简体   繁体   English

生成签名apk时出错

[英]Error while generating signed apk

I got old project and keystore file , but when I am trying to create signed APK it give following error. 我有旧的项目和密钥库文件,但是当我尝试创建签名的APK时,它会给出以下错误。

   [2013-05-19 12:36:02 - xxxxxxx] Proguard returned with error code 1. See console
   [2013-05-19 12:36:02 - xxxxxxx] Unable to access jarfile /Users/muhammadali/Documents/development
   [2013-05-19 12:36:12 - xxxxxx] Proguard returned with error code 1. See console
    [2013-05-19 12:36:12 - xxxxxx] Unable to access jarfile /Users/muhammadali/Documents/development

Please help why i cant generate the APK file. 请帮助我为什么不能生成APK文件。

Alright, a few things: 好吧,一些事情:

  1. Make sure your Proguard is version 4.8 and above. 确保您的Proguard4.8及更高版本。 There is a known bug that caused that in 4.7. 有一个已知的错误导致4.7.

  2. Assuming you are running the latest version of Proguard and it is still occuring, go to [android-sdk-folder]/sdk/tools/proguard/bin/proguard.sh and make the following changes: 假设您正在运行最新版本的Proguard并且它仍然存在,请转到[android-sdk-folder]/sdk/tools/proguard/bin/proguard.sh并进行以下更改:

    Change: 更改:

     java -jar $PROGUARD_HOME/lib/proguard.jar "$@" 

    To: 至:

     java -jar "$PROGUARD_HOME/lib/proguard.jar" "$@" 
  3. Add this line to your project.properties file in your application folder. 将此行添加到应用程序文件夹中的project.properties文件中。

     proguard.config=proguard.cfg 
  4. Create a proguard.cfg file in your application folder. 在应用程序文件夹中创建proguard.cfg文件。

  5. Populate your proguard.cfg file with something like below (modify as needed). 使用下面的内容填充您的proguard.cfg文件(根据需要进行修改)。

     -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify -verbose -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class * extends android.app.backup.BackupAgentHelper -keep public class * extends android.preference.Preference -keep public class com.android.vending.licensing.ILicensingService -keepclasseswithmembernames class * { native <methods>; } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet); } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet, int); } -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); public void onSearchButtonClicked(java.lang.String); } -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; } 
  6. Turn Project -> Build Automatically off Go to menu Project -> Clean... and clean your project first. 转动Project -> Build Automatically关闭转到菜单Project -> Clean...并首先清理项目。

Good luck! 祝好运! I'll be happy to help out as you try all the steps above and go through it. 当您尝试上述所有步骤并完成它时,我将很乐意为您提供帮助。

I think it is a best practice if you are using it with command shell. 我认为如果你在命令shell中使用它是最好的做法。

Please refer the below link which has all the necessary steps for you to follow either in eclipse or via command shell. 请参阅以下链接,其中包含您在eclipse或命令shell中执行所有必要步骤。

http://developer.android.com/tools/publishing/app-signing.html http://developer.android.com/tools/publishing/app-signing.html

First you need to unsign you apk. 首先你需要取消你的apk。

Then create private key 然后创建私钥

$ keytool -genkey -v -keystore my-release-key.keystore-alias alias_name -keyalg RSA -keysize 2048 -validity 10000

Then sign you unsigned apk with private key 然后用私钥签署你的unsigned apk

$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-releasekey.keystore my_application.apk alias_name

Finally using zip align, align you apk 最后使用zip对齐,对齐你apk

$ zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk

These steps are well explained in above documentation. 上述文档中详细说明了这些步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM