3

I have an app which I'm trying to compile with my original package name, very similar to this: com.mypackage.name_.app'

The app compiled successfully until now, which I migrated to the newest versions of Gradle and I'm compiling with API 24. Previously I used old versions of Gradle and API 23.

Now, when trying to compile that app, I'm getting this error:

    APT: error: attribute 'package' in tag is not a valid Java package name: 'com.mypackage.name_.app'.
    .
    .
    Failed to execute aapt
    com.android.ide.common.process.ProcessException: Failed to execute aapt
    .
    .
    Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:794)

I found here that AAPT2 doesn't allow underscore in the end of a portion of your package name: All of my android studio projects and all new ones give me errors coming from the debug android manifest file

But then, what happens if you previously compiled and released into Google Play an app with a underscore in the end of a part of your package name? For example I found this example: https://play.google.com/store/apps/details?id=com.mobincube.tarifas_taxi_.sc_35K1XV

It is released into Google Play with this package name portion ".tarifas_taxi_."

How can that developer (and me) compile now our apps with underscore in that position?

halfer
  • 19,824
  • 17
  • 99
  • 186
NullPointerException
  • 36,107
  • 79
  • 222
  • 382

1 Answers1

3

AAPT2 does not allow package names with 'words' ending or starting with the underscore character.
Here for the package "com.mypackage.name_.app" the offending word is "name_". Remove the underscore or use "name_foo" (underscores are allowed in the middle of the word) to make is work.
There's an open issue on the issue tracker for this, it's being looked at by the AAPT2's owner.

More info: https://issuetracker.google.com/68468089

Izabela Orlowska
  • 7,431
  • 2
  • 20
  • 33
  • Most likely this will be marked as 'working as intended' or will take a few months to fix, so the best solution for you is to change the package name to not have words ending with "_". – Izabela Orlowska Mar 19 '18 at 11:37