From 4ad210b6c7a095321db41c5d6c32bb13873bea55 Mon Sep 17 00:00:00 2001 From: KrzysztofMoch Date: Mon, 25 Sep 2023 12:08:11 +0200 Subject: [PATCH 1/3] chore(android/gradle): update namespace handler --- android/build.gradle | 30 ++++++++++++++++++++----- android/src/main/AndroidManifestNew.xml | 2 ++ 2 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 android/src/main/AndroidManifestNew.xml diff --git a/android/build.gradle b/android/build.gradle index fc609670..efc72f3b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -24,11 +24,20 @@ def getExtOrDefault(name, defaultValue) { } def isNewArchitectureEnabled() { - // To opt-in for the New Architecture, you can either: - // - Set `newArchEnabled` to true inside the `gradle.properties` file - // - Invoke gradle with `-newArchEnabled=true` - // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` - return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" + return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true" +} + +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 } def useExoplayerIMA = safeExtGet("RNVUseExoplayerIMA", false) @@ -48,7 +57,16 @@ if (isNewArchitectureEnabled()) { } android { - namespace 'com.brentvatne.react' + if (supportsNamespace()) { + namespace 'com.brentvatne.react' + + sourceSets { + main { + manifest.srcFile "src/main/AndroidManifestNew.xml" + } + } + } + compileSdkVersion safeExtGet('compileSdkVersion', 31) buildToolsVersion safeExtGet('buildToolsVersion', '30.0.2') diff --git a/android/src/main/AndroidManifestNew.xml b/android/src/main/AndroidManifestNew.xml new file mode 100644 index 00000000..a2f47b60 --- /dev/null +++ b/android/src/main/AndroidManifestNew.xml @@ -0,0 +1,2 @@ + + From 842a156b3cc88a3c72237bb7a3546390d4da8ace Mon Sep 17 00:00:00 2001 From: KrzysztofMoch Date: Mon, 25 Sep 2023 12:17:33 +0200 Subject: [PATCH 2/3] chore(android/gradle): remove doubled `compileOptions` --- android/build.gradle | 5 ----- 1 file changed, 5 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index efc72f3b..11487135 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,11 +91,6 @@ android { exclude "**/libreact_render*.so" } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - buildDir 'buildOutput_' + configStringPath sourceSets { From 01c8e54e12a2528d54ed425e803bd20df61f9147 Mon Sep 17 00:00:00 2001 From: KrzysztofMoch Date: Mon, 25 Sep 2023 12:24:08 +0200 Subject: [PATCH 3/3] chore(android/gradle): add suport for AGP 8 --- android/build.gradle | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 11487135..7a786fa2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -70,9 +70,16 @@ android { compileSdkVersion safeExtGet('compileSdkVersion', 31) buildToolsVersion safeExtGet('buildToolsVersion', '30.0.2') - compileOptions { - targetCompatibility JavaVersion.VERSION_1_8 - sourceCompatibility JavaVersion.VERSION_1_8 + def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION + if (agpVersion.tokenize('.')[0].toInteger() < 8) { + compileOptions { + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11.majorVersion + } } defaultConfig { @@ -87,6 +94,10 @@ android { } } + buildFeatures { + buildConfig true + } + packagingOptions { exclude "**/libreact_render*.so" }