React Native 0.60.5-构建时任务:expo-constants:compileDebugJavaWithJavac FAILED

时间:2019-09-06 15:36:18

标签: android react-native gradle androidx

我创建了一个新的React Native应用并将所有内容升级到最新版本(React Native,组件,Gradle),但是在尝试构建和部署到设备时出现以下错误)-这是输出VS Code终端:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\myAppFolder\MyApp\MyApp> react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1187 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :app
...
.../*more debugging progress output here*/..
...
ace
 unimodules-sensors-interface@3.0.0 from C:\myAppFolder\MyApp\MyApp\node_modules\unimodules-sensors-interface
 unimodules-task-manager-interface@3.0.0 from C:\myAppFolder\MyApp\MyApp\node_modules\unimodules-task-manager-interface

> Task :expo-constants:compileDebugJavaWithJavac

> Task :expo-constants:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.6.1/userguide/command_line_interface.html#sec:command_line_warnings
84 actionable tasks: 1 executed, 83 up-to-date
C:\MyAppFolder\MyApp\MyApp\node_modules\expo-constants\android\src\main\java\expo\modules\constants\ConstantsService.java:6: error: cannot find symbol
import androidx.annotation.Nullable;
                          ^
  symbol:   class Nullable
  location: package androidx.annotation
C:\MyAppFolder\MyApp\MyApp\node_modules\expo-constants\android\src\main\java\expo\modules\constants\ConstantsService.java:51: error: cannot find symbol
  @Nullable
   ^
  symbol:   class Nullable
  location: class ConstantsService
2 errors

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':expo-constants:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 6m 2s

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.bat app:installDebug -PreactNativeDevServerPort=8081
C:\MyAppFolder\MyApp\MyApp\node_modules\expo-constants\android\src\main\java\expo\modules\constants\ConstantsService.java:6: error: cannot find symbol
import androidx.annotation.Nullable;
                          ^
  symbol:   class Nullable
  location: package androidx.annotation
C:\MyAppFolder\MyApp\MyApp\node_modules\expo-constants\android\src\main\java\expo\modules\constants\ConstantsService.java:51: error: cannot find symbol
  @Nullable
   ^
  symbol:   class Nullable
  location: class ConstantsService
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':expo-constants:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 6m 2s

    at checkExecSyncError (child_process.js:616:11)
    at execFileSync (child_process.js:634:15)
    at runOnAllDevices (C:\MyAppFolder\MyApp\MyAPp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
    at buildAndRun (C:\MyAppFolder\MyApp\MyAPp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
    at C:\MyAppFolder\MyApp\MyAPp\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:\MyAppFolder\MyApp\MyApp\node_modules\react-native\node_modules\@react-native-community\cli\build\cliEntry.js:160:7)

我尝试将以下内容添加到./android/gradle.properties中以确保该项目,但这似乎引起了其他类型的问题

android.useAndroidX=true
android.enableJetifier=true

这是我的package.json

{
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "web": "expo start --web",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.6.1",
    "expo": "^34.0.4",
    "react": "16.9.0",
    "react-dom": "^16.9.0",
    "react-native": "0.60.5",
    "react-native-elements": "^1.2.0",
    "react-native-gesture-handler": "~1.4.1",
    "react-native-reanimated": "~1.2.0",
    "react-native-unimodules": "~0.5.4",
    "react-native-vector-icons": "^6.6.0",
    "react-native-web": "^0.11.7",
    "react-navigation": "^4.0.0",
    "react-navigation-tabs": "^2.4.0"
  },
  "devDependencies": {
    "@babel/core": "^7.5.5",
    "babel-jest": "24.9.0",
    "jest": "24.9.0",
    "jetifier": "^1.6.4",
    "metro-react-native-babel-preset": "0.56.0",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  },
  "private": true
}

Jetifier(将所有非本地Android模块都迁移到AndroidX)-似乎是建议的解决方案,但我已经就位(Jetifier在构建时自动运行-如上所示),并且没有帮助。

任何建议将不胜感激。

0 个答案:

没有答案