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

NullPointerException in ResXmlPatcher #1264

Closed
dlubarov opened this Issue Jun 7, 2016 · 6 comments

Comments

Projects
None yet
3 participants
@dlubarov

dlubarov commented Jun 7, 2016

Information

  1. Apktool Version - 2.1.1
  2. Operating System - Mac
  3. APK From? - compiled myself

Stacktrace

Exception in thread "main" java.lang.NullPointerException
    at brut.androlib.res.xml.ResXmlPatcher.pullValueFromStrings(ResXmlPatcher.java:128)
    at brut.androlib.ApkDecoder.putVersionInfo(ApkDecoder.java:360)
    at brut.androlib.ApkDecoder.writeMetaFile(ApkDecoder.java:299)
    at brut.androlib.ApkDecoder.decode(ApkDecoder.java:162)
    at brut.apktool.Main.cmdDecode(Main.java:163)
    at brut.apktool.Main.main(Main.java:81)

APK

It's one of our (Square's) apps. I can't share the apk unfortunately, but I'm hoping the problem will be clear from the stacktrace.

Other

It works with 2.1.0, but not 2.1.1. I haven't dug into the code very much, but it seems likely related to 7c1ce8b; versionName must be null. After decoding with 2.1.0, the apktool.yml file contains

versionInfo:
  versionCode: null
  versionName: null

@dlubarov dlubarov changed the title from NullPointerException to NullPointerException in ResXmlPatcher Jun 7, 2016

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Jun 7, 2016

Owner
aapt d xmltree apk_filename.apk AndroidManifest.xml

Could you run that and provide output? (Email ibotpeaches - at - gmail.com) if the Manifest is private. If you can't provide the whole output of that command, I just need the two lines that say android:versionCode and android:versionName

This will help me figure out what the problem is, as the last bug with this stacktrace was fixed here - 3e56693

Owner

iBotPeaches commented Jun 7, 2016

aapt d xmltree apk_filename.apk AndroidManifest.xml

Could you run that and provide output? (Email ibotpeaches - at - gmail.com) if the Manifest is private. If you can't provide the whole output of that command, I just need the two lines that say android:versionCode and android:versionName

This will help me figure out what the problem is, as the last bug with this stacktrace was fixed here - 3e56693

@dlubarov

This comment has been minimized.

Show comment
Hide comment
@dlubarov

dlubarov Jun 7, 2016

Hm, I'm getting ERROR: dump failed because resource [...]/AndroidManifest.xml found when running the aapt command.

I neglected to mention an important detail: this is an androidTest apk, so the generated manifest doesn't have android:versionName or android:versionCode.

It seems to happen with any androidTest apk, so here are the repro steps with my Mixologist app:

  1. ./gradlew clean assembleDebugAndroidTest
  2. java -jar apktool_2.1.1.jar decode --force app/build/outputs/apk/app-debug-androidTest-unaligned.apk (must be the 2.1.1 jar; 2.1.0 works without an error)

dlubarov commented Jun 7, 2016

Hm, I'm getting ERROR: dump failed because resource [...]/AndroidManifest.xml found when running the aapt command.

I neglected to mention an important detail: this is an androidTest apk, so the generated manifest doesn't have android:versionName or android:versionCode.

It seems to happen with any androidTest apk, so here are the repro steps with my Mixologist app:

  1. ./gradlew clean assembleDebugAndroidTest
  2. java -jar apktool_2.1.1.jar decode --force app/build/outputs/apk/app-debug-androidTest-unaligned.apk (must be the 2.1.1 jar; 2.1.0 works without an error)
@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Jun 7, 2016

Owner

Make sure you are adapting the command to run against the APK.

cd directory_to_where_apk_is_at;
aapt d xmltree NAME_OF_APK.apk AndroidManifest.xml

Basically CD to directory of apk, then run the aapt command adapting it to the name of apk you are running against. I think I know what the problem is after you mentioned the detail of missing both versionName and versionCode, but just getting all possible information for when I sit down and write a patch.

Owner

iBotPeaches commented Jun 7, 2016

Make sure you are adapting the command to run against the APK.

cd directory_to_where_apk_is_at;
aapt d xmltree NAME_OF_APK.apk AndroidManifest.xml

Basically CD to directory of apk, then run the aapt command adapting it to the name of apk you are running against. I think I know what the problem is after you mentioned the detail of missing both versionName and versionCode, but just getting all possible information for when I sit down and write a patch.

@dlubarov

This comment has been minimized.

Show comment
Hide comment
@dlubarov

dlubarov Jun 7, 2016

Oh I see, here's the output:

[~/Development/Mixologist/app/build/outputs/apk] (master) aapt dump xmltree app-debug-androidTest-unaligned.apk AndroidManifest.xml
N: android=http://schemas.android.com/apk/res/android
  E: manifest (line=2)
    A: package="com.lubarov.daniel.mixologist.test" (Raw: "com.lubarov.daniel.mixologist.test")
    A: platformBuildVersionCode=(type 0x10)0x17 (Raw: "23")
    A: platformBuildVersionName="6.0-2704002" (Raw: "6.0-2704002")
    E: uses-sdk (line=5)
      A: android:minSdkVersion(0x0101020c)=(type 0x10)0xa
      A: android:targetSdkVersion(0x01010270)=(type 0x10)0x17
    E: application (line=7)
      A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
      E: uses-library (line=8)
        A: android:name(0x01010003)="android.test.runner" (Raw: "android.test.runner")
    E: instrumentation (line=11)
      A: android:label(0x01010001)="Tests for com.lubarov.daniel.mixologist" (Raw: "Tests for com.lubarov.daniel.mixologist")
      A: android:name(0x01010003)="android.support.test.runner.AndroidJunitRunner" (Raw: "android.support.test.runner.AndroidJunitRunner")
      A: android:targetPackage(0x01010021)="com.lubarov.daniel.mixologist" (Raw: "com.lubarov.daniel.mixologist")
      A: android:handleProfiling(0x01010022)=(type 0x12)0x0
      A: android:functionalTest(0x01010023)=(type 0x12)0x0

dlubarov commented Jun 7, 2016

Oh I see, here's the output:

[~/Development/Mixologist/app/build/outputs/apk] (master) aapt dump xmltree app-debug-androidTest-unaligned.apk AndroidManifest.xml
N: android=http://schemas.android.com/apk/res/android
  E: manifest (line=2)
    A: package="com.lubarov.daniel.mixologist.test" (Raw: "com.lubarov.daniel.mixologist.test")
    A: platformBuildVersionCode=(type 0x10)0x17 (Raw: "23")
    A: platformBuildVersionName="6.0-2704002" (Raw: "6.0-2704002")
    E: uses-sdk (line=5)
      A: android:minSdkVersion(0x0101020c)=(type 0x10)0xa
      A: android:targetSdkVersion(0x01010270)=(type 0x10)0x17
    E: application (line=7)
      A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
      E: uses-library (line=8)
        A: android:name(0x01010003)="android.test.runner" (Raw: "android.test.runner")
    E: instrumentation (line=11)
      A: android:label(0x01010001)="Tests for com.lubarov.daniel.mixologist" (Raw: "Tests for com.lubarov.daniel.mixologist")
      A: android:name(0x01010003)="android.support.test.runner.AndroidJunitRunner" (Raw: "android.support.test.runner.AndroidJunitRunner")
      A: android:targetPackage(0x01010021)="com.lubarov.daniel.mixologist" (Raw: "com.lubarov.daniel.mixologist")
      A: android:handleProfiling(0x01010022)=(type 0x12)0x0
      A: android:functionalTest(0x01010023)=(type 0x12)0x0

@iBotPeaches iBotPeaches added this to the 2.1.2 milestone Jun 8, 2016

iBotPeaches added a commit that referenced this issue Jun 8, 2016

@dlubarov

This comment has been minimized.

Show comment
Hide comment
@dlubarov

dlubarov commented Jun 8, 2016

Thanks!

@sunalong

This comment has been minimized.

Show comment
Hide comment
@sunalong

sunalong Jul 29, 2016

Encounter the same problem.
Thank you!

sunalong commented Jul 29, 2016

Encounter the same problem.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment