Apr 122013
 

Sometimes a JAR file can be corrupted. I had this issue when working with smali and baksmali on Android. The fix I use for this is simply deleting META-INF and repacking it:

mkdir tmp
cd tmp/
jar xf ../myfile.jar
rm -rf META-INFO
jar cf ../unsigned_myfile.jar *
cd ..
rm -rf tmp/

Then to sign the file, I use

jarsigner -sigalg MD5withRSA -digestalg SHA1 -keystore debugstore unsigned_myfile.apk androiddebugkey

Verify:

jarsigner -verify -certs unsigned_myfile.jar

If you do not have a keystore with debugkey, you can create one using:

keytool -genkeypair -alias androiddebugkey -dname “CN=Android Debug,O=Android,C=US” -keystore debugstore -keyalg RSA -validity 10000

I found this like, where someone does nearly the same, but also aligning the apkĀ http://codeseekah.com/tag/baksmali/