Android release: Error: package is not a valid resource name (reserved Java keyword)
See original GitHub issueEnvironment
- Development OS: Mac
- Device OS & Version: Not important since build already fails
- Version:
react-viro 2.13.0
,react-native 0.57.7
- Device(s): Not important since build already fails
Description
./gradlew assembleGvrRelease
always fails, with different errors depending on what steps have been taken.
Reproducible Demo
1: [RELEASE] Error after following install instructions
After following the instructions of this gist to integrate react-viro
into Android, running ./gradlew assembleGvrRelease
results in this error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
2: [RELEASE] Error after adding default flavor dimension
Nothing in the docs suggests how to fix this (easily reproducible) error, so I assumed that it only happens in my current environment. Googling the error suggested that I add flavorDimensions "default"
above the productFlavors
block in android/app/build.gradle
, so after doing that, the error above doesn’t show any more when running ./gradlew assembleGvrRelease
, but this one:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeGvrReleaseResources'.
> /Users/steff/Github/iazzu/app/android/app/build/generated/res/react/gvr/release/raw/package.json: Error: package is not a valid resource name (reserved Java keyword)
3: [DEBUG] Build error when running react-native run-android --variant=arDebug
Now when I run react-native run-android --variant=arDebug
with a connected physical device (not in emulator), I get the following error:
> Task :app:mergeArDebugResources FAILED
[string/app_name] /Users/steff/Github/iazzu/app/android/app/src/main/res/values/strings.xml [string/app_name] /Users/steff/Github/iazzu/app/android/app/build/generated/res/resValues/ar/debug/values/generated.xml: Error: Duplicate resources
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeArDebugResources'.
> [string/app_name] /Users/steff/Github/iazzu/app/android/app/src/main/res/values/strings.xml [string/app_name] /Users/steff/Github/iazzu/app/android/app/build/generated/res/resValues/ar/debug/values/generated.xml: Error: Duplicate resources
Since I’m not exactly an Android expert, I have no idea how to solve this issue. Needless to say that googling this error didn’t turn out to be successful, so please give me your thoughts on this. Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
In my case that was importing ‘package.json’ in react-native js app. After removing it everything works perfectly.
If we can’t import package.json, how else should we get the version number into things like api calls?