I've created a new React Native app and upgraded everything to latest versions (React Native, components, Gradle), yet I'm getting the following error when trying to build and deploy to device) - this is the output in VS Code terminal:
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)
I've tried adding the following to ./android/gradle.properties to make sure the project, but that seems to be causing other types of issues
android.useAndroidX=true
android.enableJetifier=true
Here's my 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 (which migrates all non-native Android modules to AndroidX) - seems to be the suggested solution, but I have that in place (Jetifier runs automatically on build - as seen above) and it doesn't help.
Any suggestions would be appreciated.