Apktool: targetSdkVersion not updating when building.

Created on 27 Mar 2017  路  2Comments  路  Source: iBotPeaches/Apktool

Information

  1. Apktool Version (apktool -version) - 2.2.2
  2. Operating System (Mac, Linux, Windows) - Windows
  3. APK From? (Playstore, ROM, Other) - Playstore

Stacktrace/Logcat

Command line output
I: Using Apktool 2.2.2
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
I: Copying libs... (/lib)
I: Building apk file...
I: Copying unknown files/dir...

Steps to Reproduce

  1. apktool.jar d playstore.apk
  2. Open created playstore folder and update apktool.yml with new package name and updated targetSdkVersion from 23 to 22
  3. apktool.jar b
  4. Convert .apk to .zip and look at internal files
  5. Note that package name in the manifest has properly updated but the targetSdkVersion is unchanged.

All the fields but the targetSdkVersion/minSdkVersion seem to update as expected when I build after modifying the apktool.yml. Is there any known reason this might occur? I have also tried just changing the targetSdkVersion without changing anything else with no success.

Most helpful comment

Couldn't duplicate this.

Connor@iBotPeaches MINGW64 ~/Desktop/bin/testunknown
$ cat apktool.yml
!!brut.androlib.meta.MetaInfo
apkFileName: testunknown.apk
compressionType: false
doNotCompress:
- arsc
- assets/bin/Data/two.extension.file
isFrameworkApk: false
packageInfo:
  forcedPackageId: '127'
  renameManifestPackage: null
sdkInfo:
  minSdkVersion: '22'
  targetSdkVersion: '23'
sharedLibrary: false
unknownFiles: {}
usesFramework:
  ids:
  - 1
  tag: null
version: 2.2.2
versionInfo:
  versionCode: '1'
  versionName: '1.0'

Rebuilt with 22 as targetSdkVersion, using verbose mode.

Mar 31, 2017 8:40:35 AM brut.androlib.res.AndrolibResources aaptPackage
INFO: [C:\Users\Connor\AppData\Local\Temp\brut_util_Jar_5927941574323280425.tmp, p, -v, --forced-package-id, 127, --min-sdk-version, 22, --target-sdk-version, 22, --version-code, 1, --version-name, 1.0, --no-version-vectors, -F, C:\Users\Connor\AppData\Local\Temp\APKTOOL812515995527187221.tmp, -0, arsc, -0, assets/bin/Data/two.extension.file, -0, arsc, -I, C:\Users\Connor\AppData\Local\apktool\framework\1.apk, -S, C:\Users\Connor\Desktop\bin\testunknown\res, -M, C:\Users\Connor\Desktop\bin\testunknown\AndroidManifest.xml]

You can see the parameters --target-sdk-version and --min-sdk-version are passed. So I leverage aapt to view compiled binary.

Connor@iBotPeaches MINGW64 ~/Desktop/bin
$ aapt d badging testunknown/dist/testunknown.apk
package: name='com.ibotpeaches.issue1244' versionCode='1' versionName='1.0'
sdkVersion:'22'
targetSdkVersion:'22'
application-label:'Issue1244'
application-icon-160:'res/mipmap-mdpi-v4/ic_launcher.png'
application-icon-240:'res/mipmap-hdpi-v4/ic_launcher.png'
application-icon-320:'res/mipmap-xhdpi-v4/ic_launcher.png'
application-icon-480:'res/mipmap-xxhdpi-v4/ic_launcher.png'
application-icon-640:'res/mipmap-xxxhdpi-v4/ic_launcher.png'
application: label='Issue1244' icon='res/mipmap-mdpi-v4/ic_launcher.png'
application-debuggable
uses-feature:'android.hardware.touchscreen'
uses-implied-feature:'android.hardware.touchscreen','assumed you require a touch screen unless explicitly made optional'
supports-screens: 'small' 'normal' 'large' 'xlarge'
supports-any-density: 'true'
locales: '--_--'
densities: '160' '240' '320' '480' '640'

As you can see targetSdkVersion is compiled apk is now 22 instead of 23.

All 2 comments

Couldn't duplicate this.

Connor@iBotPeaches MINGW64 ~/Desktop/bin/testunknown
$ cat apktool.yml
!!brut.androlib.meta.MetaInfo
apkFileName: testunknown.apk
compressionType: false
doNotCompress:
- arsc
- assets/bin/Data/two.extension.file
isFrameworkApk: false
packageInfo:
  forcedPackageId: '127'
  renameManifestPackage: null
sdkInfo:
  minSdkVersion: '22'
  targetSdkVersion: '23'
sharedLibrary: false
unknownFiles: {}
usesFramework:
  ids:
  - 1
  tag: null
version: 2.2.2
versionInfo:
  versionCode: '1'
  versionName: '1.0'

Rebuilt with 22 as targetSdkVersion, using verbose mode.

Mar 31, 2017 8:40:35 AM brut.androlib.res.AndrolibResources aaptPackage
INFO: [C:\Users\Connor\AppData\Local\Temp\brut_util_Jar_5927941574323280425.tmp, p, -v, --forced-package-id, 127, --min-sdk-version, 22, --target-sdk-version, 22, --version-code, 1, --version-name, 1.0, --no-version-vectors, -F, C:\Users\Connor\AppData\Local\Temp\APKTOOL812515995527187221.tmp, -0, arsc, -0, assets/bin/Data/two.extension.file, -0, arsc, -I, C:\Users\Connor\AppData\Local\apktool\framework\1.apk, -S, C:\Users\Connor\Desktop\bin\testunknown\res, -M, C:\Users\Connor\Desktop\bin\testunknown\AndroidManifest.xml]

You can see the parameters --target-sdk-version and --min-sdk-version are passed. So I leverage aapt to view compiled binary.

Connor@iBotPeaches MINGW64 ~/Desktop/bin
$ aapt d badging testunknown/dist/testunknown.apk
package: name='com.ibotpeaches.issue1244' versionCode='1' versionName='1.0'
sdkVersion:'22'
targetSdkVersion:'22'
application-label:'Issue1244'
application-icon-160:'res/mipmap-mdpi-v4/ic_launcher.png'
application-icon-240:'res/mipmap-hdpi-v4/ic_launcher.png'
application-icon-320:'res/mipmap-xhdpi-v4/ic_launcher.png'
application-icon-480:'res/mipmap-xxhdpi-v4/ic_launcher.png'
application-icon-640:'res/mipmap-xxxhdpi-v4/ic_launcher.png'
application: label='Issue1244' icon='res/mipmap-mdpi-v4/ic_launcher.png'
application-debuggable
uses-feature:'android.hardware.touchscreen'
uses-implied-feature:'android.hardware.touchscreen','assumed you require a touch screen unless explicitly made optional'
supports-screens: 'small' 'normal' 'large' 'xlarge'
supports-any-density: 'true'
locales: '--_--'
densities: '160' '240' '320' '480' '640'

As you can see targetSdkVersion is compiled apk is now 22 instead of 23.

Just encountered the exactly same problem. When I modified target-sdk-version and rebuilt, the rebuild process worked fast as nothing was modified, and aapt confirmed this. I manually remove the 'build' folder inside the decompiled folder, and rebuilt it again, it worked correctly.

I just guess there is some mechanism that check whether something has changed, and decide to or not to compile it again, same as most compilers. I also guess in some condition, the checking process goes wrong and can not detect some minor changes in 'apktool.yml', and the target-sdk-version won't update.

Was this page helpful?
0 / 5 - 0 ratings