13

After upgrading react native from 0.61.2 to 0.68.2 with RN update helper, gradle cant build app. Getting this error

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':react-native-webview:compileDebugKotlin'.

java.io.IOException: Permission denied

trying all react-native-webview versions but result is same.

when i removeing "react-native-webview": "^8.0.3" this line from package.json file then build successfully goes but app getting error because this dependency used in app

below dependency versions which i using.

  1. "react": "17.0.2",
  2. "react-native": "0.68.2",
  3. "@babel/core": "^7.12.9",
  4. "@babel/runtime": "^7.12.5",
  5. "@react-native-community/eslint-config": "^2.0.0",
  6. "babel-jest": "^26.6.3",
  7. "eslint": "^7.32.0",

distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-all.zip

android/build.gralde

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888"
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529"
        }
    }

    dependencies {
    classpath("com.android.tools.build:gradle:7.0.4")
    classpath 'com.google.gms:google-services:4.3.8'
    classpath("com.facebook.react:react-native-gradle-plugin")
    classpath("de.undercouch:gradle-download-task:4.1.2")
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
1

7 Answers 7

24

If you face the issue from Nov 4th 2022,

Fix for react-native >= 0.63 and lower than 0.67

In android/buld.gradle file,

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    // ...
}


allprojects {
    repositories {
+       exclusiveContent {
+           // We get React Native's Android binaries exclusively through npm,
+           // from a local Maven repo inside node_modules/react-native/.
+           // (The use of exclusiveContent prevents looking elsewhere like Maven Central
+           // and potentially getting a wrong version.)
+           filter {
+               includeGroup "com.facebook.react"
+           }
+           forRepository {
+               maven {
+                   // NOTE: if you are in a monorepo, you may have "$rootDir/../../../node_modules/react-native/android"
+                   url "$rootDir/../node_modules/react-native/android"
+               }
+           }
+       }
        // ...
    }
}

What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules.

Once you update your app to React Native v0.71.0, this fix won't be needed anymore.

Fix for older react-native (< 0.63)

The fix above only works on gradle 6.2 and higher. Older react-native used older gradle.

You may determine your gradle version by looking in your /android/gradle/wrapper/gradle-wrapper.properties file.

If you are on older react-native (for example 0.63 or earlier) that uses gradle version 6.1 or below, you must use a different workaround, detailed here: #35210 (comment)

Updated On Nov 11th 2022

If the above solution is not working for you then try this one.

In android/buld.gradle file,

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

allprojects {
    configurations.all {
        resolutionStrategy {
            // Remove this override in 0.66, as a proper fix is included in react-native itself.
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }
    // ...
}
Sign up to request clarification or add additional context in comments.

2 Comments

I'd been having the same issue since Nov. 4th and fixed it using your suggestion. Thank you. It was turning into a nightmare. Do you have any idea why is this happening though?
@AminDannak, See the details here: github.com/facebook/react-native/issues/35210
5

In android/buld.gradle file you have to specify kotlinVersion to "1.6.0"

buildscript {
ext {
     //... other fields
    kotlinVersion = "1.6.0" //1 <- here is solution
    RNNKotlinVersion = kotlinVersion //2 <- here is solution
}
dependencies {
    // kotlinVersion you have defined above dot this to koltin version // solution next line
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")//3 <- here is solution
   
}
}

Comments

4

Try running this command on the android folder.

sudo ./gradlew compileDebugKotlin

This worked for me.

Comments

1

Upgarding your react native version can work 0.63.x to 0.63.5 0.65.x to 0.65.3 0.66.x to 0.66.5 0.68.x to 0.68.5 0.69.x to 0.69.7 0.70.x to 0.70.5

Comments

0

If you don't want to use in your project then remove it by uninstall lib not only from package.json

npm uninstall react-native-webview

If you want to use then, Please Update it to latest version of it:

"react-native-webview": "^11.17.2",

For ios:

delete pods and reinstall pods

cd ios && pod install

For Android: delete build and rebuild it

Hope it works!

4 Comments

not working with latest version (( same error
Not working facing same error
use the latest stable version 12.1.0
0

You can try the below setting inside android/build.gradle file

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        kotlin_version = '1.6.10'
    }
    repositories {
        mavenCentral()
        google()
        jcenter()
        maven { url "https://dl.bintray.com/android/android-tools/"  }
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.2")
        classpath 'com.google.gms:google-services:4.3.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

        // Add the Crashlytics Gradle plugin (be sure to add version
        // 2.0.0 or later if you built your app with Android Studio 4.1).
//         classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'

//          classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
    }
}

allprojects {
    repositories {
        exclusiveContent {
            // We get React Native's Android binaries exclusively through npm,
            // from a local Maven repo inside node_modules/react-native/.
            // (The use of exclusiveContent prevents looking elsewhere like Maven Central
            // and potentially getting a wrong version.)
            filter {
                includeGroup "com.facebook.react"
            }
            forRepository {
                maven {
                    // NOTE: if you are in a monorepo, you may have "$rootDir/../../../node_modules/react-native/android"
                    url "$rootDir/../node_modules/react-native/android"
                }
            }
        }
        mavenCentral()
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../../../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../../../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

Comments

0

I was using react-native version 0.64.0, then based on this issue, I upgraded to 0.64.4 and everything is fine now.

this is the useful part of the issue's solution:

📢 Patches for >= 0.63 We have prepared releases for all the main versions of react-native with an hotfix:

🛳 0.70.5: https://github.com/facebook/react-native/releases/tag/v0.70.5 🛳️ 0.69.7: https://github.com/facebook/react-native/releases/tag/v0.69.7 🛳 0.68.5: https://github.com/facebook/react-native/releases/tag/v0.68.5 🛳️ 0.67.5: https://github.com/facebook/react-native/releases/tag/v0.67.5 🛳️ 0.66.5: https://github.com/facebook/react-native/releases/tag/v0.66.5 🛳️ 0.65.3: https://github.com/facebook/react-native/releases/tag/v0.65.3 🛳️ 0.64.4: https://github.com/facebook/react-native/releases/tag/v0.64.4 🛳️ 0.63.5: https://github.com/facebook/react-native/releases/tag/v0.63.5

By updating to these patch versions, your Android build should start working again.

To do so, in your package.json change react-native's version to the relevant new patch (ex. if you are on 0.64.3, change to 0.64.4) and run yarn install. No other changes should be necessary, but you might want to clean your android artifacts with a cd android && ./gradlew clean before trying to re-run your Android app.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.