@@ -2,17 +2,7 @@ apply plugin: "com.android.application"
22apply plugin : " org.jetbrains.kotlin.android"
33apply plugin : " com.facebook.react"
44
5- import com.android.build.OutputFile
6-
75def projectRoot = rootDir. getAbsoluteFile(). getParentFile(). getAbsolutePath()
8- def expoDebuggableVariants = [' debug' ]
9- // Override `debuggableVariants` for expo-updates debugging
10- if (System . getenv(' EX_UPDATES_NATIVE_DEBUG' ) == " 1" ) {
11- react {
12- expoDebuggableVariants = []
13- }
14- }
15-
166
177/**
188 * This is the configuration block to customize your React Native Android app.
@@ -22,17 +12,20 @@ react {
2212 entryFile = file([" node" , " -e" , " require('expo/scripts/resolveAppEntry')" , projectRoot, " android" , " absolute" ]. execute(null , rootDir). text. trim())
2313 reactNativeDir = new File ([" node" , " --print" , " require.resolve('react-native/package.json')" ]. execute(null , rootDir). text. trim()). getParentFile(). getAbsoluteFile()
2414 hermesCommand = new File ([" node" , " --print" , " require.resolve('react-native/package.json')" ]. execute(null , rootDir). text. trim()). getParentFile(). getAbsolutePath() + " /sdks/hermesc/%OS-BIN%/hermesc"
25- debuggableVariants = expoDebuggableVariants
15+ codegenDir = new File ([" node" , " --print" , " require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })" ]. execute(null , rootDir). text. trim()). getParentFile(). getAbsoluteFile()
16+
17+ // Use Expo CLI to bundle the app, this ensures the Metro config
18+ // works correctly with Expo projects.
19+ cliFile = new File ([" node" , " --print" , " require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })" ]. execute(null , rootDir). text. trim())
20+ bundleCommand = " export:embed"
2621
2722 /* Folders */
28- // The root of your project, i.e. where "package.json" lives. Default is '..'
29- // root = file("../")
30- // The folder where the react-native NPM package is. Default is ../node_modules/react-native
31- // reactNativeDir = file("../node_modules/react-native")
32- // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
33- // codegenDir = file("../node_modules/react-native-codegen")
34- // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
35- // cliFile = file("../node_modules/react-native/cli.js")
23+ // The root of your project, i.e. where "package.json" lives. Default is '../..'
24+ // root = file("../../")
25+ // The folder where the react-native NPM package is. Default is ../../node_modules/react-native
26+ // reactNativeDir = file("../../node_modules/react-native")
27+ // The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
28+ // codegenDir = file("../../node_modules/@react-native/codegen")
3629
3730 /* Variants */
3831 // The list of variants to that are debuggable. For those we're going to
@@ -43,9 +36,7 @@ react {
4336 /* Bundling */
4437 // A list containing the node command and its flags. Default is just 'node'.
4538 // nodeExecutableAndArgs = ["node"]
46- //
47- // The command to run when bundling. By default is 'bundle'
48- // bundleCommand = "ram-bundle"
39+
4940 //
5041 // The path to the CLI configuration file. Default is empty.
5142 // bundleConfig = file(../rn-cli.config.js)
@@ -67,22 +58,10 @@ react {
6758 // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
6859 // hermesFlags = ["-O", "-output-source-map"]
6960
61+ /* Autolinking */
7062 autolinkLibrariesWithApp()
7163}
7264
73- // Override `hermesEnabled` by `expo.jsEngine`
74- ext {
75- hermesEnabled = (findProperty(' expo.jsEngine' ) ?: " hermes" ) == " hermes"
76- }
77-
78- /**
79- * Set this to true to create four separate APKs instead of one,
80- * one for each native architecture. This is useful if you don't
81- * use App Bundles (https://developer.android.com/guide/app-bundle/)
82- * and want to have separate APKs to upload to the Play Store.
83- */
84- def enableSeparateBuildPerCPUArchitecture = false
85-
8665/**
8766 * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
8867 */
@@ -101,21 +80,11 @@ def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInRelea
10180 */
10281def jscFlavor = ' org.webkit:android-jsc:+'
10382
104- /**
105- * Private function to get the list of Native Architectures you want to build.
106- * This reads the value from reactNativeArchitectures in your gradle.properties
107- * file and works together with the --active-arch-only flag of react-native run-android.
108- */
109- def reactNativeArchitectures () {
110- def value = project. getProperties(). get(" reactNativeArchitectures" )
111- return value ? value. split(" ," ) : [" armeabi-v7a" , " x86" , " x86_64" , " arm64-v8a" ]
112- }
113-
11483android {
11584 ndkVersion rootProject. ext. ndkVersion
11685
11786 buildToolsVersion rootProject. ext. buildToolsVersion
118- compileSdkVersion rootProject. ext. compileSdkVersion
87+ compileSdk rootProject. ext. compileSdkVersion
11988
12089 namespace ' com.callstack.reactnativepaperexample'
12190 defaultConfig {
@@ -125,15 +94,6 @@ android {
12594 versionCode 28
12695 versionName " 3.14.0"
12796 }
128-
129- splits {
130- abi {
131- reset()
132- enable enableSeparateBuildPerCPUArchitecture
133- universalApk false // If true, also generate a universal APK
134- include (* reactNativeArchitectures())
135- }
136- }
13797 signingConfigs {
13898 debug {
13999 storeFile file(' debug.keystore' )
@@ -153,24 +113,17 @@ android {
153113 shrinkResources (findProperty(' android.enableShrinkResourcesInReleaseBuilds' )?. toBoolean() ?: false )
154114 minifyEnabled enableProguardInReleaseBuilds
155115 proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
116+ crunchPngs (findProperty(' android.enablePngCrunchInReleaseBuilds' )?. toBoolean() ?: true )
156117 }
157118 }
158-
159- // applicationVariants are e.g. debug, release
160- applicationVariants. all { variant ->
161- variant. outputs. each { output ->
162- // For each separate APK per architecture, set a unique version code as described here:
163- // https://developer.android.com/studio/build/configure-apk-splits.html
164- // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
165- def versionCodes = [" armeabi-v7a" : 1 , " x86" : 2 , " arm64-v8a" : 3 , " x86_64" : 4 ]
166- def abi = output. getFilter(OutputFile . ABI )
167- if (abi != null ) { // null for the universal-debug, universal-release variants
168- output. versionCodeOverride =
169- defaultConfig. versionCode * 1000 + versionCodes. get(abi)
170- }
171-
119+ packagingOptions {
120+ jniLibs {
121+ useLegacyPackaging (findProperty(' expo.useLegacyPackaging' )?. toBoolean() ?: false )
172122 }
173123 }
124+ androidResources {
125+ ignoreAssetsPattern ' !.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
126+ }
174127}
175128
176129// Apply static values from `gradle.properties` to the `android.packagingOptions`
@@ -200,35 +153,24 @@ dependencies {
200153 def isGifEnabled = (findProperty(' expo.gif.enabled' ) ?: " " ) == " true" ;
201154 def isWebpEnabled = (findProperty(' expo.webp.enabled' ) ?: " " ) == " true" ;
202155 def isWebpAnimatedEnabled = (findProperty(' expo.webp.animated' ) ?: " " ) == " true" ;
203- def frescoVersion = rootProject. ext. frescoVersion
204-
205- // If your app supports Android versions before Ice Cream Sandwich (API level 14)
206- if (isGifEnabled || isWebpEnabled) {
207- implementation(" com.facebook.fresco:fresco:${ frescoVersion} " )
208- implementation(" com.facebook.fresco:imagepipeline-okhttp3:${ frescoVersion} " )
209- }
210156
211157 if (isGifEnabled) {
212158 // For animated gif support
213- implementation(" com.facebook.fresco:animated-gif:${ frescoVersion } " )
159+ implementation(" com.facebook.fresco:animated-gif:${ reactAndroidLibs.versions.fresco.get() } " )
214160 }
215161
216162 if (isWebpEnabled) {
217163 // For webp support
218- implementation(" com.facebook.fresco:webpsupport:${ frescoVersion } " )
164+ implementation(" com.facebook.fresco:webpsupport:${ reactAndroidLibs.versions.fresco.get() } " )
219165 if (isWebpAnimatedEnabled) {
220166 // Animated webp support
221- implementation(" com.facebook.fresco:animated-webp:${ frescoVersion } " )
167+ implementation(" com.facebook.fresco:animated-webp:${ reactAndroidLibs.versions.fresco.get() } " )
222168 }
223169 }
224170
225- implementation(" androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" )
226-
227171 if (hermesEnabled. toBoolean()) {
228172 implementation(" com.facebook.react:hermes-android" )
229173 } else {
230174 implementation jscFlavor
231175 }
232176}
233-
234- applyNativeModulesAppBuildGradle(project)
0 commit comments