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

[BUG] Decode and build apk but crashed when launch it #3710

Open
wangnianwu opened this issue Oct 8, 2024 · 5 comments
Open

[BUG] Decode and build apk but crashed when launch it #3710

wangnianwu opened this issue Oct 8, 2024 · 5 comments

Comments

@wangnianwu
Copy link

Information

  1. Apktool Version (apktool -version) - latest
  2. Operating System (Mac, Linux, Windows) - Mac
  3. APK From? (Playstore, ROM, Other) - Other
  4. Java Version (java --version) - java 11.0.16

Stacktrace/Logcat

20241008-174553

Steps to Reproduce

  1. apktool d and apktool b
  2. install it by command line ('adb install')
  3. launch it and crashed

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.
app-debug.apk.zip
please remove the suffix '.zip' from this file name, it's a demo apk.

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, install it successfuly, but crashed when launch
  3. Are you using the latest apktool version?
    yes, clone the latest source code and build it.
@wangnianwu wangnianwu changed the title [BUG] [BUG] Decode and build apk but crashed when launch it Oct 8, 2024
@iBotPeaches
Copy link
Owner

Well thats odd. If you use it with -s (without sources) does it work? It would suggest smali/baksmali is corrupting the file.

@wangnianwu
Copy link
Author

yes, if I use it with -s and it work.

@wangnianwu
Copy link
Author

wangnianwu commented Oct 21, 2024

Well thats odd. If you use it with -s (without sources) does it work? It would suggest smali/baksmali is corrupting the file.

@iBotPeaches has any new discoveries

@wangnianwu
Copy link
Author

@iBotPeaches I have found that cause, here:

// In case we have no resources. We should store the minSdk we pulled from the source opcode api level
if (!mApkInfo.hasResources() && mMinSdkVersion > 0) {
    mApkInfo.setSdkInfoField("minSdkVersion", Integer.toString(mMinSdkVersion));
}

Add a condition likes:

// In case we have no resources. We should store the minSdk we pulled from the source opcode api level
if (!(mApkInfo.hasResources() && mConfig.forceDecodeManifest == Config.FORCE_DECODE_MANIFEST_FULL)
        && mMinSdkVersion > 0) {
    mApkInfo.setSdkInfoField("minSdkVersion", Integer.toString(mMinSdkVersion));
}

If not decode manifest, we can not get minSdkVersion. So build the dex with incorrect minSdkVersion(dex version).

@iBotPeaches
Copy link
Owner

@wangnianwu - You are welcome to open a PR with some reasoning. Its tough to follow samples in issues as it might not reflect the present state / context of code around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants