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.
Related
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.
I'm getting the following error while building Android ROM, either it is AOSP/CyanogenMod
In file included from hardware/ril-caf/libril/RilSapSocket.cpp:21:0:
hardware/ril-caf/libril/RilSapSocket.h:22:55: fatal error: hardware/ril/librilutils/proto/sap-api.pb.h: No such file or directory
#include <hardware/ril/librilutils/proto/sap-api.pb.h>
^
compilation terminated.
When I look into the path in github.com/CyanogenMod and github.com/Android I couldn't find sap-api.pb.h
What could be the problem and how can I resolve it?
I got the same error message, and I tried to find the generated file with find command:
$ find . -name "sap-api.pb.h"
./out/target/product/bacon/gen/STATIC_LIBRARIES/librilutils_static_intermediates/proto/hardware/ril-caf/librilutils/proto/sap-api.pb.h
./out/target/product/bacon/gen/SHARED_LIBRARIES/librilutils_intermediates/proto/hardware/ril-caf/librilutils/proto/sap-api.pb.h
then I notice the #include path is a bit different from the real path, I open the error .h file and change hardware/ril/... to hardware/ril-caf/... in these two files:
hardware/ril-caf/libril/rilSocketQueue.h
hardware/ril-caf/libril/RilSapSocket.h
Then, the build passed.
Hope this help.
I am getting the following error while trying to run
devkit debug native-android
ERROR
BUILD FAILED
/home/bonnie/adt/sdk/tools/ant/build.xml:597: The following error occurred while executing this line:
/home/bonnie/GameEngines/MyGameClosure/modules/devkit-core/modules/native-android/TeaLeaf/build.xml:7: Source resource does not exist: /home/bonnie/GameEngines/MyGameClosure/modules/devkit-core/modules/native-android/TeaLeaf/local.properties
looking closely I found the local.properties fille is missing.
How can i fix this? what is the reason for it?
copy the local.properties file from build/debug/native-android/local.properties to modules/devkit-core/modules/native-android/TeaLeaf/
cp build/debug/native-android/local.properties modules/devkit-core/modules/native-android/TeaLeaf/
-OR-
change line no. 7 of
modules/devkit-core/modules/native-android/TeaLeaf/buid.xml
to
<loadproperties srcFile="../../../../../build/debug/native-android/local.properties" />
`
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 have Jenkins-CI compiling an Android app I'm working on. Compiles it great but it will not upload the release apk via SCP. I have set the source to bin/* and it gives me the following error. Does anyone have a suggestion on what I have configured wrong? I've had it working in the past, but I forgot to get the config before I re-installed Fedora on the machine.
[SCP] Connecting to smccloud.com
ERROR: Failed to upload files
2: No such file
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2289)
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:1741)
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:1758)
at com.jcraft.jsch.ChannelSftp.stat(ChannelSftp.java:1715)
at be.certipost.hudson.plugin.SCPSite.upload(SCPSite.java:188)
at be.certipost.hudson.plugin.SCPRepositoryPublisher.perform(SCPRepositoryPublisher.java:218)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:682)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:657)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:635)
at hudson.model.Build$RunnerImpl.post2(Build.java:161)
at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:604)
at hudson.model.Run.run(Run.java:1400)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:175)
Build step 'Publish artifacts to SCP Repository' changed build result to UNSTABLE
I encountered this error when I was trying to copy to a directory that didn't exist on the target machine. Create the directory(s) on the target first and this should go away and the copy work.
On the target machine you are seeing something like:
No such file or directory
when you try to navigate to the non-existent directory.
If the plugin isn't working for you can use the shell script with expect, as a post build step, to do it for you.