I'm trying to decompile some apk using apktools, but on the first step when I'm doing:
apktool if framework-res.apk
I'm getting the following log:
Exception in thread "main" brut.androlib.AndrolibException: Multiple resources:
spec=0x01080293 drawable/ic_ab_back_holo_dark, config=-xhdpi
at brut.androlib.res.data.ResConfig.addResource(ResConfig.java:65)
at brut.androlib.res.data.ResConfig.addResource(ResConfig.java:58)
at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:196)
at brut.androlib.res.decoder.ARSCDecoder.readConfig(ARSCDecoder.java:165
)
at brut.androlib.res.decoder.ARSCDecoder.readType(ARSCDecoder.java:130)
at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:10
5)
at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:82)
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:48)
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:39)
at brut.androlib.res.AndrolibResources.installFramework(AndrolibResource
s.java:384)
at brut.androlib.Androlib.installFramework(Androlib.java:365)
at brut.apktool.Main.cmdInstallFramework(Main.java:193)
at brut.apktool.Main.main(Main.java:69)
My guess is that this apk contains lib that possess resource with the same name as the main apk's project. The question is whether I can fight and get it to work or leave it.
PS - I still can decompile the .class file using JV-GUI but I need the xmls.
Thanks
Your version of Apktools is too low. you need download apktools 1.52.
Related
I just compiled a customized Minecraft server (PC-server running in console) into a .zip file, named test.zip, containing classes.dex and classes2.dex, with sdk-dx tool.
I want to run the application with the "dalvikvm" shell command, but it keeps throwing java.lang.NoClassDefFoundError: test.server.Start
The path of the .zip file is /sdcard/Test/test.zip, and the original main class is test.server.Start in classes.dex. (I don't think it's modified since I tried dex2jar and the class names remain the same.)
These are the commands I've tried. Non of them works.
dalvikvm -cp /sdcard/Test/test.zip test.server.Start
dalvikvm -cp /sdcard/Test/test.zip/classes.dex;/sdcard/Test/test.zip/classes2.dex test.server.Start
dalvikvm -cp "/sdcard/Test/test.zip/classes.dex /sdcard/Test/test.zip/classes2.dex" test.server.Start
Does anyone know what's wrong here?
Setting aside bigger questions, the Dalvik classpath is a colon-separated list of filenames (e.g. /sdcard/foo1.jar:/sdcard/foo2.jar). Each jar/apk contains a single classes.dex. For an APK you'd work around this with multidex, but for command-line invocation you just need to put each classes.dex into its own jarfile.
When I try to run the apktool to decompile my apk it gives off an error:
Exception in thread "main" brut.androlib.AndrolibException: brut.directory.DirectoryException: java.util.zip.ZipException: error in opening zip file
at brut.androlib.ApkDecoder.hasSources(ApkDecoder.java:199)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:83)
at brut.apktool.Main.cmdDecode(Main.java:146)
at brut.apktool.Main.main(Main.java:77)
Caused by: brut.directory.DirectoryException: java.util.zip.ZipException: error in opening zip file
at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:55)
at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:38)
at brut.androlib.res.util.ExtFile.getDirectory(ExtFile.java:55)
at brut.androlib.ApkDecoder.hasSources(ApkDecoder.java:197)
... 3 more
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:128)
at java.util.zip.ZipFile.<init>(ZipFile.java:145)
at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:53)
... 6 more
I followed this guide. http://www.adventuresofanentrepreneur.net/creating-a-mobile-appsgames-company/how-to-unpack-pack-an-apk-file
Am I missing some files it needs to operate?
I checked all the other solution but now I found i was using jdk1.6 which was preinstalled on my machine. Maybe a java update might solve this problem. The apktool documentation explicitly mentions that it needs minimum of jdk 1.7. More info here:https://code.google.com/p/android-apktool/
try unzip your apk file first
apk is a zipfile the message said it cannot unzip the apk first
so try your self to unzip the apk file to find whether it is a real apk
This error means Apktool cannot open the Zipfile to read the files it wants (classes.dex in this case). Try using a regular Zip program (Like 7zip or Winrar) and try and unzip the apk. If this works, then apktool is at fault and you should report a bug. However, I believe it will fail, in which case you need to figure out why that is. It could be any of the following reasons:
Apk utilizes the "general access bit" hack, which no longer runs on Android, thus apktool removed support for it.
Apk has a password on it.
Apk was improperly downloaded, thus not complete
I use ant to unzip an apk file, but it occurred an error like this:
<unzip src="test.apk" dest="testdir" >
error message:
java.lang.RuntimeException: data starting at 0 is in unknown format
i googled it, and add attribute encoding="native-encoding" , it still error.
great thanks for any help!
ok,finally I wrote a custom ant task using java ziputil to unzip an apk files. It does work well.
Can someone share with me the steps executed by the Android OS on an newly downloaded APK for its bundled AndroidManifest file?
Actually I keen to know that what does Android OS do after downloading and before confirming installation successful. how it reads the AndroidManifest and whats the sequence of that...?
Install time parsing
PackageManager is a system component that runs on Android devices (in system_server) and plays a key role in the installation process, and the one that concerns itself with parsing the AndroidManifest.xml file of the package being installed.
Precisely the parsing is happening in PackageParser.java.
UPDATE:
While on Android R PackageParser.java still remains in place and contains the code for parsing, that code is effectively "deprecated" in favour of ParsingPackageUtils.java
Build time parsing
There is also another parsing of the AndroidManifest.xml that happens when Android package file (.apk) is being built. When the aapt2 (Android Asset Packaging Tool) links compiled resource files it also takes, parses and validates the AndroidManifest.xml file. This happens in ManifestFixer.cpp. It also parses the AndroidManifest.xml extracted from an .apk file when aapt2 dump badging or aapt2 dump permissions are executed - DumpManifest.cpp
Actually you could find more directly in android source code:
$ find sdk/sdkmanager/* -name "*Manifest*.java"
sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/xml/AndroidManifest.java
sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/xml/ManifestData.java
sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/xml/AndroidManifestParser.java
sdk/sdkmanager/libs/sdklib/tests/com/android/sdklib/xml/AndroidManifestParserTest.java
ManifestData.java is quite important, and acts a fundamental role, recommend you to read further.
Appendix: this directory has four java source codes:
$ ls sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/xml/
AndroidManifest.java AndroidXPathFactory.java
AndroidManifestParser.java ManifestData.java
First: I'm not help vampire) I'm fighting with this issue for two days and I'm desperate to find solution. I've googled for the solution all over the inet and none is my case - this is the final stage and it feels hopeless.
To be clear: messing with AndroidManifest.xml doesn't help (no empty or unclosed tags etc). Nor app size issue (official limit is 4GB). Nor browser\system cause tried in FF, Chrome, IE 9 , Win 7, MacOSX SL 10.6.4, from my PC and from remote Server with Win2008 - same error.
Second - I extracted the AndroidManifest.xml from the APK file I submitted successfully (one with 13MB size) and extracted AndroidManifest.xml from the APK I'm trying to submit (yes, it's there! the size of this APK is 50MB) both with same apktool v 1.4.1. I compared the AndroidManifest.xml files with tortoise Diff - and the only difference between them is presence of android:targetSdkVersion="8" attribute in unuploadable APK and of course package name (diff only in .sub of com.mycompany.app.vers.sub - so i guess not a reason for this googlemare I'm having on ).
No way to give up on android:targetSdkVersion="8" - cause it can't be a reason for the error too.
Both APK were created with File -> Export -> Android -> Export Android Application with same keystore and key. I uploaded another app - third one with same AndroidManifest.xml as first one (without android:targetSdkVersion="8") but also of small size - 9MB, nothing bigger works((!
Help - I hate google and android now, almost :)
If you ran into the same problem I did with apktool, then please make sure you download the .jar file along with aapt.exe, that fixed it for me. I was running aapt.exe on an apk and got your above error, but it turns out I should have been running the apktool.bat file. The apktool.bat won't work if the .jar is not in the same directory. Get the jar file here: Android-APKTool
The maximum size of an Android app to be uploaded to Android Market is 50MB. If you're even one byte over this, I believe that the upload will fail. See this blog post for reference.