【问题标题】:react-native run-android after config jetifier配置 jetifier 后的 react-native run-android
【发布时间】:2019-12-20 04:09:28
【问题描述】:

FAILURE:构建失败并出现异常。

8 秒后构建失败

错误 无法安装应用程序。确保您已设置 Android 开发环境:https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment。使用 --verbose 标志运行 CLI 以获取更多详细信息。 错误:命令失败:gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE:构建失败并出现异常。

8 秒后构建失败

at checkExecSyncError (child_process.js:616:11)
at execFileSync (child_process.js:634:15)
at runOnAllDevices (C:\Users\k7aled\Desktop\reactnative\test2\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
at buildAndRun (C:\Users\k7aled\Desktop\reactnative\test2\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
at C:\Users\k7aled\Desktop\reactnative\test2\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async Command.handleAction (C:\Users\k7aled\Desktop\reactnative\test2\node_modules\@react-native-community\cli\build\cliEntry.js:160:7)

PS C:\Users\k7aled\Desktop\reactnative\test2> npx react-native run-android info 运行 jetifier 将库迁移到 AndroidX。您可以使用“--no-jetifier”标志禁用它。 Jetifier 找到 928 个文件来转发-jetify。使用 4 名工人... info 正在启动 JS 服务器... info 正在安装应用程序...

FAILURE:构建失败并出现异常。

10 秒后构建失败

错误 无法安装应用程序。确保您已设置 Android 开发环境:https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment。使用 --verbose 标志运行 CLI 以获取更多详细信息。 错误:命令失败:gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE:构建失败并出现异常。

10 秒后构建失败

at checkExecSyncError (child_process.js:616:11)
at execFileSync (child_process.js:634:15)
at runOnAllDevices (C:\Users\k7aled\Desktop\reactnative\test2\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
at buildAndRun (C:\Users\k7aled\Desktop\reactnative\test2\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
at C:\Users\k7aled\Desktop\reactnative\test2\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async Command.handleAction (C:\Users\k7aled\Desktop\reactnative\test2\node_modules\@react-native-community\cli\build\cliEntry.js:160:7)

PS C:\Users\k7aled\Desktop\reactnative\test2>

【问题讨论】:

    标签: react-native


    【解决方案1】:

    首先将这两行添加到您的 android/gradle.properties 中:

    android.useAndroidX=true
    android.enableJetifier=true
    

    然后使用终端(cmd)在项目根目录中运行这两个命令行:

    npm i jetifier
    npx jetify
    

    【讨论】:

      猜你喜欢
      • 2020-01-17
      • 1970-01-01
      • 2017-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多