Execution failed for task ':react-native-webview:compileDebugKotlin' - android

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.
"react": "17.0.2",
"react-native": "0.68.2",
"#babel/core": "^7.12.9",
"#babel/runtime": "^7.12.5",
"#react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"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

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
}
}
// ...
}

Try running this command on the android folder.
sudo ./gradlew compileDebugKotlin
This worked for me.

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!

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

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' }
}
}

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.

Related

Kotlin: The binary version of its metadata is 1.8.0, expected version is 1.6.0

I have an app coded in react native that I'm trying to upload to the google play store, but I'm running into some issues when I am trying to compile the .aab file.
Whenever i try to reload my gradle project I am greeted with 356 errors all relating to the version of kotlin used to compile.
(This is the error message:
e: E: ... \App\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\utils\TaskUtils.kt: (24, 12): Class 'kotlin.collections.ArraysKt___ArraysKt' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
The class is loaded from C:/Users/USERNAME/.gradle/wrapper/dists/gradle-8.0-rc-1-bin/di0yrgntpr7ydpxe8yasu72eh/gradle-8.0-rc-1/lib/kotlin-stdlib-1.8.0-RC2.jar!/kotlin/collections/ArraysKt___ArraysKt.class)
I have already changed my build.gradle file to include the current versions of gradle and kotlin, this is what it looks like:
buildscript {
ext.kotlin_version = '1.8.0'
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
//kotlin_version = '1.8.0' //use latest
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"
}
}
//ext.kotlin_version = '1.7.21' //use latest
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.0.0-alpha11")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath("com.android.tools.build:gradle:8.0.0-alpha11")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
//implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
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")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}
Any help would be greatly appreciated!
1、ext.kotlin_version = '1.6.0'
2、Setting the following in the project build.gradle:
change "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" version to "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0
3、Setting the following in the app build.gradle:
check 'androidx.core:core-ktx:1.6.0' version
Because attribute "$kotlin_version" has been updated

Unable to resolve class.org.apache.tools.ant.taskdefs.condition.Os in React Native

I opened up my build gradle because andoid emulator is not working and this is what I saw:
and this is the whole code:
build.gradle
import org.apache.tools.ant.taskdefs.condition.Os
// Top-level build file where you can add configuration options common to all sub-projects/modules.
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"
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
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
}
}
allprojects {
repositories {
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")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}
I think this is the reason why android emulator is not working? What should I do to remove the error? Thank you in advance!!!
I faced the same issue while building my old application. I just upgraded my react-native project to the newer version and deleted the old build folder from "App/android/build".
To upgrade your project, go to the official link:
https://react-native-community.github.io/upgrade-helper/
select your version and the newer version you want to upgrade to.
after making changes to all the files mentioned there, delete the build folder.
Then run command "npx react-native run-android"
NOTE: You might get an error while creating or deleting a file or directory because of wrong permissions. Use commands below:
In linux : chmod 755 "/path of the showing error of permission"
In windows : run cmd as administrator

Stripe Installation failed in react native android

I am trying to install the stripe SDK for the stripe payment gateway. I have the provider for the stripe in my App.js with the publishable key. When I try to run the android its build fails with the following error
Execution failed for task ':app:checkDebugAarMetadata'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
I have tried some solutions available online but nothing seems to work.
Here is my build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
mavenLocal()
jcenter() {
content {
includeModule("com.yqritc", "android-scalablevideoview")
}
}
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()
maven { url 'https://www.jitpack.io' }
}
}
The latest version of stripe-react-native is using compileSdkVersion 31, please check if your Android project is using the same compileSdkVersion, otherwise you might want to update your project's compileSdkVersion or use an older version of stripe-react-native
if you are using compileSdkVersion 29 you can use
"#stripe/stripe-react-native": "^0.1.2"
its work for me
npm i #stripe/stripe-react-native#0.1.2
Add this inside /android/gradle.properties
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true

Execution failed for task ':tipsi-stripe:generateDebugRFile' Could not find com.google.firebase:firebase-core:17.3.4

I am trying to implement Tipsi-stripe in my project, yet after attempting to link manually all the dependencies I am getting the following error
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':tipsi-stripe:generateDebugRFile'.
> Could not resolve all files for configuration ':tipsi-stripe:debugCompileClasspath'.
> Could not find com.google.firebase:firebase-core:17.3.4.
Required by:
project :tipsi-stripe
This is my android/app/build.gradle
dependencies {
implementation 'com.google.firebase:firebase-core:17.3.4' //Added by Antek
implementation platform('com.google.firebase:firebase-bom:28.0.0') //Added by Antek
...
}
This is my android/build.gradle
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
// googlePlayServicesVersion = "16.1.0" // default: "+"
firebaseVersion = "17.3.4" // default: "+"
}
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
classpath 'com.google.gms:google-services:4.3.5'// <- Added this line
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google() //Added by Antek
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")
}
maven { url "https://jitpack.io" }
jcenter()
}
}
And the following are my (problem related) dependencies in package.json
"dependencies": {
...
"#react-native-firebase/app": "^11.4.1",
"#react-native-firebase/auth": "^11.4.1",
"#react-native-firebase/firestore": "^11.4.1",
"#react-native-firebase/messaging": "^11.4.1",
"tipsi-stripe": "^9.0.0"
}
How do I solve this error? I tried cleaning the gradlew with gradlew clean, however nothing seems to be working so far :(
You may not have seen the news, but Stripe just release their own React Native SDK stripe-react-native (github) recently, currently in open beta.
I highly recommend you review that package and the associate guides (eg, accept-a-payment) and shift your integration efforts towards that instead.

Could not find com.android.tools.build:gradle:3.5

I'm trying to update gradle from 1.3.1 to 3.5, as some of my dependencies requires version 3.3 or above.
I've seen similar questions, but none of them help.
build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5'
}
}
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
Still i'm getting this when trying to do anything (build, clean etc):
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'chat'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.5.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.5/gradle-3.5.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.5/gradle-3.5.jar
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
To fix this issue check do you have google() repo in your project's level build.gradle file.
buildscript {
repositories {
jcenter()
google() //HAVE YOU MISS IT?
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
jcenter()
google() //HAVE YOU MISS IT?
}
}
There is a difference between the Android Plugin for Gradle version and the Gradle version being used. The plugin version typically matches the version number of Android Studio you are using. See the documentation for more information. So if using the latest stable Android Studio it should currently be com.android.tools.build:gradle:2.3.1.
These values can also be reviewed and set from the Project Structure window in Android Studio.
Try this
** If you are using android studio 3.5 and your build.gradle(Project
level) is=> classpath 'com.android.tools.build:gradle:3.5.1' or =>
classpath 'com.android.tools.build:gradle:3.5.1'.
than replace with ***
classpath 'com.android.tools.build:gradle:3.3.2' to
classpath 'com.android.tools.build:gradle:3.5.0'
OR
classpath 'com.android.tools.build:gradle:3.5.1'
I had google() repo both in buildscript and allprojects repositories, but still it shows me Could not find gradle-3.5.3 error
Finally I added maven { url "https://maven.google.com" }, and it fixed the errors!
project's level build.gradle:
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
maven { url "https://maven.google.com" } // <= this line
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://maven.google.com" } // <= this line
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://www.jitpack.io' }
}
}
You may need to save your build.gradle (for whatever reason, Android Studio doesn't always save your latest changes, as I found even with Android Studio 3.5.3, the gradle sync kept failing even after I had changed the classpath line, and it only picked up the new value after saving the build.gradle file)
I got an error after changing version code from 2 to 2.1.
When I opened the build with ctrl+shift+alt+s, I realized adding .1 (decimals) resulted in a $ symbol being added to the right and so build failed. I opted to use numbers without decimal positions and it worked.
For example, I used 3 for buildversion because I wanted to upgrade the app in playstore.

Categories

Resources