xref: /expo/android/app/build.gradle (revision 400d1b67)
1import java.nio.file.Files
2import java.nio.file.Paths
3
4apply plugin: 'kotlin-kapt'
5
6buildscript {
7  // Simple helper that allows the root project to override versions declared by this library.
8  ext.safeExtGet = { prop, fallback ->
9    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
10  }
11
12  repositories {
13    google()
14    mavenCentral()
15  }
16
17  dependencies {
18    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.6.10')}")
19  }
20}
21apply plugin: 'com.android.application'
22apply plugin: 'kotlin-android'
23apply plugin: 'com.google.firebase.crashlytics'
24
25def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
26if (expoModulesCorePlugin.exists()) {
27  apply from: expoModulesCorePlugin
28  applyKotlinExpoModulesCorePlugin()
29}
30
31android {
32  // Remove this if and it's contents, when support for SDK49 is dropped
33  if (!safeExtGet("expoProvidesDefaultConfig", false)) {
34    compileSdkVersion safeExtGet("compileSdkVersion", 33)
35
36    defaultConfig {
37      minSdkVersion safeExtGet("minSdkVersion", 23)
38      targetSdkVersion safeExtGet("targetSdkVersion", 33)
39    }
40
41    lintOptions {
42      abortOnError false
43    }
44  }
45
46  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
47  if (agpVersion.tokenize('.')[0].toInteger() < 8) {
48    compileOptions {
49      sourceCompatibility JavaVersion.VERSION_11
50      targetCompatibility JavaVersion.VERSION_11
51    }
52
53    kotlinOptions {
54      jvmTarget = JavaVersion.VERSION_11.majorVersion
55    }
56  }
57
58  defaultConfig {
59    applicationId 'host.exp.exponent'
60    // ADD VERSIONS HERE
61    // BEGIN VERSIONS
62    versionCode 192
63    versionName '2.29.0'
64    // END VERSIONS
65
66    multiDexEnabled true
67    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
68    // Deprecated. Used by net.openid:appauth
69    manifestPlaceholders = [
70        'appAuthRedirectScheme': 'host.exp.exponent'
71    ]
72  }
73  dexOptions {
74    javaMaxHeapSize System.getenv("DISABLE_DEX_MAX_HEAP") ? null : "8g"
75  }
76
77  signingConfigs {
78    debug {
79      storeFile file('../debug.keystore')
80    }
81    release {
82      storeFile file(System.getenv("ANDROID_KEYSTORE_PATH") ?: "release-key.jks")
83      storePassword System.getenv("ANDROID_KEYSTORE_PASSWORD")
84      keyAlias System.getenv("ANDROID_KEY_ALIAS")
85      keyPassword System.getenv("ANDROID_KEY_PASSWORD")
86    }
87  }
88  buildTypes {
89    debug {
90      debuggable true
91      firebaseCrashlytics {
92        nativeSymbolUploadEnabled false
93        mappingFileUploadEnabled false
94      }
95    }
96    release {
97      minifyEnabled true
98      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
99      consumerProguardFiles 'proguard-rules.pro'
100      if (!System.getenv("ANDROID_UNSIGNED")) {
101        signingConfig signingConfigs.release
102      }
103      def shouldUploadCrashlytics = System.getenv("EAS_BUILD") != null
104      firebaseCrashlytics {
105        nativeSymbolUploadEnabled shouldUploadCrashlytics
106        mappingFileUploadEnabled shouldUploadCrashlytics
107      }
108    }
109  }
110
111  flavorDimensions "versioning"
112  productFlavors {
113    versioned {
114      dimension "versioning"
115      manifestPlaceholders = [appLabel:"@string/versioned_app_name"]
116      firebaseCrashlytics {
117        unstrippedNativeLibsDir file("${buildDir}/intermediates/merged_native_libs/versionedRelease/out/lib")
118      }
119    }
120    unversioned {
121      dimension "versioning"
122      getIsDefault().set(true)
123      manifestPlaceholders = [appLabel: "@string/unversioned_app_name"]
124      firebaseCrashlytics {
125        unstrippedNativeLibsDir file("${buildDir}/intermediates/merged_native_libs/unversionedRelease/out/lib")
126      }
127    }
128  }
129
130  // `productFlavors` must be defined before this block
131  defaultConfig {
132    if (android.productFlavors.empty) {
133      // when preparing shell app, the above flavor declarations  are removed
134      // this falls back :expoview to versioned flavor
135      missingDimensionStrategy 'versioning', 'versioned'
136      manifestPlaceholders = [appLabel:"@string/versioned_app_name"]
137    }
138  }
139
140  lintOptions {
141    abortOnError false
142  }
143  packagingOptions {
144    // libfbjni.so is prebuilt library shared between all ABIs
145    pickFirst "lib/**/libfbjni.so"
146    // AGP will give priority of libc++_shared coming from App modules.
147    pickFirst "**/libc++_shared.so"
148  }
149}
150
151dependencies {
152  implementation fileTree(dir: 'libs', include: ['*.jar'])
153
154  implementation 'androidx.multidex:multidex:2.0.0'
155
156  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.6.10')}"
157
158  // Our dependencies
159  implementation ('androidx.appcompat:appcompat:1.4.1')
160
161  // Our dependencies from ExpoView
162  // DON'T ADD ANYTHING HERE THAT ISN'T IN EXPOVIEW. ONLY COPY THINGS FROM EXPOVIEW TO HERE.
163  implementation ('androidx.appcompat:appcompat:1.4.1')
164  compileOnly 'org.glassfish:javax.annotation:3.1.1'
165  implementation 'com.jakewharton:butterknife:10.2.1'
166  implementation 'de.greenrobot:eventbus:2.4.0'
167
168  implementation 'com.squareup.picasso:picasso:2.5.2'
169  implementation 'com.google.android.gms:play-services-analytics:16.0.1'
170  implementation 'com.google.android.gms:play-services-maps:18.0.0'
171  implementation 'com.google.android.gms:play-services-auth:15.0.1'
172  implementation 'com.google.android.gms:play-services-location:15.0.1'
173  debugImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
174  // debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
175  releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
176  implementation 'com.facebook.device.yearclass:yearclass:2.1.0'
177  implementation 'commons-io:commons-io:1.4'
178  implementation 'me.leolin:ShortcutBadger:1.1.4@aar'
179  implementation 'com.github.CanHub:Android-Image-Cropper:1.1.1'
180  implementation 'commons-codec:commons-codec:1.10'
181  implementation 'com.google.zxing:core:3.3.3'
182  implementation 'net.openid:appauth:0.4.1'
183  implementation 'com.airbnb.android:lottie:3.4.0'
184  implementation('io.nlopez.smartlocation:library:3.2.11') {
185    transitive = false
186  }
187  implementation "androidx.exifinterface:exifinterface:1.0.0"
188  implementation 'com.squareup.okio:okio:1.9.0'
189  implementation 'com.facebook.soloader:soloader:0.8.2'
190  implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
191
192  // expo-file-system
193  implementation 'com.squareup.okhttp3:okhttp:3.10.0'
194  implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.10.0'
195
196  // expo-image
197  def GLIDE_VERSION = "4.13.2"
198  kapt "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"
199
200  // Testing
201  androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
202  androidTestImplementation 'androidx.test:runner:1.4.0'
203  androidTestImplementation "androidx.annotation:annotation:1.3.0"
204  androidTestImplementation 'com.google.code.findbugs:jsr305:3.0.0'
205  androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
206  androidTestImplementation 'com.azimolabs.conditionwatcher:conditionwatcher:0.2'
207
208  androidTestImplementation 'junit:junit:4.13.2'
209  androidTestImplementation 'org.mockito:mockito-core:1.10.19'
210  testImplementation 'org.robolectric:robolectric:4.10'
211  androidTestImplementation 'androidx.test:runner:1.4.0'
212  androidTestImplementation 'androidx.test:rules:1.4.0'
213
214  testImplementation 'androidx.test:runner:1.4.0'
215  testImplementation 'androidx.test:rules:1.4.0'
216  testImplementation 'junit:junit:4.13.2'
217  testImplementation 'org.mockito:mockito-core:1.10.19'
218
219  // WHEN_DISTRIBUTING_REMOVE_FROM_HERE
220
221  // BEGIN_SDK_UNVERSIONED
222  implementation(project(':expoview'))
223
224  implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
225  // END_SDK_UNVERSIONED
226
227  // ADD_NEW_SDKS_HERE
228
229
230  // BEGIN_SDK_49
231  versionedImplementation(project(':expoview-abi49_0_0'))
232  // END_SDK_49
233
234
235  // BEGIN_SDK_48
236  versionedImplementation(project(':expoview-abi48_0_0'))
237  // END_SDK_48
238
239
240  // BEGIN_SDK_47
241  versionedImplementation(project(':expoview-abi47_0_0'))
242  // END_SDK_47
243}
244
245// This has to be down here for some reason
246apply plugin: 'com.google.gms.google-services'
247
248def ensureCrashlyticsDir = tasks.register('ensureCrashlyticsDir') {
249  doLast {
250    Files.createDirectories(Paths.get("${buildDir}/intermediates/merged_native_libs/versionedRelease/out/lib"))
251    Files.createDirectories(Paths.get("${buildDir}/intermediates/merged_native_libs/unversionedRelease/out/lib"))
252  }
253}
254preBuild.dependsOn(ensureCrashlyticsDir)
255