3

I got old project and keystore file , but when I am trying to create signed APK it give following error.

   [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.

Ali
  • 10,774
  • 10
  • 56
  • 83

2 Answers2

1

Alright, a few things:

  1. Make sure your Proguard is version 4.8 and above. There is a known bug that caused that in 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:

    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.

    proguard.config=proguard.cfg
    
  4. Create a proguard.cfg file in your application folder.

  5. Populate your proguard.cfg file with something like below (modify as needed).

    -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.

Good luck! I'll be happy to help out as you try all the steps above and go through it.

kushyar
  • 1,191
  • 1
  • 6
  • 10
0

I think it is a best practice if you are using it with command shell.

Please refer the below link which has all the necessary steps for you to follow either in eclipse or via command shell.

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

First you need to unsign you 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

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

Finally using zip align, align you apk

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

These steps are well explained in above documentation.

M P Mathugama
  • 1,418
  • 1
  • 20
  • 31