Skip to content

Commit

Permalink
Use AndroidX (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorVanian authored Nov 14, 2023
1 parent d11d059 commit faad186
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
38 changes: 34 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.android.tools.build:gradle:8.0.2'
}
}

Expand All @@ -17,8 +17,30 @@ def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

def supportsNamespace() {
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
def major = parsed[0].toInteger()
def minor = parsed[1].toInteger()

// Namespace support was added in 7.3.0
if (major == 7 && minor >= 3) {
return true
}

return major >= 8
}

android {
compileSdkVersion safeExtGet('compileSdkVersion', 27)
if (supportsNamespace()) {
namespace "com.reactnative.googlefit"
} else {
sourceSets {
main {
manifest.srcFile "src/main/AndroidManifest.xml"
}
}
}
compileSdkVersion safeExtGet('compileSdkVersion', 28)
// buildToolsVersion safeExtGet('buildToolsVersion', '27.0.3')

compileOptions {
Expand All @@ -28,7 +50,7 @@ android {

defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 27)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
versionCode 1
versionName "1.0"
}
Expand All @@ -48,11 +70,19 @@ repositories {
}

dependencies {
def supportLibVersion = safeExtGet('supportLibVersion', null)
def androidXVersion = safeExtGet('androidXVersion', null)

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation('com.facebook.react:react-native:+') {
exclude group: 'com.android.support'
}
implementation "com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '27.0.0')}"
if (supportLibVersion && androidXVersion == null) {
implementation "com.android.support:appcompat-v7:$supportLibVersion"
} else {
def defaultAndroidXVersion = "1.+"
implementation "androidx.appcompat:appcompat:${safeExtGet(androidXVersion, defaultAndroidXVersion)}"
}
implementation "com.google.android.gms:play-services-auth:${safeExtGet('authVersion', '+')}"
implementation "com.google.android.gms:play-services-fitness:${safeExtGet('fitnessVersion', '+')}"
}
15 changes: 15 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Wed Oct 11 13:41:26 CEST 2023
android.enableJetifier=true
android.useAndroidX=true

0 comments on commit faad186

Please sign in to comment.