11apply plugin : " com.android.application"
2+ apply plugin : " org.jetbrains.kotlin.android"
23apply plugin : " com.facebook.react"
34
4- import com.android.build.OutputFile
5-
65def projectRoot = rootDir. getAbsoluteFile(). getParentFile(). getAbsolutePath()
7- def expoDebuggableVariants = [' debug' ]
8- // Override `debuggableVariants` for expo-updates debugging
9- if (System . getenv(' EX_UPDATES_NATIVE_DEBUG' ) == " 1" ) {
10- react {
11- expoDebuggableVariants = []
12- }
13- }
14-
156
167/**
178 * This is the configuration block to customize your React Native Android app.
@@ -21,17 +12,20 @@ react {
2112 entryFile = file([" node" , " -e" , " require('expo/scripts/resolveAppEntry')" , projectRoot, " android" , " absolute" ]. execute(null , rootDir). text. trim())
2213 reactNativeDir = new File ([" node" , " --print" , " require.resolve('react-native/package.json')" ]. execute(null , rootDir). text. trim()). getParentFile(). getAbsoluteFile()
2314 hermesCommand = new File ([" node" , " --print" , " require.resolve('react-native/package.json')" ]. execute(null , rootDir). text. trim()). getParentFile(). getAbsolutePath() + " /sdks/hermesc/%OS-BIN%/hermesc"
24- 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"
2521
2622 /* Folders */
2723 // The root of your project, i.e. where "package.json" lives. Default is '..'
2824 // root = file("../")
2925 // The folder where the react-native NPM package is. Default is ../node_modules/react-native
3026 // reactNativeDir = file("../node_modules/react-native")
31- // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
32- // codegenDir = file("../node_modules/react-native-codegen")
33- // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
34- // cliFile = file("../node_modules/react-native/cli.js")
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")
3529
3630 /* Variants */
3731 // The list of variants to that are debuggable. For those we're going to
@@ -42,9 +36,7 @@ react {
4236 /* Bundling */
4337 // A list containing the node command and its flags. Default is just 'node'.
4438 // nodeExecutableAndArgs = ["node"]
45- //
46- // The command to run when bundling. By default is 'bundle'
47- // bundleCommand = "ram-bundle"
39+
4840 //
4941 // The path to the CLI configuration file. Default is empty.
5042 // bundleConfig = file(../rn-cli.config.js)
@@ -67,19 +59,6 @@ react {
6759 // hermesFlags = ["-O", "-output-source-map"]
6860}
6961
70- // Override `hermesEnabled` by `expo.jsEngine`
71- ext {
72- hermesEnabled = (findProperty(' expo.jsEngine' ) ?: " hermes" ) == " hermes"
73- }
74-
75- /**
76- * Set this to true to create four separate APKs instead of one,
77- * one for each native architecture. This is useful if you don't
78- * use App Bundles (https://developer.android.com/guide/app-bundle/)
79- * and want to have separate APKs to upload to the Play Store.
80- */
81- def enableSeparateBuildPerCPUArchitecture = false
82-
8362/**
8463 * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
8564 */
@@ -98,20 +77,11 @@ def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInRelea
9877 */
9978def jscFlavor = ' org.webkit:android-jsc:+'
10079
101- /**
102- * Private function to get the list of Native Architectures you want to build.
103- * This reads the value from reactNativeArchitectures in your gradle.properties
104- * file and works together with the --active-arch-only flag of react-native run-android.
105- */
106- def reactNativeArchitectures () {
107- def value = project. getProperties(). get(" reactNativeArchitectures" )
108- return value ? value. split(" ," ) : [" armeabi-v7a" , " x86" , " x86_64" , " arm64-v8a" ]
109- }
110-
11180android {
11281 ndkVersion rootProject. ext. ndkVersion
11382
114- compileSdkVersion rootProject. ext. compileSdkVersion
83+ buildToolsVersion rootProject. ext. buildToolsVersion
84+ compileSdk rootProject. ext. compileSdkVersion
11585
11686 namespace ' com.anonymous.rnexpoexample'
11787 defaultConfig {
@@ -121,15 +91,6 @@ android {
12191 versionCode 1
12292 versionName " 1.0.0"
12393 }
124-
125- splits {
126- abi {
127- reset()
128- enable enableSeparateBuildPerCPUArchitecture
129- universalApk false // If true, also generate a universal APK
130- include (* reactNativeArchitectures())
131- }
132- }
13394 signingConfigs {
13495 debug {
13596 storeFile file(' debug.keystore' )
@@ -151,20 +112,9 @@ android {
151112 proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
152113 }
153114 }
154-
155- // applicationVariants are e.g. debug, release
156- applicationVariants. all { variant ->
157- variant. outputs. each { output ->
158- // For each separate APK per architecture, set a unique version code as described here:
159- // https://developer.android.com/studio/build/configure-apk-splits.html
160- // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
161- def versionCodes = [" armeabi-v7a" : 1 , " x86" : 2 , " arm64-v8a" : 3 , " x86_64" : 4 ]
162- def abi = output. getFilter(OutputFile . ABI )
163- if (abi != null ) { // null for the universal-debug, universal-release variants
164- output. versionCodeOverride =
165- defaultConfig. versionCode * 1000 + versionCodes. get(abi)
166- }
167-
115+ packagingOptions {
116+ jniLibs {
117+ useLegacyPackaging (findProperty(' expo.useLegacyPackaging' )?. toBoolean() ?: false )
168118 }
169119 }
170120}
@@ -196,42 +146,27 @@ dependencies {
196146 def isGifEnabled = (findProperty(' expo.gif.enabled' ) ?: " " ) == " true" ;
197147 def isWebpEnabled = (findProperty(' expo.webp.enabled' ) ?: " " ) == " true" ;
198148 def isWebpAnimatedEnabled = (findProperty(' expo.webp.animated' ) ?: " " ) == " true" ;
199- def frescoVersion = rootProject. ext. frescoVersion
200-
201- // If your app supports Android versions before Ice Cream Sandwich (API level 14)
202- if (isGifEnabled || isWebpEnabled) {
203- implementation(" com.facebook.fresco:fresco:${ frescoVersion} " )
204- implementation(" com.facebook.fresco:imagepipeline-okhttp3:${ frescoVersion} " )
205- }
206149
207150 if (isGifEnabled) {
208151 // For animated gif support
209- implementation(" com.facebook.fresco:animated-gif:${ frescoVersion } " )
152+ implementation(" com.facebook.fresco:animated-gif:${ reactAndroidLibs.versions.fresco.get() } " )
210153 }
211154
212155 if (isWebpEnabled) {
213156 // For webp support
214- implementation(" com.facebook.fresco:webpsupport:${ frescoVersion } " )
157+ implementation(" com.facebook.fresco:webpsupport:${ reactAndroidLibs.versions.fresco.get() } " )
215158 if (isWebpAnimatedEnabled) {
216159 // Animated webp support
217- implementation(" com.facebook.fresco:animated-webp:${ frescoVersion } " )
160+ implementation(" com.facebook.fresco:animated-webp:${ reactAndroidLibs.versions.fresco.get() } " )
218161 }
219162 }
220163
221- implementation(" androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" )
222-
223- debugImplementation(" com.facebook.flipper:flipper:${ FLIPPER_VERSION} " )
224- debugImplementation(" com.facebook.flipper:flipper-network-plugin:${ FLIPPER_VERSION} " ) {
225- exclude group :' com.squareup.okhttp3' , module :' okhttp'
226- }
227- debugImplementation(" com.facebook.flipper:flipper-fresco-plugin:${ FLIPPER_VERSION} " )
228-
229164 if (hermesEnabled. toBoolean()) {
230165 implementation(" com.facebook.react:hermes-android" )
231166 } else {
232167 implementation jscFlavor
233168 }
234169}
235170
236- apply from : new File ([" node" , " --print" , " require.resolve('@react-native-community/cli-platform-android/package.json')" ]. execute(null , rootDir). text. trim(), " ../native_modules.gradle" );
171+ apply from : new File ([" node" , " --print" , " require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] } )" ]. execute(null , rootDir). text. trim(), " ../native_modules.gradle" );
237172applyNativeModulesAppBuildGradle(project)
0 commit comments