创建应用程序" Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPl



我试着做

react-native run-android

但是它会出现错误

--------------
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
    Command failed: ./gradlew installDebug
    Error: Command failed: ./gradlew installDebug
        at checkExecSyncError (child_process.js:637:11)
        at Object.execFileSync (child_process.js:655:13)
        at runOnAllDevices (/Users/bobbyjulian/Desktop/ReactNative/project/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19)
        at buildAndRun (/Users/bobbyjulian/Desktop/ReactNative/project/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
        at isPackagerRunning.then.result (/Users/bobbyjulian/Desktop/ReactNative/project/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12)
        at processTicksAndRejections (internal/process/next_tick.js:81:5)

我在这里遇到了类似的问题,就我而言,它与访问权限有关。只需授予对项目文件夹的读取访问权限。

命令:

chmod -R 777 YourFolder/

我的日志错误:

spawnSync ./gradlew EACCES
Error: spawnSync ./gradlew EACCES
    at Object.spawnSync (internal/child_process.js:998:20)
    at spawnSync (child_process.js:622:24)
    at Object.execFileSync (child_process.js:650:13)
    at runOnAllDevices (/Users/willowchung/project/AwesomeApp/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19)
    at buildAndRun (/Users/willowchung/project/AwesomeApp/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
    at isPackagerRunning.then.result (/Users/willowchung/project/AwesomeApp/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

希望对您有所帮助!

run chmod 755 android/gradlew

应该完成工作

检查您正在使用的 Java JDK 版本。我首先尝试了版本 11,但遇到了与您相同的错误,然后我安装了 Java JDK 版本 8 并根据此问题正确更新JAVA_HOME设置,从而解决了问题。

这足以阻止错误

1 - 安装 JDK

列出候选 JDK:

asdf list-all java

安装上一个命令中列出的候选项,如下所示:

asdf install java openjdk-11

选择一个已安装的候选项,如下所示:

asdf global java openjdk-11

2 - 设置JAVA_HOME。要在 shell 的初始化中设置JAVA_HOME,请添加以下内容:

. ~/.asdf/plugins/java/set-java-home.bash

对于 zsh shell,请使用:

. ~/.asdf/plugins/java/set-java-home.zsh

对于鱼壳,请改用:

. ~/.asdf/plugins/java/set-java-home.fish

相关内容

  • 没有找到相关文章

最新更新