viromedia / viro

ViroReact: AR and VR using React Native
MIT License
2.29k stars 481 forks source link

Android release: Error: package is not a valid resource name (reserved Java keyword) #547

Open skizzo opened 5 years ago

skizzo commented 5 years ago

Environment

  1. Development OS: Mac
  2. Device OS & Version: Not important since build already fails
  3. Version: react-viro 2.13.0, react-native 0.57.7
  4. 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!

dam00n commented 5 years ago

We have some steps in our latest release notes for 2.13 about Android setup starting from -> Note: Instructions for updating Android project to Target API level 28.

Release Notes link -> https://docs.viromedia.com/docs/releases

Can you follow those steps and see if they resolve your issue?

Cattari commented 5 years ago

In my case that was importing 'package.json' in react-native js app. After removing it everything works perfectly.

wbodron commented 5 years ago

If we can't import package.json, how else should we get the version number into things like api calls?

dam00n commented 5 years ago

We updated the gist reference above recently -> https://gist.github.com/achuvm/fe0136818158bec2cdf4d1cd11053f6d

yernandus commented 4 years ago

updating to 0.60.6 solved the problem for me