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,21 @@ 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")
29+
3530
3631 /* Variants */
3732 // The list of variants to that are debuggable. For those we're going to
@@ -43,9 +38,6 @@ react {
4338 // A list containing the node command and its flags. Default is just 'node'.
4439 // nodeExecutableAndArgs = ["node"]
4540 //
46- // The command to run when bundling. By default is 'bundle'
47- // bundleCommand = "ram-bundle"
48- //
4941 // The path to the CLI configuration file. Default is empty.
5042 // bundleConfig = file(../rn-cli.config.js)
5143 //
@@ -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.rnh.example'
11787 defaultConfig {
@@ -120,16 +90,9 @@ android {
12090 targetSdkVersion rootProject. ext. targetSdkVersion
12191 versionCode 1
12292 versionName " 1.0.0"
93+ buildConfigField(" boolean" , " REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS" , (findProperty(" reactNative.unstable_useRuntimeSchedulerAlways" ) ?: true ). toString())
12394 }
12495
125- splits {
126- abi {
127- reset()
128- enable enableSeparateBuildPerCPUArchitecture
129- universalApk false // If true, also generate a universal APK
130- include (* reactNativeArchitectures())
131- }
132- }
13396 signingConfigs {
13497 debug {
13598 storeFile file(' debug.keystore' )
@@ -151,19 +114,9 @@ android {
151114 }
152115 }
153116
154- // applicationVariants are e.g. debug, release
155- applicationVariants. all { variant ->
156- variant. outputs. each { output ->
157- // For each separate APK per architecture, set a unique version code as described here:
158- // https://developer.android.com/studio/build/configure-apk-splits.html
159- // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
160- def versionCodes = [" armeabi-v7a" : 1 , " x86" : 2 , " arm64-v8a" : 3 , " x86_64" : 4 ]
161- def abi = output. getFilter(OutputFile . ABI )
162- if (abi != null ) { // null for the universal-debug, universal-release variants
163- output. versionCodeOverride =
164- defaultConfig. versionCode * 1000 + versionCodes. get(abi)
165- }
166-
117+ packagingOptions {
118+ jniLibs {
119+ useLegacyPackaging (findProperty(' expo.useLegacyPackaging' )?. toBoolean() ?: false )
167120 }
168121 }
169122}
@@ -195,35 +148,22 @@ dependencies {
195148 def isGifEnabled = (findProperty(' expo.gif.enabled' ) ?: " " ) == " true" ;
196149 def isWebpEnabled = (findProperty(' expo.webp.enabled' ) ?: " " ) == " true" ;
197150 def isWebpAnimatedEnabled = (findProperty(' expo.webp.animated' ) ?: " " ) == " true" ;
198- def frescoVersion = rootProject. ext. frescoVersion
199-
200- // If your app supports Android versions before Ice Cream Sandwich (API level 14)
201- if (isGifEnabled || isWebpEnabled) {
202- implementation(" com.facebook.fresco:fresco:${ frescoVersion} " )
203- implementation(" com.facebook.fresco:imagepipeline-okhttp3:${ frescoVersion} " )
204- }
205151
206152 if (isGifEnabled) {
207153 // For animated gif support
208- implementation(" com.facebook.fresco:animated-gif:${ frescoVersion } " )
154+ implementation(" com.facebook.fresco:animated-gif:${ reactAndroidLibs.versions.fresco.get() } " )
209155 }
210156
211157 if (isWebpEnabled) {
212158 // For webp support
213- implementation(" com.facebook.fresco:webpsupport:${ frescoVersion } " )
159+ implementation(" com.facebook.fresco:webpsupport:${ reactAndroidLibs.versions.fresco.get() } " )
214160 if (isWebpAnimatedEnabled) {
215161 // Animated webp support
216- implementation(" com.facebook.fresco:animated-webp:${ frescoVersion } " )
162+ implementation(" com.facebook.fresco:animated-webp:${ reactAndroidLibs.versions.fresco.get() } " )
217163 }
218164 }
219165
220- implementation(" androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" )
221-
222- debugImplementation(" com.facebook.flipper:flipper:${ FLIPPER_VERSION} " )
223- debugImplementation(" com.facebook.flipper:flipper-network-plugin:${ FLIPPER_VERSION} " ) {
224- exclude group :' com.squareup.okhttp3' , module :' okhttp'
225- }
226- debugImplementation(" com.facebook.flipper:flipper-fresco-plugin:${ FLIPPER_VERSION} " )
166+ implementation(" com.facebook.react:flipper-integration" )
227167
228168 if (hermesEnabled. toBoolean()) {
229169 implementation(" com.facebook.react:hermes-android" )
@@ -232,5 +172,5 @@ dependencies {
232172 }
233173}
234174
235- apply from : new File ([" node" , " --print" , " require.resolve('@react-native-community/cli-platform-android/package.json')" ]. execute(null , rootDir). text. trim(), " ../native_modules.gradle" );
175+ 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" );
236176applyNativeModulesAppBuildGradle(project)
0 commit comments