Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

App crashes on 2.4.0, does not crash on 2.3.4

Open gilhartman opened this issue 6 years ago • 8 comments

Information

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

Stacktrace/Logcat

03-06 10:30:41.516 E/AndroidRuntime(29350): FATAL EXCEPTION: main
03-06 10:30:41.516 E/AndroidRuntime(29350): Process: com.ghostsq.commander, PID: 29350
03-06 10:30:41.516 E/AndroidRuntime(29350): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ghostsq.commander/com.appdome.ui.LoginActivity}: android.view.InflateException: Binary XML file line #13: Binary XML file line #13: Error inflating class <unknown>
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.ActivityThread.-wrap11(Unknown Source:0)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.os.Handler.dispatchMessage(Handler.java:106)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.os.Looper.loop(Looper.java:164)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.ActivityThread.main(ActivityThread.java:6494)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at java.lang.reflect.Method.invoke(Native Method)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
03-06 10:30:41.516 E/AndroidRuntime(29350): Caused by: android.view.InflateException: Binary XML file line #13: Binary XML file line #13: Error inflating class <unknown>
03-06 10:30:41.516 E/AndroidRuntime(29350): Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class <unknown>
03-06 10:30:41.516 E/AndroidRuntime(29350): Caused by: java.lang.reflect.InvocationTargetException
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at java.lang.reflect.Constructor.newInstance0(Native Method)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.createView(LayoutInflater.java:647)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:419)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.Activity.setContentView(Activity.java:2669)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at com.appdome.ui.LoginActivity.onCreate(LoginActivity.java:49)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.Activity.performCreate(Activity.java:7009)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.Activity.performCreate(Activity.java:7000)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.ActivityThread.-wrap11(Unknown Source:0)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.os.Handler.dispatchMessage(Handler.java:106)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.os.Looper.loop(Looper.java:164)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.app.ActivityThread.main(ActivityThread.java:6494)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at java.lang.reflect.Method.invoke(Native Method)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
03-06 10:30:41.516 E/AndroidRuntime(29350): Caused by: java.lang.StringIndexOutOfBoundsException: length=0; index=0
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at java.lang.String.charAt(Native Method)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:107)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.content.res.TypedArray.getInt(TypedArray.java:375)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.widget.TextView.<init>(TextView.java:1289)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.widget.EditText.<init>(EditText.java:88)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.widget.EditText.<init>(EditText.java:84)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	at android.widget.EditText.<init>(EditText.java:80)
03-06 10:30:41.516 E/AndroidRuntime(29350): 	... 33 more
03-06 10:30:41.519 W/ActivityManager(  791):   Force finishing activity com.ghostsq.commander/com.appdome.ui.LoginActivity

Steps to Reproduce

  1. apktool d (with apktool 2.4.0)
  2. apktool b(with apktool 2.3.4)
  3. sign, install, run the application (adb shell monkey -p com.ghostsq.commander -c android.intent.category.LAUNCHER 1)

Notes:

  1. If I use apktool 2.3.4 to perform apktool d, the application doesn't crash (no matter which apktool version is used to close the apk back again)
  2. When comparing the open directories, there is a difference in the res/values/ids.xml file, in apktool 2.3.4 some ids have false values, in apktool 2.4 these ids have empty values. When using the file from 2.3.4 the app loads.

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files (.apks that live in /system/framework or /system/priv-app)

APK

If this APK can be freely shared, please upload/attach a link to it. https://www.dropbox.com/s/bpqb8d09rnrt4ij/orig.apk?dl=0

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? yes
  2. If you are trying to install a modified apk, did you resign it? yes
  3. Are you using the latest apktool version? yes

gilhartman avatar Mar 06 '19 08:03 gilhartman

Classic Android

https://github.com/iBotPeaches/Apktool/commit/f997e0aff144d27dd5bedc62a27814f4a0b59367

AAPT2 only allows ids in the form of:

<item type=id" name="my_id/>
<item type=id" name="my_id></item>
<item type=id" name="my_id>@id/other_id</item> <!-- @id/my_id is a reference to @id/other_id -->

You probably have some other text in your inner xml element.

So looks like this is different between aapt1/aapt2, but even stranger that the host machine crashes with empty.

iBotPeaches avatar Mar 06 '19 10:03 iBotPeaches

The question is how do we proceed from here. This is a degradation on a pretty simple app (I can share the source code if needed)

gilhartman avatar Mar 06 '19 16:03 gilhartman

I think I'm going to drop aapt1 support, move forward with aapt2 and those who need aapt1 will stick with older releases.

Alternatively, I have to know "which" aapt you are going to build with during the decode step so I can take needed steps. Or I can just run some "cleanup" methods depending on the aapt version used.

iBotPeaches avatar Mar 06 '19 16:03 iBotPeaches

But reproducing the issue happens when decoding and building with 2.4.0 (aapt2),

gilhartman avatar Mar 06 '19 17:03 gilhartman

@gilhartman, I believe that iBotPeaches may mean...

The App your referring to uses AAPT1 and the Apktool v2.4.0 is trying to use AAPT2 that is resulting in it not being successful as opposed to the success with using the Apktool v2.3.4.

It looks like iBotPeaches may also be pointing out something that is making him think twice about keeping AAPT1 within the Apktool due to the consistent challenges in getting the Apktool to determine which AAPT1/AAPT2 to use for an App.

I hope that I had explained this okay @iBotPeaches... :-)

~Ibuprophen

Ibuprophen avatar Mar 06 '19 18:03 Ibuprophen

is it possible to force AAPT1 on 2.4.0?

AndnixSH avatar May 15 '19 14:05 AndnixSH

@AndnixSH You only force aapt2, it should presently default to aapt1.

iBotPeaches avatar May 15 '19 14:05 iBotPeaches

Oh ok

AndnixSH avatar May 15 '19 14:05 AndnixSH