执行任务失败:react-native-native-webview:compiledebugkotlin'

发布于 2025-01-31 12:02:45 字数 1615 浏览 6 评论 0原文

在使用RN更新助手使用RN更新后,Gradle CH build build build app将REACT本地升级为0.61.2。获取此错误

故障:构建失败而异常。

  • 出了什么问题: 执行失败的任务':react-native-webview:compiledebugkotlin'。

java.io.ioexception:拒绝权限

尝试所有React-Native-webview版本,但结果是相同的。

当我删除“ react-native-webview”:“^8.0.3”该行中的该行

  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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

生活了然无味 2025-02-07 12:02:46

如果您从2022年11月4日开始面对问题,

React-native> = 0.63且低于0.67 。

修复了Android/buld.gradle.gradle的 文件,

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

此修复程序将要做的是应用一个排除的分辨率规则,该规则将迫使React Antial Android库的分辨率使用node_modules内部。

一旦您更新应用程序以对本机V0.71.0进行反应,则将不再需要此修复程序。

修复了较旧的反应(< 0.63)

上面的修复仅适用于Gradle 6.2及更高的固定。较旧的反应生物使用了较旧的gradle。

您可以通过查看/android/gradle/warpper/gradle-wrapper.properties 文件。

如果您使用Gradle版本6.1或以下的较旧的反应本地(例如0.63或更早),则必须在此处使用其他解决方法,请在此处详细介绍:#35210(评论)

在2022年11月11日更新了

上述解决方案,为您工作,然后尝试这个。

android/buld.gradle文件中

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

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
        }
    }
    // ...
}
相思碎 2025-02-07 12:02:46

android/buld.gradle文件中,您必须指定kotlinversion到“ 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
   
}
}

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
   
}
}
呆橘 2025-02-07 12:02:46

尝试在Android文件夹上运行此命令。

sudo ./gradlew compiledebugkotlin

这对我有用。

Try running this command on the android folder.

sudo ./gradlew compileDebugKotlin

This worked for me.

寄离 2025-02-07 12:02:46

如果您不想在项目中使用,请通过卸载lib不仅从软件包

npm uninstall react-native-webview

删除

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

。 用于Android的豆荚和重新安装豆荚

cd ios && pod install


删除构建并重建它

希望它有效!

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!

浅浅 2025-02-07 12:02:46

上网您的React本地版本可以正常工作
0.63.x至0.63.5
0.65.x至0.65.3
0.66.x至0.66.5
0.68.x至0.68.5
0.69.x至0.69.7
0.70.x至0.70.5

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

小清晰的声音 2025-02-07 12:02:46

您可以在Android/build.gradle文件中尝试以下设置

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

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' }
    }
}
鱼窥荷 2025-02-07 12:02:46

我正在使用React-Native版本0.64.0,然后基于 this ,我升级到0.64.4,现在一切都很好。

这是该问题解决方案的有用部分:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文