Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

compileSdkVersion value changed in AndroidManifest.xml file

Open numbinum opened this issue 5 years ago • 15 comments

Information issue #1852 #1909

After decompiling and recompiling with apktool, the contents of the AndroidManifest.xml file are changed as follows. 0. 2.3.3 version works as normal.

  1. Apktool Version (apktool -version) - 2.3.4 & 2.4.0
  2. Operating System (Mac, Linux, Windows) -Windows10
  3. 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

numbinum avatar Mar 05 '19 08:03 numbinum

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

susameca avatar Mar 05 '19 16:03 susameca

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

iBotPeaches avatar Mar 05 '19 16:03 iBotPeaches

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?

susameca avatar Mar 05 '19 17:03 susameca

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.

PiR43 avatar Jul 31 '19 10:07 PiR43

Facing same issue.

prabhu-bsft avatar Aug 27 '19 07:08 prabhu-bsft

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.

yankarinRG avatar Oct 04 '19 12:10 yankarinRG

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

tahsin1373 avatar Nov 11 '19 20:11 tahsin1373

Reasons and solutions ?

m30102 avatar Dec 23 '19 02:12 m30102

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.

PiR43 avatar Jan 10 '20 09:01 PiR43

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?

Pecadis avatar Oct 30 '20 15:10 Pecadis

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.

iBotPeaches avatar Nov 29 '20 14:11 iBotPeaches

Is there any update on this issue?

susameca avatar Jun 06 '21 18:06 susameca

Is there any update on this issue?

Not that I see. Still open and waiting to be worked on.

iBotPeaches avatar Jun 06 '21 18:06 iBotPeaches

It seem this issue happened on Mac

khaintt avatar Aug 25 '21 09:08 khaintt

I took a look at this and debating closing as no-fix. Apktool by nature is using different build tools to rebuild the application. Forging aapt/aapt2 to lie about the build tool version, even though it may be built with different/newer tools just seems wrong.

Removing "bug", adding "feature".

iBotPeaches avatar Aug 28 '21 20:08 iBotPeaches

This issue seems still exist in 2.6.1

arkilis avatar Oct 26 '22 23:10 arkilis