Skip to content

Commit

Permalink
fix: Fix namespace/AndroidManifest.package error on Android Gradl…
Browse files Browse the repository at this point in the history
…e Plugin 8/React Native 0.73 (#624)
  • Loading branch information
mrousavy committed Jan 18, 2024
1 parent 5dab096 commit 8ca6ae5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
19 changes: 16 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import com.android.Version

def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
def agpVersionMajor = agpVersion.tokenize('.')[0].toInteger()
def androidManifestPath = agpVersionMajor >= 7 ? 'src/main/AndroidManifest.xml' : 'src/hasNamespace/AndroidManifest.xml'

buildscript {
repositories {
maven {
Expand Down Expand Up @@ -46,16 +52,23 @@ repositories {
}

android {
namespace = "com.reactnativemmkv"
compileSdkVersion safeExtGet("compileSdkVersion", 28)
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersionMajor >= 7) {
namespace = "com.reactnativemmkv"
}

if (agpVersion.tokenize('.')[0].toInteger() >= 8) {
if (agpVersionMajor >= 8) {
buildFeatures {
buildConfig = true
}
}

sourceSets {
main {
manifest.srcFile androidManifestPath
}
}

// Used to override the NDK path/version on internal CI or by allowing
// users to customize the NDK path/version from their root project (e.g. for M1 support)
if (rootProject.hasProperty("ndkPath")) {
Expand Down
3 changes: 3 additions & 0 deletions android/src/hasNamespace/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>

0 comments on commit 8ca6ae5

Please sign in to comment.