构建失败,出现异常java.io.IOException:权限被拒绝

时间:2019-12-26 17:59:18

标签: android linux react-native gradle

我正试图让一个React Native项目在我的Linux Mint PC上运行,但由于出现以下错误消息,我正在努力做到这一点:

yarn android
yarn run v1.21.1
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 977 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
/bin/sh: 1: /user/local/Android/Sdk/platform-tools/adb: not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...

FAILURE: Build failed with an exception.

* Wh

at went wrong:
    java.io.IOException: Permission denied

    * 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

    error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
    Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

    FAILURE: Build failed with an exception.

    * What went wrong:
    java.io.IOException: Permission denied

    * 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

        at checkExecSyncError (child_process.js:603:11)
        at execFileSync (child_process.js:621:15)
        at runOnAllDevices (/home/guilherme/Workspace/soccerama/soccerama-mobile-rn/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 977 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...

FAILURE: Build failed with an exception.

* What went wrong:
java.io.IOException: Permission denied

* 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

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
java.io.IOException: Permission denied

* 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

    at checkExecSyncError (child_process.js:603:11)
    at execFileSync (child_process.js:621:15)
    at runOnAllDevices (/home/guilherme/Workspace/soccerama/soccerama-mobile-rn/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
    at buildAndRun (/home/guilherme/Workspace/soccerama/soccerama-mobile-rn/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
    at /home/guilherme/Workspace/soccerama/soccerama-mobile-rn/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Command.handleAction (/home/guilherme/Workspace/soccerama/soccerama-mobile-rn/node_modules/@react-native-community/cli/build/index.js:164:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

据我所知,这与gradle的权限有关,并且我尝试了以下操作:

chown -R username ./android/gradlew
chmod 777 -R ./android
chmod +x ./android/gradlew

但是这些似乎都无法解决我的问题。如果有人可以在这里帮助我,我将不胜感激。

1 个答案:

答案 0 :(得分:-1)

尝试一下:

1-建立gradle。如果没有问题,请继续访问您应用的android文件夹。即c:\ folder \ app \ android

2-输入./gradlew clean

3-运行react-native run-android