REAndroid / ARSCLib

Android binary resources read/write library
Apache License 2.0
230 stars 49 forks source link

Repacked APK crash on runtime #49

Closed entwildfire closed 1 year ago

entwildfire commented 1 year ago

Hi, thank you for your great library and your good support. I am using ARSCLib v1.2.0 to add an XML file, edit resources.arsc, edit manifest of multiple APKs. there is no problem in all APKs except one of them, when I repack this specific APK, even without any edit, just decompile and build, the app crash on runtime as follows:

 E  FATAL EXCEPTION: main
    Process: a.a.myapplication, PID: 2683
    java.lang.RuntimeException: Unable to instantiate application android.support.multidex.MultiDexApplication package a.a.myapplication: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/~~jiNlAldBI9zriYWq2RGs0w==/a.a.myapplication-t3lmIin-UCSOuRv7-T9tfQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~jiNlAldBI9zriYWq2RGs0w==/a.a.myapplication-t3lmIin-UCSOuRv7-T9tfQ==/lib/arm64, /system/lib64, /system/system_ext/lib64]]
        at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1573)
        at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1502)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7553)
        at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2400)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8757)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/~~jiNlAldBI9zriYWq2RGs0w==/a.a.myapplication-t3lmIin-UCSOuRv7-T9tfQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~jiNlAldBI9zriYWq2RGs0w==/a.a.myapplication-t3lmIin-UCSOuRv7-T9tfQ==/lib/arm64, /system/lib64, /system/system_ext/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
        at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52)
        at android.app.Instrumentation.newApplication(Instrumentation.java:1232)
        at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1565)
        at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1502) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7553) 
        at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2400) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loopOnce(Looper.java:226) 
        at android.os.Looper.loop(Looper.java:313) 
        at android.app.ActivityThread.main(ActivityThread.java:8757) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)  

There is no difference in dex files, and the class "android.support.multidex.MultiDexApplication" not exists in the original APK too, the resources.arsc binary files have some small differences, but I don't find any difference when opening them in android studio. The class "android.support.multidex.MultiDexApplication" is in the manifest application tag:

<application
        android:theme="@ref/0x7f1101d2"
        android:label="@ref/0x7f10001c"
        android:icon="@ref/0x7f0d0000"
        android:name="android.support.multidex.MultiDexApplication"
        android:debuggable="true"
        android:allowBackup="true"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:fullBackupContent="@ref/0x7f130000"
        android:usesCleartextTraffic="true"
        android:roundIcon="@ref/0x7f0d0001"
        android:appComponentFactory="androidx.core.app.CoreComponentFactory"
        android:dataExtractionRules="@ref/0x7f130001"
        android:requestLegacyExternalStorage="true">
REAndroid commented 1 year ago

How can I reproduce this issue ?