MuntashirAkon / AppManager

A full-featured package manager and viewer for Android
https://muntashirakon.github.io/AppManager/
Other
4.72k stars 265 forks source link

Crashing when opening app from main page #951

Closed assembleDebug closed 1 year ago

assembleDebug commented 1 year ago

Please check before submitting an issue

Describe the bug

I have installed this shady chinies app NP MANAGER (just bcz it connects to internet), provides functionalities which you see in MT Manager. This app seems highly obfuscated. I can not open the NP manager app info in the AM Debug version. It crashes the AM Debug. I am attaching logs below.

To Reproduce

  1. Open app manager
  2. Tap on NP manager in app list.
  3. It crashes.

Expected behavior

Should open details page for NP manager.

Screenshots

No response

Logs

java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean io.github.muntashirakon.AppManager.apk.ApkFile.isSplit()' on a null object reference
    at io.github.muntashirakon.AppManager.details.info.AppInfoViewModel.lambda$loadTagCloud$0(AppInfoViewModel.java:216)
    at io.github.muntashirakon.AppManager.details.info.AppInfoViewModel$$ExternalSyntheticLambda0.run(Unknown Source:2)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7893)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean io.github.muntashirakon.AppManager.apk.ApkFile.isSplit()' on a null object reference
   at io.github.muntashirakon.AppManager.details.AppDetailsViewModel.getSplitCount(AppDetailsViewModel.java:978)
   at io.github.muntashirakon.AppManager.details.info.AppInfoViewModel.loadTagCloud(AppInfoViewModel.java:133)
   at io.github.muntashirakon.AppManager.details.info.AppInfoFragment.loadPackageInfo(AppInfoFragment.java:1551)
   at io.github.muntashirakon.AppManager.details.info.AppInfoFragment.$r8$lambda$oxlKbqiAsxIkEG69gntC-jrgnXk(Unknown Source:0)
   at io.github.muntashirakon.AppManager.details.info.AppInfoFragment$$ExternalSyntheticLambda56.run(Unknown Source:2)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:463)
   at java.util.concurrent.FutureTask.run(FutureTask.java:264)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
   at java.lang.Thread.run(Thread.java:1012)

Device Info:
App version: 3.1.0-alpha02-DEBUG
App version code: 415
Android build version: 1669133913
Android release version: 13
Android SDK version: 33
Android build ID: TD1A.221105.001
Device brand: Redmi
Device manufacturer: Xiaomi
Device name: sweet
Device model: Redmi Note 10 Pro
Device product name: aosp_sweet
Device hardware name: qcom
ABIs: [arm64-v8a, armeabi-v7a, armeabi]
ABIs (32bit): [armeabi-v7a, armeabi]
ABIs (64bit): [arm64-v8a]
System language: en-US
In-App Language: auto
Mode: auto
Inferred Mode: root

Device info

Everything given in logs above.

Additional context

No response

MuntashirAkon commented 1 year ago

This is the magic of the AndroidManifest.xml of NP Manager (in hexadecimal):

00 00 08 00

Since Android Binary XML uses little endian, it could be written as follows:

00 00 00 08

The first part is the version i.e. 0x0000 and the second part is the header i.e. 0x0008. Version 0x0000 appears to be invalid according to my checks (App Manager expects 0x0003). Other XML files, as it appears, are perfectly fine.

Related issue: https://github.com/LSPosed/LSPatch/issues/135

assembleDebug commented 1 year ago

So this is something which cannot be fixed on our side, right?

MuntashirAkon commented 1 year ago

So this is something which cannot be fixed on our side, right?

I'm not sure yet. Since Android package parser is able to parse this file, there might be a way. Interestingly, the other parser provided by the AOSP is not working as you can see in the error above.

MuntashirAkon commented 1 year ago

Even Android's own buildtools' aapt has failed to parse the manifest:

N: android=http://schemas.android.com/apk/res/android
  E: manifest (line=2)
    A: android:versionCode(0x0101021b)=(type 0x10)0x1348d13
    A: (0x0101021c)="3.0.62" (Raw: "3.0.62")
    A: (0x01010572)=(type 0x10)0x1c
    A: (0x01010573)="9" (Raw: "9")
    A: package="player.normal.np" (Raw: "player.normal.np")
    A: platformBuildVersionCode=(type 0x10)0x1c
    A: platformBuildVersionName=(type 0x10)0x9
zsh: segmentation fault  /Users/muntashir/Library/Android/sdk/build-tools/33.0.1/aapt d xmltree
(exit code: 139)
MuntashirAkon commented 1 year ago

Ah, aap2 can parse it. So, whatever this format is, it is new.

MuntashirAkon commented 1 year ago

All existing Java implementations will fail to parse this file. A possible alternative is to create a new implementation from aapt2: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/libs/androidfw/include/androidfw/ResourceTypes.h

MuntashirAkon commented 1 year ago

Depends on https://github.com/REAndroid/ARSCLib/issues/9

MuntashirAkon commented 1 year ago

Fixed in bbcc8024b015c4722defbbac9971f8c2c2d4f14e

Note: If APK signing is enabled, the installation will still fail due to an issue with the apksig library, which will be fixed later in the corresponding library.