I am facing problem in creating the .apk file using the ant script . The generated .apk named as _unaligned.apk instead of .apk and on installing the _unaligned.apk file to the device I get force-close showing the java.lang.VerifyError exception, but the same apk generated using IDE works fine. I am struck on this for a long time. Can you share the build.xml file that generates the .apk file?
this Bloq entry explains all necessary steps. Especially if you want to customize your build script.
If your are looking for the actual build script, just look into your Android SDK folder platforms/android-X/templates. There should be a file called android_rules.xml.
I customized my build script to clean, build, sign and distributing the apk to an attached device. If you like, I can provide you with my script. Just contact me!
You'll need to use zipalign & sign your apk with some key; as long as you're testing the app you can simply use the debug key with ant debug
At least that's what I understand from this page which you may want to read carefully.
What ant command are you running at the command / terminal prompt?
I have been having different problems with manually running ant (Repackage apk file to contain custom assets what build tool to use) and there might be some info on that thread to help you.
Alternatively, remember that one needs to sign the apk file before deploying it (see Joubarc's link).
Related
I made my android project and run the app on my phone. I got the apk file and also app but accidentally deleted app. Can anyone Help me out please.
If your apk not obfuscated by proguard or other third party also not build by signed. Probably you can use an software like Dex2Jar. But i am not really sure about this, you can try it. There are tutorial here
Reverse engineering your app is theoretically possible but hard.
1) Use the Apktool which would help generate a little code and the resource files.
2) Use the jadx tool which helps to produce Java source code from Android Dex and Apk files.
Next is to open a new Android Studio project, copy the manifest file generated by the Apktool into the manifest of the new project, Copy the resource files generated by Apktool to the res section of your new project, Copy the java files generated by jadx and place them in the src folder of your new project.
Try to build the app but you'll definitely run into several errors. Try following the messages to fix them.
Reverse engineering your app is very tedious and you still might not be able to build the app.
Goodluck :)
Added 24th November 2019
Just found this awesome article on how to go about Reverse Engineering an Apk.
The context of my issue is the following:
I build AOSP for our hardware device on Linux
Together with the system, I build an APK as a system application
Everything works fine in this setup when I flesh it together with system image
However, I would like to have this application build separated from the AOSP build and be able to build it standalone and install from Windows.
On windows, I am trying to build it with Gradle
And the problem arises when I try to push the build to the device the following way:
adb install -r my_app.apk
adb: failed to install my_app.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package <...> signatures do not match the previously installed version; ignoring!]
Obviously the error means that I am missing a platform signature in the application, but where to take it from the AOSP build and how to sign it with Gradle build is not so clear.
Also here I found an advice to uninstall the system app first before installing. Unfortunately, for my case it does not help, the error is still the same even I uninstall it first.
I already spend quite some time on this, searching in the Android make-files for the signing script, but it seems to be not that straight forward there.
Any help would be highly appreciated...
Create a keystore from platform.x509.pem and platform.pk8 files located in build/target/product/security. Then use that with gradle.
See this answer for how to do the conversion: https://stackoverflow.com/a/22214826/3801327
Note: Don't use the default keys included with AOSP, everyone has those, and would be able to make their app a system app in your platform. Generate your own keys.
Using eclipse to generate Android app.
All of a sudden when I export a project - I get an apk file that's not valid.
e.g. missing AndroidManifest.xml and res folder.
It was working a few days ago and I didn't make any config changes.
When I test it in an emulator - the correct apk file is generated in the bin folder -
albeit without certificate signing etc.
A really hackish workaround is to go to Eclipse->Preferences->Android->Build and change the debug key to the cert you want to sign with. The downside is it's still built in debug mode. Eclipse can easily drive a good man insane trying to troubleshoot it. You might consider upgrading/reinstalling your version of Eclipse and/or reinstalling/upgrading to the latest ADT plugin.
If you don't have time to battle Eclipse, use the command line:
http://developer.android.com/tools/building/building-cmdline.html
How to compile APK from command line?
I am working on an android application in Titanium. When i do a direct build by clicking Run>Android Emulator, the size of app.apk file generated under "approot/build/android/build" is 8 MB and i could able to copy this file in my device and install.
But when i package and distribute for Android store by choosing Keystore and password, the resultant .apk file size is only 5MB and when i copy this directly to device and try to install. Its actually not getting installed.
Will the app built using distribution process will be this size? please suggest.
Output from adb when installing the app :
Click on this link to see the output bigger : http://i.stack.imgur.com/Dtzb7.png
Googling, I found this for error code 103:
https://groups.google.com/forum/?fromgroups=#!topic/rhomobile/WJJvB8NVcuU
Could it be that you are using sdk 1.7? try to switch to the java sdk 1.6.
I found the solution, below are the answer to my question
1) Yes, when app is executed for production the file size will be reduced.
2) After publishing the app to a specific folder, we should be signing the application using below
command
jarsigner -verbose -keystore /home/balan/tmp/KeyStore360/android.keystore myproject.apk androidalias
Thanks for Steelight letting me know about the adb logcat, this helped me to sort out that my apk file missing certificate.
I'm creating a software that will guide the user through a few steps, to publish an android application (APK file).
The way I am doing this, is that the APK file is already compiled, and all I need to do is replace an XML file in the package, and that will change the behaviour of the application. My big problem now, is that unpacking the apk file, and doing any tiny text edit, and then packing it again, breaks the signature and prevents the application from running on any device, giving a message that the signature is incorrect.
How can I solve this? I want to safely open the APK, write something in a text file, and close it again. Note that this operation will be done on the user's computer (after he purchases our application) so we're look for a command-line tool with no special requirements like JDK.
Any help?
Ok I reached the best "tested" solution - I'm posting it here to save other developers hours of googling. The only downside is that I will require the customer to install JDK on his machine, unfortunately. The reason is because I did not find any apk-signing tool that works purely on windows, without relying on JDK.
I have my android application created using Air, so this makes things easy for me - all of the air files are treated as resource assets. So have your APK archive file ready.
Once you have your modifications ready, put them inside a temporary folder named "assets". You will use the 7-zip command line tool (free: http://sourceforge.net/projects/sevenzip/) to update the contents of your apk. To have it working with your apk you will have to rename your apk's extension to zip - don't worry, you'll change it back later.
Now from a .bat file (or directly in the command prompt) from the location containing both your apk file (zip extensioned) and your assets folder, you'll call: 7za u APK-file.zip assets
Now your apk file is updated. Rename it back to .apk extension
Now you'll use the signAPK tool from here https://code.google.com/p/signapk/ and note that this is the only step requiring JDK installed. It also assumes that you have your key files ready (replace the dummy ones included in the package). Extract the file contents and call: java -jar signapk.jar key.x509.pem key.pk8 [android_app].apk [signed_android_app].apk
At the very end, you may find your signed apk file size drammatically increased. So you need to use the android's zipAlign tool: (darn, can't post the link since new users can only post a maximum of two hyperlinks)
you will be calling the command: zipAlign -c 4 [signed_android_app].apk
And voila! That's the route I'm taking.
If someone finds a way to do the signing process without relying on JDK (assuming the key files are ready) please share.
How can I solve this?
You don't. If you modify an APK file, by any means, it must be re-signed.
Android apk files must be signed. That signature proves that the contents of the apk have NOT BEEN MODIFIED from what was initially published. (Which is exactly what you are doing.) The signature at the same time, also proves who the author is.
So in a normal signed apk file:
You know who the author is. (Even if it's not something you as a human can understand.)
You know the contents were put there by the author, and not modified since.
This is a key security measure built into Android, is there for very good reason, and cannot be overcome. It prevents things like viruses from being embedded inside innocent apk files.