Fixed
Status Update
Comments
jo...@gmail.com <jo...@gmail.com> #2
Digging further, this isn't a problem with Gradle, but rather the AAPT daemon, probably due to a unpushed change occurring around this part of the code: https://android.googlesource.com/platform/frameworks/base/+/master/tools/aapt2/cmd/Link.cpp#764
Can this ticket please be reassigned to the appropriate component?
To reproduce:
$ANDROID_HOME/build-tools/27.0.3/aapt2 link --manifest $BUTTERKNIFE_REPO_CLONE_ROOT/butterknife/build/intermediates/manifests/aapt/release/AndroidManifest.xml -o .
Can this ticket please be reassigned to the appropriate component?
To reproduce:
$ANDROID_HOME/build-tools/27.0.3/aapt2 link --manifest $BUTTERKNIFE_REPO_CLONE_ROOT/butterknife/build/intermediates/manifests/aapt/release/AndroidManifest.xml -o .
jo...@gmail.com <jo...@gmail.com> #3
The issue doesn't occur when I explicitly define build-tools v27.0.1 in my build.gradle (which requires a downgrade to AGP 3.1.0-alpha09), so it looks like the issue was introduced in build-tools v27.0.2 (a file size check also appears to confirm this, although I realize that's not a foolproof indicator).
$ANDROID_HOME/build-tools/27.0.1/aapt2 version
Android Asset Packaging Tool (aapt) 2:19
$ANDROID_HOME/build-tools/27.0.2/aapt2 version
Android Asset Packaging Tool (aapt) 2:19
$ANDROID_HOME/build-tools/27.0.3/aapt2 version
Android Asset Packaging Tool (aapt) 2:19
ls -l $ANDROID_HOME/build-tools/27.0.1/aapt2
-rwxr-xr-x 1 jrod 2853 2739732 Dec 22 17:59 $ANDROID_HOME/build-tools/27.0.1/aapt2
ls -l $ANDROID_HOME/build-tools/27.0.2/aapt2
-rwxr-xr-x 1 jrod 2853 2740588 Dec 16 12:22 $ANDROID_HOME/build-tools/27.0.2/aapt2
ls -l $ANDROID_HOME/build-tools/27.0.3/aapt2
-rwxr-xr-x 1 jrod 2853 2740588 Dec 22 16:49 $ANDROID_HOME/build-tools/27.0.3/aapt2
I'm unfamiliar with how AAPT is versioned, but examining its release notes history, perhaps some changes were made recently without updating the version/release notes?
$ANDROID_HOME/build-tools/27.0.1/aapt2 version
Android Asset Packaging Tool (aapt) 2:19
$ANDROID_HOME/build-tools/27.0.2/aapt2 version
Android Asset Packaging Tool (aapt) 2:19
$ANDROID_HOME/build-tools/27.0.3/aapt2 version
Android Asset Packaging Tool (aapt) 2:19
ls -l $ANDROID_HOME/build-tools/27.0.1/aapt2
-rwxr-xr-x 1 jrod 2853 2739732 Dec 22 17:59 $ANDROID_HOME/build-tools/27.0.1/aapt2
ls -l $ANDROID_HOME/build-tools/27.0.2/aapt2
-rwxr-xr-x 1 jrod 2853 2740588 Dec 16 12:22 $ANDROID_HOME/build-tools/27.0.2/aapt2
ls -l $ANDROID_HOME/build-tools/27.0.3/aapt2
-rwxr-xr-x 1 jrod 2853 2740588 Dec 22 16:49 $ANDROID_HOME/build-tools/27.0.3/aapt2
I'm unfamiliar with how AAPT is versioned, but examining its release notes history, perhaps some changes were made recently without updating the version/release notes?
xa...@google.com <xa...@google.com>
ad...@google.com <ad...@google.com> #4
Having a package name like 'butterknife' fails to install. The check has moved to AAPT2 to help developers catch this earlier.
adb: failed to install /mnt/android/master/out/target/product/generic/data/app/Test/Test.apk: Failure [INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: Invalid manifest package: must have at least one '.' separator]
adb: failed to install /mnt/android/master/out/target/product/generic/data/app/Test/Test.apk: Failure [INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: Invalid manifest package: must have at least one '.' separator]
ja...@gmail.com <ja...@gmail.com> #5
This is a library, not an app. That check should be done in Gradle against the applicationId for users of com.android.application plugins and not in the tooling that has to process resources for libraries and applications.
ja...@gmail.com <ja...@gmail.com> #6
Or a flag to aapt2 that this is for a library such that the check is not run.
ad...@google.com <ad...@google.com>
ja...@gmail.com <ja...@gmail.com> #7
Getting this with a second library now that uses a single element package name for its manifest and code.
ma...@gmail.com <ma...@gmail.com> #8
So AAPT2 doesn't allow package names containing a single word, right? I have a multi-module Android project and one of these modules has a package name 'base'. Now after enabling AAPT2 I'm getting the following error:
error: attribute 'package' in <manifest> tag is not a valid Android package name: 'base'.
Is it a bug or intended behavior? Do I have to rename the package now?
error: attribute 'package' in <manifest> tag is not a valid Android package name: 'base'.
Is it a bug or intended behavior? Do I have to rename the package now?
to...@google.com <to...@google.com> #9
This is "working as coded". However, there can be an argument to be made to allow this for libraries since they're never installed on device. It's unclear what this means to namespacing because we expect the package name to be a valid java name [ie. at least one '.'].
rt...@google.com <rt...@google.com> #10
+Izabela
Could we move this check to Gradle when building applications and remove this logic from AAPT2? We could then change the error into a warning for people using AAPT2 directly.
Could we move this check to Gradle when building applications and remove this logic from AAPT2? We could then change the error into a warning for people using AAPT2 directly.
ai...@gmail.com <ai...@gmail.com> #11
> the package name to be a valid java name [ie. at least one '.']
But this is valid java package name and it's not so rare to have one level package (and some even advocate for this practice to have shorter packages)
But this is valid java package name and it's not so rare to have one level package (and some even advocate for this practice to have shorter packages)
je...@google.com <je...@google.com> #12
if you want to use short package name, you need to start with a dot like '.base' and it will be added to your main package name by the manifest merger.
is this what you are doing ?
is this what you are doing ?
im...@google.com <im...@google.com> #13
@10 Yeah, doing a package name validity check on our side makes sense.
jr...@squareup.com <jr...@squareup.com> #14
Any updates on this?
im...@google.com <im...@google.com> #16
We're still working on allowing package names without dots in library modules. I'll update this bug once that's in.
im...@google.com <im...@google.com> #17
@11 For application modules we now detect early if the package is incorrect. The check can now be removed from AAPT2.
ku...@google.com <ku...@google.com>
zs...@salesforce.com <zs...@salesforce.com> #18
This is going to cause a lot of headache with namespaced resources for anyone using Butter Knife, as it will cause the build to fail
jo...@happy.co <jo...@happy.co> #19
It sure is. We're having to rewrite the package & namespace now we've upgraded to Bazel 4.
im...@google.com <im...@google.com>
cm...@google.com <cm...@google.com>
cm...@google.com <cm...@google.com>
cm...@google.com <cm...@google.com> #20
Done in 3243e148dbbf6a2e55cf8c99ba46311ae95e51fd, which will land in AGP 8.5.0-alpha01
an...@google.com <an...@google.com> #21
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Koala | 2024.1.1 Canary 3
- Android Gradle Plugin 8.5.0-alpha03
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description
Android Plugin Version: 3.1.0-beta3
Module Compile Sdk Version: 27
Module Build Tools Version: latest
Android SDK Tools version: 26.1.1
Cloning Butterknife and updating to the latest Gradle and Android Plugin versions, I get the following when I run `./gradlew assemble`:
/Users/jrod/Development/butterknife/butterknife/build/intermediates/manifests/aapt/release/AndroidManifest.xml:2: AAPT: error: attribute 'package' in <manifest> tag is not a valid Android package name: 'butterknife'.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':butterknife:verifyReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt