Apktool error on mac - android

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

Related

Bundletool build-bundle error: Protocol message end-group tag did not match expected tag

I am trying to turn an apk into aab, decompile with apktool, and build with aapt2 and bundletool (all in command line, without gradle).
After decompile, aapt2 compile and link looks good, but when I execute build-bundle with bundletool, I got this error. What went wrong? And How ow can i fix it?
F:\>java -jar "F:\tool\common\bundletool.jar" build-bundle --modules="F:\_workspace\20210714\decompile\base.zip" --output="F:\_workspace\20210714\decompile\base.aab"
[BT:1.7.0] Error: com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.
java.io.UncheckedIOException: com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.
at com.android.tools.build.bundletool.model.BundleModule$Builder.addEntry(BundleModule.java:357)
at com.android.tools.build.bundletool.model.BundleModule$Builder.addEntries(BundleModule.java:339)
at com.android.tools.build.bundletool.validation.BundleModulesValidator.toBundleModule(BundleModulesValidator.java:94)
at com.android.tools.build.bundletool.validation.BundleModulesValidator.lambda$validate$0(BundleModulesValidator.java:79)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Collections$2.tryAdvance(Collections.java:4719)
at java.util.Collections$2.forEachRemaining(Collections.java:4727)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
at com.android.tools.build.bundletool.validation.BundleModulesValidator.validate(BundleModulesValidator.java:80)
at com.android.tools.build.bundletool.commands.BuildBundleCommand.execute(BuildBundleCommand.java:231)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:73)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:49)
Caused by: com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.
at com.google.protobuf.InvalidProtocolBufferException.invalidEndTag(InvalidProtocolBufferException.java:106)
at com.google.protobuf.CodedInputStream$StreamDecoder.checkLastTagWas(CodedInputStream.java:2076)
at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:217)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:232)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:237)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:48)
at com.google.protobuf.GeneratedMessageV3.parseWithIOException(GeneratedMessageV3.java:347)
at com.android.aapt.Resources$XmlNode.parseFrom(Resources.java:44493)
at com.android.tools.build.bundletool.model.BundleModule$SpecialModuleEntry$1.addToModule(BundleModule.java:386)
at com.android.tools.build.bundletool.model.BundleModule$Builder.addEntry(BundleModule.java:355)
... 15 more
Seems like it's talking about the protobuf format (not sure if I'm right), but I do add "--proto-format" in my command.
Details of what I did:
compile the resources using aapt2:
"F:\tool\common\aapt2.exe" compile --dir "F:\_workspace\20210714\decompile\res" -v -o "F:\_workspace\20210714\decompile\compiled_resources.zip"
then link:
"F:\tool\common\aapt2.exe" link --proto-format "F:\_workspace\20210714\decompile\compiled_resources.zip" -v -o "F:\_workspace\20210714\decompile\base.apk" -I "F:\tool\common\android.jar" --manifest "F:\_workspace\20210714\decompile\AndroidManifest.xml"
unzip the base.apk, move other files into position (I did it according to bundletool's documentation), than zip again, name base.zip.
then do build-bundle, which has been mentioned in the beginning, and got that error:
"F:\tool\common\bundletool.jar" build-bundle --modules="F:\_workspace\20210714\decompile\base.zip" --output="F:\_workspace\20210714\decompile\base.aab"
The code and resources are decompiled from an apk which works well, dependencies should be good, and recompiling these into apk again can be done successfully. By the way, I use smali.jar to convert smali files into dex for bundletool.
The version of tools I am using:
aapt2.exe 7.0.0-beta05-7396180
bundletool.jar 1.7.0
apktool.jar 2.5.0
smali.jar 2.4.0
So the other day i fix this by myself. It is because i put the wrong manifeat file in place. The file in "base.zip/manifest/AndroidManifest.xml" should be proto-format, which is produce by aapt2 in link process, you can find it inside the apk generate by aapt2.
And yes, decompile an apk and use bundletool to turn it into an aab is possible.

Error at installing my app on mobile for testing

my package name is com.example.project name but to upload it on google console for publishing it.I change it to com.ahsan.project name, now when i am trying to run it on my mobile it is showing me this error....
already have tried to revert back to old changes but it is not working.still getting the same result.
Run Window
Unknown failure: Exception occurred while executing:
java.lang.IllegalArgumentException: Unknown package: com.example.ethlon
at com.android.server.pm.Settings.getInstallerPackageNameLPr(Settings.java:5051)
at com.android.server.pm.PackageManagerService.getInstallerPackageName(PackageManagerService.java:27786)
at com.android.server.pm.PackageManagerService.isOrphaned(PackageManagerService.java:27792)
at com.android.server.pm.PackageManagerService.deletePackageVersioned(PackageManagerService.java:23919)
at com.android.server.pm.PackageInstallerService.uninstall(PackageInstallerService.java:993)
at com.android.server.pm.PackageManagerShellCommand.runUninstall(PackageManagerShellCommand.java:912)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:134)
at android.os.ShellCommand.exec(ShellCommand.java:96)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:28572)
at android.os.Binder.shellCommand(Binder.java:581)
at android.os.Binder.onTransact(Binder.java:481)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:3209)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:5078)
at android.os.Binder.execTransact(Binder.java:682)
Error while Installing APKs
this error happen because
your package name not the same in all project
search and update your package to be the same
Most of the time this error came due to Changes in file location in Project folder.
To solve this problem you just have to open whole project again as a new Project.
Steps-
File-Export To Zip File (save as new zip file).
Unzip the zip file.
Go to Open and select the location of unzip file.
Now try to run app on device.

Error with Uploading APK to Google Play

Upload failed:
Your APK cannot be analyzed using 'aapt dump badging'. Error output:
to run aapt dump badging:
W/ResourceType(12713): Bad XML block: header size 28024 or total size 1702240364 is larger than data size 3783
ERROR: AndroidManifest.xml is corrupt
This is the error I am getting when I attempt to upload an APK onto Google Play and am completely unsure of what to do. I have looked at other posts but am unable to fix my problem. Any help is appreciated!!
-- Moksh
Is your apk run on emulator or device..?
Clean and build your project again. Sign it with your very own keystore and then try to upload it.
Make sure following points are need to be taken care of while uploading file on android market
"android:versionCode" attribute from AndroidManifest.xml is proper.
"android:versionName" attribute from AndroidManifest.xml is proper.
The package name is very unique,. Because all the apps on android market are separated by the package.

decompile framework-res.apk multiple resources exception

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.

error when unzip apk file in ant

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.

Categories

Resources