diff --git a/android/build.gradle b/android/build.gradle index dada51b0..bc15ec8c 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -58,6 +58,27 @@ if (isNewArchitectureEnabled()) { apply plugin: "com.facebook.react" } +def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger() +def shouldUseNameSpace = agpVersion >= 7 +def PACKAGE_PROP = "package=\"com.zoontek.rnpermissions\"" +def manifestOutFile = file("${projectDir}/src/main/AndroidManifest.xml") +def manifestContent = manifestOutFile.getText() +if(shouldUseNameSpace){ + manifestContent = manifestContent.replaceAll( + PACKAGE_PROP, + '' + ) +} else { + if(!manifestContent.contains("$PACKAGE_PROP")){ + manifestContent = manifestContent.replace( + '