创建应用程序时反应本机错误“无法使用BuildScopeServices.createScriptPluginFactory()创建ScriptPluginFactory类型的服务。”

时间:2019-01-29 03:29:44

标签: react-native

我试图做

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)

4 个答案:

答案 0 :(得分:2)

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

命令:

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)

希望有帮助!

答案 1 :(得分:2)

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

答案 2 :(得分:0)

run chmod 755 android/gradlew

应该做的工作

答案 3 :(得分:0)

这足以阻止错误

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