question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
Cattaricommented, May 7, 2019

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

2reactions
wbodroncommented, Jul 16, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Import is not a valid resource name (reserved Java keyword)
Hi I face this error when I tried to declare import in string.xml why import is not a valid resource it just a...
Read more >
FileResourceNameValidator.java - android Git repositories
* Validate a file-based resource name as it is being typed in a text field. *. * Partial or no extensions are allowed,...
Read more >
Error:Error: ':' is not a valid resource name character [37071888]
This issue tracker is a technical resource focused on the Android Open ... The error message suggests that you have a string with...
Read more >
Error "Package AndroidManifest.xml is not a valid Java ...
xml is not a valid Java package name as 'for' is a Java Keyword" (see attached screenshot). Unity does not allow me to...
Read more >
Introduction to Custom Keywords - Katalon Docs
Because software written in the Java programming language or similar languages can ... Enter a name for your keyword and specify a package...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found