Skip to content

Commit 8eca045

Browse files
fdraultalois-beto
authored andcommitted
fix(namespace): Namespace required in module level for AGP>=8
1 parent 90f545b commit 8eca045

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

android/build.gradle

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import com.android.Version
2+
13
def DEFAULT_COMPILE_SDK_VERSION = 30
24
def DEFAULT_BUILD_TOOLS_VERSION = '30.0.2'
35
def DEFAULT_MIN_SDK_VERSION = 16
@@ -30,7 +32,29 @@ if (isNewArchitectureEnabled()) {
3032
apply plugin: 'com.facebook.react'
3133
}
3234

35+
// https://github.com/react-native-community/discussions-and-proposals/issues/671
36+
// https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes#namespace-dsl
37+
// Namespace is required in module-level when AGP version >=7.3
38+
def supportsNamespace() {
39+
def parsed = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
40+
def major = parsed[0].toInteger()
41+
def minor = parsed[1].toInteger()
42+
43+
// Namespace support was added in 7.3.0
44+
return (major == 7 && minor >= 3) || major >= 8
45+
}
46+
3347
android {
48+
if (supportsNamespace()) {
49+
namespace "com.betomorrow.rnfilelogger"
50+
51+
sourceSets {
52+
main {
53+
manifest.srcFile "src/main/AndroidManifestNew.xml"
54+
}
55+
}
56+
}
57+
3458
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
3559
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
3660
defaultConfig {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
3+
<application>
4+
<provider
5+
android:name="androidx.core.content.FileProvider"
6+
android:authorities="${applicationId}.provider"
7+
android:exported="false"
8+
android:grantUriPermissions="true">
9+
<meta-data
10+
android:name="android.support.FILE_PROVIDER_PATHS"
11+
android:resource="@xml/provider_paths"/>
12+
</provider>
13+
</application>
14+
15+
</manifest>

0 commit comments

Comments
 (0)