Apktool: compileSdkVersion value changed in AndroidManifest.xml file

Created on 5 Mar 2019  ยท  11Comments  ยท  Source: iBotPeaches/Apktool

Information issue #1852 #1909

After decompiling and recompiling with apktool, the contents of the AndroidManifest.xml file are changed as follows.

  1. 2.3.3 version works as normal.
  2. Apktool Version (apktool -version) - 2.3.4 & 2.4.0
  3. Operating System (Mac, Linux, Windows) -Windows10
  4. APK From? (Playstore, ROM, Other) - Other

Steps to Reproduce

  1. original : AndroidManifest.xml -> android:compileSdkVersion="28"
  2. delete framework(1.apk)
  3. 'd' option ->
  4. 'b' option ->
  5. Check the AndroidManifest.xml file.
    AndroidManifest.xml -> android:compileSdkVersion="23"
    compileSdkVersion changed

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.
sample_compilesdkversion.zip

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? N/A
  3. Are you using the latest apktool version? Yes. 2.3.4 & 2.4.0 version
Bug

Most helpful comment

Same problem here, compileSdk changed from "9" to "6.0-2438415" with apkTool 2.3.4 or 2.4.0.
But no problem with apkTool 2.3.3 (compileSdk not modified) so regression seems be in 2.3.4 version.

All 11 comments

I have same issue. Also after compile the app and open it is crashing.

Not sure how we regressed here. I have a test that ensures compileSdkVersion does not change. This must be aapt1 related

I'm using the latest aapt.exe from build-tools v28.0.3. I can confirm that the compileSDK is changed to 23. Is there any tag to force the version?

Same problem here, compileSdk changed from "9" to "6.0-2438415" with apkTool 2.3.4 or 2.4.0.
But no problem with apkTool 2.3.3 (compileSdk not modified) so regression seems be in 2.3.4 version.

Facing same issue.

Same exact issue, android:compileSdkVersion got changed from 28 to 23 and android:compileSdkVersionCodename from 9 to 6.0-2438415.
Using 2.4 on Windows and Java 64 bits. Commands were simply _apktool d_ and _apktool b_.

I have the same problem and it doesn't work properly after compiling the app

Reasons and solutions ๏ผŸ

I have found that the version used ("6.0-2438415") is taken from the version of the framwork apk (1.apk).

โžœ  /tmp unzip  /opt/apktool_2.4.1.jar brut/androlib/android-framework.jar 

Archive:  /opt/apktool_2.4.1.jar
  inflating: brut/androlib/android-framework.jar  

โžœ  /tmp ~/Android/Sdk/tools/bin/apkanalyzer manifest print brut/androlib/android-framework.jar | grep -i version

<?xml version="1.0" encoding="utf-8"?>
    android:versionCode="23"
    android:versionName="6.0-2438415"
        android:minSdkVersion="23"
        android:targetSdkVersion="23" />

I don't know why all last version of apkTool have a framework with this version but if I use another framwork (take from an emulator device). It will use the version of this framework.

And I don't know if it is better to take the version of the framwork or keep the version of original apk.

I just want to raise awareness of this issue because i am facing the same and it causes my App to immediately crash after rebuilding it. Is there any proposal on how it could be fixed?

Old

โžœ  debug git:(master) โœ— aapt d xmltree app-debug.apk AndroidManifest.xml | grep 'compileSdkVersion'
    A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1d
    A: android:compileSdkVersionCodename(0x01010573)="10" (Raw: "10")
โžœ  debug git:(master) โœ— 

Rebuilt

โžœ  dist git:(master) โœ— aapt d xmltree app-debug.apk AndroidManifest.xml | grep 'compileSdkVersion'
    A: android:compileSdkVersion(0x01010572)=(type 0x10)0x17
    A: android:compileSdkVersionCodename(0x01010573)="6.0-2438415" (Raw: "6.0-2438415")
โžœ  dist git:(master) โœ— 

Indeed changed (aapt1).

Let me try aapt2.

โžœ  app-debug git:(master) โœ— apktool b . --use-aapt2
I: Using Apktool 2.4.2-f545c2-SNAPSHOT
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk...
โžœ  app-debug git:(master) โœ— cd dist 
โžœ  dist git:(master) โœ— aapt d xmltree app-debug.apk AndroidManifest.xml | grep 'compileSdkVersion'
    A: android:compileSdkVersion(0x01010572)=(type 0x10)0x17
    A: android:compileSdkVersionCodename(0x01010573)="6.0-2438415" (Raw: "6.0-2438415")
โžœ  dist git:(master) โœ— 

Nope, still busted. Marking as bug.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ibuprophen picture Ibuprophen  ยท  3Comments

raulsiles picture raulsiles  ยท  4Comments

trandua picture trandua  ยท  3Comments

LeeDroid- picture LeeDroid-  ยท  3Comments

xiao-xing-yun picture xiao-xing-yun  ยท  3Comments