Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

Instant App - Error decode/build

Open minyungsim opened this issue 8 years ago • 1 comments

Information

  1. Apktool Version (apktool -version) - 2.2.3, 2.2.4-fce273-SNAPSHOT
  2. Operating System (Mac, Linux, Windows) - Mac
  3. APK From? (Playstore, ROM, Other) - instant app tutorial link

Stacktrace/Logcat

$ java -jar apktool-cli-all.jar d topekaui-debug.apk -o topekaui
I: Using Apktool 2.2.4-fce273-SNAPSHOT on topekaui-debug.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /Users/xxx/Library/apktool/framework/1.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x7f100131
W: Could not decode attr value, using undecoded value instead: ns=android, name=label, value=0x7f0f0020
W: Could not decode attr value, using undecoded value instead: ns=android, name=icon, value=0x7f0d0000
W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x7f10013e
W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x7f100135
W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x7f10013c
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
$ java -jar apktool-cli-all.jar b topekaui -o topekaui.apk
I: Using Apktool 2.2.4-fce273-SNAPSHOT
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
W: /Users/xxx/Documents/yyy/instant-apps-example/android-topeka/topeka-instantapp/build/outputs/apk/debug/topekaui/AndroidManifest.xml:2: error: Error: No resource type specified (at 'icon' with value '@2131558400').
W:
W: /Users/xxx/Documents/yyy/instant-apps-example/android-topeka/topeka-instantapp/build/outputs/apk/debug/topekaui/AndroidManifest.xml:2: error: Error: No resource type specified (at 'label' with value '@2131689504').
W:
W: /Users/xxx/Documents/yyy/instant-apps-example/android-topeka/topeka-instantapp/build/outputs/apk/debug/topekaui/AndroidManifest.xml:2: error: Error: No resource type specified (at 'theme' with value '@2131755313').
W:
W: /Users/xxx/Documents/yyy/instant-apps-example/android-topeka/topeka-instantapp/build/outputs/apk/debug/topekaui/AndroidManifest.xml:3: error: Error: No resource type specified (at 'theme' with value '@2131755326').
W:
W: /Users/xxx/Documents/yyy/instant-apps-example/android-topeka/topeka-instantapp/build/outputs/apk/debug/topekaui/AndroidManifest.xml:21: error: Error: No resource type specified (at 'theme' with value '@2131755317').
W:
W: /Users/xxx/Documents/yyy/instant-apps-example/android-topeka/topeka-instantapp/build/outputs/apk/debug/topekaui/AndroidManifest.xml:35: error: Error: No resource type specified (at 'theme' with value '@2131755324').
W:
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/3x/2mzylqgd02z6zrs5hdr5t1yh0000gn/T/brut_util_Jar_733533200233791872.tmp, p, --forced-package-id, -128, --min-sdk-version, 19, --target-sdk-version, 26, --version-code, 1, --version-name, 1.0, --no-version-vectors, -F, /var/folders/3x/2mzylqgd02z6zrs5hdr5t1yh0000gn/T/APKTOOL1966701960726429425.tmp, -x, -0, arsc, -0, arsc, -I, /Users/xxx/Library/apktool/framework/1.apk, -S, /Users/xxx/Documents/yyy/instant-apps-example/android-topeka/topeka-instantapp/build/outputs/apk/debug/topekaui/res, -M, /Users/xxx/Documents/yyy/instant-apps-example/android-topeka/topeka-instantapp/build/outputs/apk/debug/topekaui/AndroidManifest.xml]
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:496)
	at brut.androlib.Androlib.buildResources(Androlib.java:430)
	at brut.androlib.Androlib.build(Androlib.java:329)
	at brut.androlib.Androlib.build(Androlib.java:267)
	at brut.apktool.Main.cmdBuild(Main.java:231)
	at brut.apktool.Main.main(Main.java:84)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/3x/2mzylqgd02z6zrs5hdr5t1yh0000gn/T/brut_util_Jar_733533200233791872.tmp, p, --forced-package-id, -128, --min-sdk-version, 19, --target-sdk-version, 26, --version-code, 1, --version-name, 1.0, --no-version-vectors, -F, /var/folders/3x/2mzylqgd02z6zrs5hdr5t1yh0000gn/T/APKTOOL1966701960726429425.tmp, -x, -0, arsc, -0, arsc, -I, /Users/xxx/Library/apktool/framework/1.apk, -S, /Users/xxx/Documents/yyy/instant-apps-example/android-topeka/topeka-instantapp/build/outputs/apk/debug/topekaui/res, -M, /Users/xxx/Documents/yyy/instant-apps-example/android-topeka/topeka-instantapp/build/outputs/apk/debug/topekaui/AndroidManifest.xml]
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:441)
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:482)
	... 5 more
Caused by: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/3x/2mzylqgd02z6zrs5hdr5t1yh0000gn/T/brut_util_Jar_733533200233791872.tmp, p, --forced-package-id, -128, --min-sdk-version, 19, --target-sdk-version, 26, --version-code, 1, --version-name, 1.0, --no-version-vectors, -F, /var/folders/3x/2mzylqgd02z6zrs5hdr5t1yh0000gn/T/APKTOOL1966701960726429425.tmp, -x, -0, arsc, -0, arsc, -I, /Users/xxx/Library/apktool/framework/1.apk, -S, /Users/xxx/Documents/yyy/instant-apps-example/android-topeka/topeka-instantapp/build/outputs/apk/debug/topekaui/res, -M, /Users/xxx/Documents/yyy/instant-apps-example/android-topeka/topeka-instantapp/build/outputs/apk/debug/topekaui/AndroidManifest.xml]
	at brut.util.OS.exec(OS.java:95)
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:435)
	... 6 more

Steps to Reproduce

  1. java -jar apktool-cli-all.jar d topekaui-debug.apk -o topekaui
  2. java -jar apktool-cli-all.jar b topekaui -o topekaui.apk

APK

topeka-instantapp-debug.zip

minyungsim avatar Jul 05 '17 13:07 minyungsim

Confirmed. 6 resources that cannot be found in the "instant" app.

W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x7f100131
W: Could not decode attr value, using undecoded value instead: ns=android, name=label, value=0x7f0f0020
W: Could not decode attr value, using undecoded value instead: ns=android, name=icon, value=0x7f0d0000
W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x7f10013e
W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x7f100135
W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x7f10013c

From the AndroidManifest.xml file we can see these resources are used there

    <application android:allowBackup="false" android:debuggable="true" android:fullBackupContent="false" android:hardwareAccelerated="true" android:icon="@2131558400" android:label="@2131689504" android:supportsRtl="false" android:testOnly="true" android:theme="@2131755313">

So lets dump the resources in the instant app.

➜  Bug1550 aapt d resources topekaui-debug.apk        
Package Groups (1)
Package Group 0 id=0x80 packageCount=1 name=com.google.samples.apps.topeka
  DynamicRefTable entryCount=1:
    0x80 -> com.google.samples.apps.topeka

  Package 0 id=0x80 name=com.google.samples.apps.topeka
    type 0 configCount=1 entryCount=4
      spec resource 0x80010000 com.google.samples.apps.topeka:id/dataBinding: flags=0x00000000
      spec resource 0x80010001 com.google.samples.apps.topeka:id/onAttachStateChangeListener: flags=0x00000000
      spec resource 0x80010002 com.google.samples.apps.topeka:id/onDateChanged: flags=0x00000000
      spec resource 0x80010003 com.google.samples.apps.topeka:id/textWatcher: flags=0x00000000
      config (default):
        resource 0x80010000 com.google.samples.apps.topeka:id/dataBinding: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x80010001 com.google.samples.apps.topeka:id/onAttachStateChangeListener: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x80010002 com.google.samples.apps.topeka:id/onDateChanged: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x80010003 com.google.samples.apps.topeka:id/textWatcher: t=0x12 d=0x00000000 (s=0x0008 r=0x00)

Just 4 resources, none of which we want, so lets try the base application.

➜  Bug1550 aapt d resources topeka-base-debug.apk | grep '0x7f100131' 
      spec resource 0x7f100131 com.google.samples.apps.topeka:style/Topeka: flags=0x00000400
        resource 0x7f100131 com.google.samples.apps.topeka:style/Topeka: <bag>
        resource 0x7f100131 com.google.samples.apps.topeka:style/Topeka: <bag>

There it is. So the base application contains details on the Manifest of the instant application. So I thought I'd be creative and install the base application as a framework.

➜  Bug1550 apktool if topeka-base-debug.apk 
I: Framework installed to: /home/ibotpeaches/.local/share/apktool/framework/127.apk
➜  Bug1550 apktool d topekaui-debug.apk -f
I: Using Apktool 2.2.4-988fd1-SNAPSHOT on topekaui-debug.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/1.apk
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/127.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x7f100131
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/127.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=label, value=0x7f0f0020
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/127.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=icon, value=0x7f0d0000
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/127.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x7f10013e
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/127.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x7f100135
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/127.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x7f10013c

It did not like that. Confirmed.

iBotPeaches avatar Jul 06 '17 10:07 iBotPeaches