Skip to content

Commit

Permalink
fix: add namespace to build.gradle for gradle 8 compat (required for …
Browse files Browse the repository at this point in the history
…0.73) (react-native-webview#3055)

* Update build.gradle

* improve fix

* Update build.gradle

* Update build.gradle

---------

Co-authored-by: Thibault Malbranche <malbranche.thibault@gmail.com>
  • Loading branch information
alexhernandez and Titozzz committed Oct 6, 2023
1 parent 2c44da2 commit c4c8e4c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
22 changes: 22 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ def isNewArchitectureEnabled() {
return project.hasProperty("newArchEnabled") && project.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
}

apply plugin: 'com.android.library'
if (isNewArchitectureEnabled()) {
Expand All @@ -44,6 +56,16 @@ if (isNewArchitectureEnabled()) {
apply plugin: 'kotlin-android'

android {
if (supportsNamespace()) {
namespace "com.reactnativecommunity.webview"

sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
}
}
}

compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')

defaultConfig {
Expand Down
13 changes: 13 additions & 0 deletions android/src/main/AndroidManifestNew.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<provider
android:name=".RNCWebViewFileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider_paths" />
</provider>
</application>
</manifest>

0 comments on commit c4c8e4c

Please sign in to comment.