Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

[BUG] Decompile/compile with resources off (-r flag) makes app crash on startup

Open lucaswxp opened this issue 4 years ago • 5 comments
trafficstars

Information

  1. Apktool Version (apktool -version) - 2.4.1
  2. Operating System (Mac, Linux, Windows) - Linux
  3. APK From? (Playstore, ROM, Other) - Playstore

Stacktrace/Logcat

06-26 22:06:43.685 19186 19186 W PackageManager: Failure retrieving xml 0x7f150002 in package com.instagram.android
06-26 22:06:43.685 19186 19186 W PackageManager: android.content.res.Resources$NotFoundException: File r/b0y.xml from xml type xml resource ID #0x7f150002
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1149)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.content.res.Resources.loadXmlResourceParser(Resources.java:2150)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.content.res.Resources.getXml(Resources.java:1206)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.app.ApplicationPackageManager.getXml(ApplicationPackageManager.java:2193)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.content.pm.PackageItemInfo.loadXmlMetaData(PackageItemInfo.java:393)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at androidx.core.content.FileProvider.A00(:33)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at androidx.core.content.FileProvider.attachInfo(:12)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.app.ActivityThread.installProvider(ActivityThread.java:6578)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6133)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6043)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.app.ActivityThread.-wrap1(Unknown Source:0)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.os.Handler.dispatchMessage(Handler.java:105)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.os.Looper.loop(Looper.java:164)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.app.ActivityThread.main(ActivityThread.java:6944)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at java.lang.reflect.Method.invoke(Native Method)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
06-26 22:06:43.685 19186 19186 W PackageManager: Caused by: java.io.FileNotFoundException: r/b0y.xml
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.content.res.AssetManager.openXmlAssetNative(Native Method)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:560)
06-26 22:06:43.685 19186 19186 W PackageManager: 	at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1134)
06-26 22:06:43.685 19186 19186 W PackageManager: 	... 17 more

Steps to Reproduce

  1. apktool decode -f -r -o temp/ instagram.apk
  2. apktool build temp/ -o new.apk

APK

https://www.apkmirror.com/apk/instagram/instagram-instagram/instagram-instagram-192-0-0-35-123-release/

I also tested with latest version of apktool, doesn't work either. But when I remove the -r flag, it works (after changing some configs). Isn't the point of having the -r to avoid such error of missing resources? What steps should I take to try to manually fix it?

Thank you.

lucaswxp avatar Jun 27 '21 01:06 lucaswxp

Can you confirm what I'm rephrasing is correct?

You have a working bootable modified application when you apktool d/b without -r. However, when you introduce -r and do apktool b/d - the application fails with the stacktrace above

iBotPeaches avatar Jun 29 '21 10:06 iBotPeaches

That is correct. When I remove the -r it kinda works, at least the app boots.

Em ter., 29 de jun. de 2021 06:51, Connor Tumbleson < @.***> escreveu:

Can you confirm what I'm rephrasing is correct?

You have a working bootable modified application when you apktool d/b without -r. However, when you introduce -r and do apktool b/d - the application fails with the stacktrace above

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/iBotPeaches/Apktool/issues/2598#issuecomment-870489275, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABAB4WQLLGT4LVPXZ7SPSDTVGQSTANCNFSM47L4AQYQ .

lucaswxp avatar Jun 29 '21 12:06 lucaswxp

Just to make it clear, when I remove -r I get some resources errors that I can fix with --pause flag, thats fine, the app boots normally.

But with -r flag I dont get any compilation error, tho the app doesnt even boot and prints the stacktrace above.

Em ter., 29 de jun. de 2021 06:51, Connor Tumbleson < @.***> escreveu:

Can you confirm what I'm rephrasing is correct?

You have a working bootable modified application when you apktool d/b without -r. However, when you introduce -r and do apktool b/d - the application fails with the stacktrace above

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/iBotPeaches/Apktool/issues/2598#issuecomment-870489275, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABAB4WQLLGT4LVPXZ7SPSDTVGQSTANCNFSM47L4AQYQ .

lucaswxp avatar Jun 29 '21 12:06 lucaswxp

I have the same problem with most apps. Compiled app crashes with resource related errors such as this. Some apps crash with -r flag, some without -r flag, some crash with both.

Test app: https://drive.google.com/file/d/1Y0CZy0l626ZYKT6lydUygQrjTIsObnJ9/view?usp=sharing

timea-techgirl avatar Aug 05 '21 17:08 timea-techgirl

can fix with --pause flag

@lucaswxp Can you explain this --pause flag. Didn't find anything realted to this flag in the repo.

I am also having some resource errors with apps when decompiled without -r.

sriteja777 avatar Nov 19 '21 10:11 sriteja777