Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aapt2 + mobile-install v1 doesn't build a runnable APK #5799

Closed
jin opened this issue Aug 8, 2018 · 9 comments
Closed

aapt2 + mobile-install v1 doesn't build a runnable APK #5799

jin opened this issue Aug 8, 2018 · 9 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Android Issues for Android team type: bug

Comments

@jin
Copy link
Member

jin commented Aug 8, 2018

Bug report from @sunyal:

Building the example app from Bazel Android Tutorial with --android_aapt=aapt2 results in a un-runnable app. App is fine with --android_aapt=aapt.

    --------- beginning of crash
08-06 16:37:41.616 11490-11490/com.google.bazel.example.android E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.google.bazel.example.android, PID: 11490
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.bazel.example.android/com.google.bazel.example.android.activities.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f040000 type #0x5 is not valid
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
@jin jin self-assigned this Aug 8, 2018
@jin jin added the P1 I'll work on this now. (Assignee required) label Aug 8, 2018
@jin
Copy link
Member Author

jin commented Aug 8, 2018

Reproduced:

08-08 11:42:21.568  6551  6551 D AndroidRuntime: Shutting down VM
08-08 11:42:21.569  6551  6551 E AndroidRuntime: FATAL EXCEPTION: main
08-08 11:42:21.569  6551  6551 E AndroidRuntime: Process: com.google.bazel.example.android, PID: 6551
08-08 11:42:21.569  6551  6551 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.bazel.example.android/com.google.bazel.example.android.activities.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f040000 type #0x5 is not valid
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.app.ActivityThread.-wrap11(Unknown Source:0)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:105)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:164)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6541)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f040000 type #0x5 is not valid
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.content.res.Resources.loadXmlResourceParser(Resources.java:2138)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.content.res.Resources.getLayout(Resources.java:1142)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:418)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.app.Activity.setContentView(Activity.java:2654)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at com.google.bazel.example.android.activities.MainActivity.onCreate(MainActivity.java:42)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:6975)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
08-08 11:42:21.569  6551  6551 E AndroidRuntime: 	... 9 more

@jin
Copy link
Member Author

jin commented Aug 10, 2018

@sunyal I can reproduce this with bazel mobile-install but not bazel build && adb install. Did you try it with mobile-install?

@AlexBeggs
Copy link
Contributor

@jin if I recall it was through bazel mobile-install

@AlexBeggs
Copy link
Contributor

@jin does it work if you call bazel build and then use the adb install or are you also able to use the build mobile-install after it is built?

@AlexBeggs
Copy link
Contributor

AlexBeggs commented Aug 10, 2018

@jin I was able to install it and run it using the adb install command after just issuing the bazel build. It looks like the issue is related to bazel mobile-install

@jin jin changed the title Example not runnable when built with aapt2 aapt2 + mobile-install v1 doesn't build a runnable APK Aug 10, 2018
@jin
Copy link
Member Author

jin commented Aug 10, 2018

@sunyal thanks for confirming! It's definitely an issue with mobile-install.

@jin jin added team-Android Issues for Android team P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed P1 I'll work on this now. (Assignee required) labels Aug 11, 2018
@jin
Copy link
Member Author

jin commented Aug 13, 2018

Hey @sunyal, the mobile-install built in Bazel is actually v1 of the command. There is mobile-install v2, a rewrite of v1, due to be open sourced this quarter. That version is more feature packed and works with aapt2. Since v2 will be replacing v1, I'm downgrading this to P3 as v1 will eventually go away.

For now, the workaround to use aapt2 would be to use bazel build and adb install. Sorry for the inconvenience.

@AlexBeggs
Copy link
Contributor

AlexBeggs commented Aug 14, 2018 via email

@jin jin removed their assignment Aug 14, 2018
@jin
Copy link
Member Author

jin commented Dec 8, 2018

@sunyal this is fixed, and will be available in 0.22 (or head now)

luca-digrazia pushed a commit to luca-digrazia/DatasetCommitsDiffSearch that referenced this issue Sep 4, 2022
    Previously, the resource apk was always built with aapt regardless of configuration. This threads the aapt version into the resource processing action builder.

    Fixes: bazelbuild/bazel#5799

    Ref: bazelbuild/bazel#6814

    RELNOTES: mobile-install now works with aapt2. Try it out with `bazel mobile-install --android_aapt=aapt2 //my:target`
    PiperOrigin-RevId: 224566567
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Android Issues for Android team type: bug
Projects
None yet
Development

No branches or pull requests

2 participants