Unable to sign APK files - invalid entry compressed size?? - G1 Android Development

Hello all,
I need some help signing my APK files. I have done everything correctly up to the point of signing the file.
I am running the command:
jarsigner -verbose -keystore -my-release-key.keystore oriental.apk alias_name
Jar signer then asks for my password I set up. i put in the password and get:
jarsigner: unable to sign jar: java.util.zip.ZipException: invalid entry compressed size (expected 1110 but got 1119 bytes)
I have scoured the web for hours and tried a few things. All lowercase name ofr the apk file as suggested somewhere. i am at a loss.
Anyone know how to fix this?

Need to do this on an unsigned apk file...
I ran into this same problem for an android apk using Eclipse. I don't know if your running into the exact same problem. But, I'm guessing the principles are similar.
To fix this I had to do the jarsigner on an unsigned apk file. If you are using Eclipse, the apk is signed with a temporary key (which I think the android market won't allow).
If your using something else, you can see if your apk is already signed using syntax like:
$ jarsigner -verify -verbose my_application.apk
To get an unsigned apk in Eclipse, right click on application name in the Package Explorer window and choose Android Tools, then choose "Export Unsigned Application Package...". Save the package to a new location.
Once you have an unsigned apk. Run the jarsigner command you were using on the unsigned apk file.
This is also possibly explained better (at least for an android user using Eclipse) at:
http://developer.android.com/guide/publishing/app-signing.html
Like I said earlier if your not using Eclipse to generate an apk, possibly the tool your using has similar options to create an unsigned apk file.

Related

Ninjamorph Question

So I've been messing around with NinjaMorph, and I can't get it to work properly.
I've been trying to edit a widget (Touchdown universal widget), and edited the .png files, but it doesn't work after I repackage it whether it's zipaligned or not.
I'm sure I'm missing something here, so hopefully one of you can give me some advice.
Anyone? (10 chars)
I was having the same problem, I fixed it by using my PC to sign the apk after ninjamorph applied the changes.
If it says "application could not be installed" when you try to install an apk the signature is probably broken.
Can you recommend an application for signing apps?
-Sent from your mom's phone.
The HTC basic kitchen has an option to sign apks
sent from jdfroyo v2.0 EVO-lution
droid explorer also signs apps.. and ninjamorph is amazing btw.
Asterdroid said:
Can you recommend an application for signing apps?
-Sent from your mom's phone.
Click to expand...
Click to collapse
I believe NinjaMorph will not work with apps downloaded form the Market, atleast thats what Stericson sais in his description.
What I have been doing is self signing and making sure to uninstall the app before re-installing the modified version. here is what i do after i modify the apk.
[highlight]note: your going to need all the sdk tools and necessary binaries.[/highlight]
1. Delete the META-INF folder
2. Jump into the working folder (the one containing res/ etc.) and zip it up
Code:
$ zip -r my_application.zip *
3. change zip to apk
Code:
$ mv my_application.zip my_application.apk
4. self-sign
Code:
$ jarsigner -verbose -keystore my-release-key.keystore my_application.apk alias_name
5. zipallign
Code:
$ zipalign -v 4 my_application.apk my_application-aligned.apk
also, to generate keys if you dont have them yet, issue this command.
Code:
$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

Sign Your APK for the PLAY Store

Hey Guys,
I found it very hard to find this method on the net. I looked for around 12 hours (over a period of 2 days). But here it is!
This method is very helpful if you need to increase the length of your signature on your apk. As Google Play has a minimum length of validity for signatures.
This tutorial contains some knowledge from other websites and some from my own self. Please feel free to use my hard work below. But try to reference me if you can. Thanks!
First of all,
jarsigner and keytool are .exe files that help create your "signed" application for release to the market to prevent fraud.
1.
Make a folder somewhere called "keytools" and make a folder in that called "key"
2. Now move your apk file to the folder keytools.
(Not inside any other folders)
3. Check
"C:\Program Files\Java\jdk1.7.0_11\bin" for jarsigner and keytools..
... or whatever jdk version you have
If you DONT have it install the following: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
4. open cmd.exe,
5. cd your way to where you have your keytools folder...
I had to do.. cd desktop, and to keytools to get to C:\Users\Matt\Desktop\keytools\
In this directory is you apk file which we will manipulate.
Now add the directory C:\"Program Files"\Java\jdk1.7.0_11\bin\ or something like that to PATH in Environment Variables.
Directions on how to do this can be found here: http://www.computerhope.com/issues/ch000549.htm
type the following now (or something similar to my example)
keytool -genkey -alias xda.keystore -keyalg RSA -validity 20000 -keystore keys/xda.keystore
Then you will have be presented with:
Enter keystore password: (type in a password you will use)
Re-enter new password: (type in same password here)
What is your first and last name? Matt <LAST NAME HERE>
What is the name of your Organization unit? (You dont NEED to type anything)
What is the name of your city or locality? <What it says>
What is the name of your state or providence? <What it says>
what is the two-letter country code for this unit? AU
is CN=Matt C=AU.....etc. correct?
[no]: yes (type yes there)
Enter key password for <xda.keystore>
<RETURN if same as keystore password>: (push enter)
6.
To add the directory of jarsigner to the PATH variable just do the steps from here: http://www.computerhope.com/issues/ch000549.htm but with the path of jarsigner. Which should be something like this: echo "PATH=/cygdrive/c/Program\ Files/Java/jdk1.7.0.11/bin:\${PATH}" >> .bash_profile
Now, type the following now (or something similar to my example) NOTE: This is all in cmd.
jarsigner -verbose -keystore key/donate.keystore -signedjar Donate_signed.apk xda.apk xda.keystore
Enter Passphase for keystore: (your password you made earlier)
DO NOT TYPE --> adding: META-INF/MINFEST.MF ....
.......
.....
...Signing: classes.dex <--DO NOT TYPE
and you're all set! you signed your apk file or whatever you wanted to create!
Congratulations.
NOW STOP BEING FRUSTRATED LIKE I WAS FOR HOURS!
Come on guys! Post what you think AKA I just bumped this thread.
I did this but the file gets signed , but when trying to install on device the signed file, it says its not signed .
LOL
Thanks but I can not do this

[Q] cannot run MyFirstApp on windows 7 with adb and AVD

It seems it is not an easy thing to start android development. I followed the official instruction and tried to run the MyFirstApp example from developer.android.com on my Windows 7 64bit machine with AVD. But after 2 days effort, I am still cannot make it work for me in Eclipse and in adb command line.
The best I reached in command line approach is the following -- the second block with italic words shows the error I got:
Code:
E:\Workspace\MyFirstApp>ls bin
AndroidManifest.xml build.prop
AndroidManifest.xml.d classes
MyFirstApp-debug-unaligned.apk classes.dex
MyFirstApp-debug-unaligned.apk.d classes.dex.d
MyFirstApp-debug.apk dexedLibs
MyFirstApp.ap_ proguard.txt
MyFirstApp.ap_.d res
[I][B]E:\Workspace\MyFirstApp>adb install bin\MyFirstApp-debug.apk
failed to copy 'bin\MyFirstApp-debug.apk' to '/data/local/tmp/MyFirstApp-debug.a
pk': No such file or directory
rm failed for /data/local/tmp/MyFirstApp-debug.apk, No such file or directory[/B][/I]
I hope somebody can help me about these:
1. I am in Windows with AVD, why adb want to find /data/local/tmp, which is linux style location?
2. where does the adb try to copy the apk file to? My SDK is installed under "C:\Users\myname\AppData\Local\Android\android-sdk". There is no space in the address path. The source apk file is ready and should not be the cause of that error, I think.
3. Any configuration of the installed SDK needs to be modified in Windows machine? I think the SDK manager should be able to figure out what the machine is and download/install appropriate components for the user. Is that right?
I have similar or the same issue by using Eclipse.
thanks,

Auto APK/ZIP Signer in Windows

Hi XDA.
I have created automatic version of this One Click Signer:
(Click to thanx here FIRST! ->) http://forum.xda-developers.com/showthread.php?t=822388 (<- Click to thanx here FIRST!)
This version Works for Quantum of files at same time.
There are two DIRs:
Input - move here all APK and ZIP files to sign.
Output - here comes Signed APKs and ZIPs.
How to use?
1. Download auto-sign.zip from this thread.
2. Unzip it.
3. Run once autosign.bat.
4. Now, Input and Output folders was created.
5. Move all your Unsigned APK and ZIP files into Input folder.
6. Run autosign.bat again.
7. Wait until CMD windows closes.
8. Now you have Signed Your APKs and ZIPs in Output folder.
Click to expand...
Click to collapse
If you think, that is virus, or any harmful file,
you can right click on any .bat or .cmd file, and use EDIT option.
Here you can see all code, that files do.
Thanx to ASimmons, and dont forget to hit "Thanks!" button on his thread too! (link above)
Sorry for my BAD English.
//ANY PROBLEMS?
1. Output DIR is empty.
- move your auto-sign folder to root of C: drive, maybe run it as administrator.
2. Files are in output folder, but not signed
- check if you have Java Runtime SE Library, try to reinstall it.
if you have 64 bit system, and 64 bit Java, try to install 32 bit java too.
Thanks, gouster3.
Very easy to use Signer. However, using it to create an 'update.zip' package for my tablet was unsuccessful due to the 'zipalign' step at the end. So I reversed the steps as follows in "do2.cmd", then it was accepted (although this way the ZIP isn't fully aligned) :
Code:
setlocal EnableDelayedExpansion
@ECHO off
SET rom=%1
copy !rom! x!rom!
cd lib
rem zip align
zipalign -f 4 ..\x!rom! ..\signed-!rom!
rem sign the rom
java -Xmx512m -jar signapk.jar -w testkey.x509.pem testkey.pk8 ..\signed-!rom! ..\signed-!rom!
cd ..\
del x!rom!
Joe.

How do I sign an APK with the system key using SingApk.jar?

I need to sign an APK using the system keys obtained from Google's source (As an example) using SignApk.jar. However, everytime we try to Sign we get the error below...
This is the command we are using (Please note we are using the Source code downloaded from Google for Android 8.1 for the Pixel).
Besides this method, is there another way to sign an APK with the system key?
java -Xmx2048m -Djava.library.path="out/host/linux-x86/lib64" -jar prebuilts/sdk/tools/lib/signapk.jar -w build/make/target/product/security/platform.x509.pem build/make/target/product/security/platform.pk8 Unsigned-Apk.apk Signed_final_apk.apk
Error: Exception in thread "main" java.lang.ExceptionInInitializerError
at org.conscrypt.OpenSSLBIOInputStream.<init>(OpenSSLBIOInputStream.java:34)
at org.conscrypt.OpenSSLX509Certificate.fromX509PemInputStream(OpenSSLX509Certificate.java:119)
at org.conscrypt.OpenSSLX509CertificateFactory$1.fromX509PemInputStream(OpenSSLX509CertificateFactory.java:220)
at org.conscrypt.OpenSSLX509CertificateFactory$1.fromX509PemInputStream(OpenSSLX509CertificateFactory.java:216)
at org.conscrypt.OpenSSLX509CertificateFactory$Parser.generateItem(OpenSSLX509CertificateFactory.java:94)
at org.conscrypt.OpenSSLX509CertificateFactory.engineGenerateCertificate(OpenSSLX509CertificateFactory.java:272)
at java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:339)
at com.android.signapk.SignApk.readPublicKey(SignApk.java:184)
at com.android.signapk.SignApk.main(SignApk.java:1007)
Caused by: java.lang.IllegalArgumentException: Failed to load any of the given libraries: [conscrypt_openjdk_jni-osx-x86_64, conscrypt_openjdk_jni]
at org.conscrypt.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:160)
at org.conscrypt.NativeCryptoJni.init(NativeCryptoJni.java:49)
at org.conscrypt.NativeCrypto.<clinit>(NativeCrypto.java:53)
... 9 more

Categories

Resources