1

While exporting my app with proguard enabled I am getting the following error in my console:-

Error:-

Proguard returned with error code 1. See console
'java' is not recognized as an internal or external command,
operable program or batch file.

These are the respective files:-

proguard-project.txt:-

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keepattributes *Annotation*

-injars      bin/classes
-injars      libs
-outjars     bin/classes-processed.jar

-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.preference.Preference
-keep class com.rfhtaej.vskwgkw207826.** {*;}
-dontwarn com.rfhtaej.vskwgkw207826.**



-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 enum * 
  {
    public static **[] values();
    public static ** valueOf(java.lang.String);
  }



  -keep class * implements android.os.Parcelable 
   {
     public static final android.os.Parcelable$Creator *;
   }

   -keepclasseswithmembers class **.R$** 
   {
    public static <fields>;
   }

  -keepclassmembers class * 
  {
    @android.webkit.JavascriptInterface <methods>;
  }
   -keep class * extends android.view.View 
    { 

public <init>(android.content.Context); 
      public <init>(android.content.Context, android.util.AttributeSet); 
      public <init>(android.content.Context, android.util.AttributeSet, int); 
      void set*(***);
       *** get*();
    }

   -keepclassmembers class * 
    {
        static final %                *;
        static final java.lang.String *;
    }

-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

-dontwarn com.google.android.gms.**


-keepattributes SetJavaScriptEnabled
-keepattributes JavascriptInterface
-keepattributes InlinedApi

project.properties:-

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
target=android-19
android.library.reference.1=../../../../../Program Files/Android/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib

Now I think maybe its because of some PATH error, so

eclipse.ini:-

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
--launcher.defaultAction
openFile
-vm
C:\Program Files\Java\jdk1.7.0_03\jre\bin\javaw.exe
-vmargs
-Xms512m
-Xmx512m

So please guide me how to solve this error.

Mohit
  • 1,045
  • 4
  • 18
  • 45

3 Answers3

0

Instead of specifying the path to the Java executable (javaw.exe) inside your eclipse.ini file, create a JAVA_HOME variable instead, and add it to your System Variables.

To get to the System Variables location, in Windows, select Start | Control Panel | System | Advanced System Settings option | Advanced tab | Environment Variables button | System Variables section. Then, click New and add a JAVA_HOMEand specify the path to the Java executable, for example, "C:\Program Files\Java\jdk1.7.0_67\bin".

Note: You may need to restart Windows for the change to take effect.

ChuongPham
  • 4,761
  • 8
  • 43
  • 53
  • Ok but what about the eclipse.ini, please specify the changes I should make there. – Mohit Oct 26 '14 at 15:10
  • Eh, none. Have you add the JAVA_HOME variable as instructed, and are you still getting the error _"'java' is not recognized as an internal or external command..."_? – ChuongPham Oct 27 '14 at 21:20
  • Yeah I added, "C:\Program Files\Java\jdk1.7.0_03\bin" as Java_home but I am still getting the error. – Mohit Nov 21 '14 at 06:30
  • Maybe you need to move your `android-sdk` directory out of "Program Files" directory. Space in directory name often causes problem with directory reference. – ChuongPham Nov 22 '14 at 02:58
  • Yeah but all my android SDK related works are performed accurately. I think after providing the java home should I remove the javaw.exe path from eclipse.ini ?? – Mohit Nov 22 '14 at 04:38
  • @Mohit: _"should I remove the javaw.exe path from eclipse.ini"_ I have already commented on this above - you don't need to add JDK path in `eclipse.ini`. – ChuongPham Nov 22 '14 at 14:22
0

I found this solution

  1. Download the last proguard version here http://proguard.sourceforge.net/downloads.html
  2. Copy and past the folder 'bin' and 'lib' of your downloaded proguard in your "sdk\tools\proguard" in order to remplace the old ones
  3. Export your Signed Application Package
Matthew Usdin
  • 1,264
  • 1
  • 19
  • 20
0

The reason for this error message is that there is no public JRE installed on your system. According to your posted settings you are using Windows.

When you open cmd and try to execute java there is the exact same error message.

The easiest solution is to add java to your environment variables. How this works was already answered on StackOverflow: See this question for Details

Community
  • 1
  • 1
DaniEll
  • 1,022
  • 4
  • 22
  • 31