1

I am kind of stuck from past 1 week from this issue. I am trying to export my android app for final release but it gives following errror while exporting.

Proguard returned with error code 1. See console
[2014-08-26 19:55:11 - ] Note: there were 1281 duplicate class definitions.
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced method 'android.app.RemoteInput[] getRemoteInputs()' in class android.app.Notification$Action
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced method 'android.os.Bundle getExtras()' in class android.app.Notification$Action
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced class android.app.Notification$Action$Builder
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced class android.app.Notification$Action$Builder
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced class android.app.Notification$Action$Builder
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced class android.app.Notification$Action$Builder
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced class android.app.Notification$Action$Builder
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced method 'java.lang.String getGroup()' in class android.app.Notification
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced method 'java.lang.String getSortKey()' in class android.app.Notification

I am using below entries in my proguard-project.txt file.

-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault

-keepclassmembers class * {
@com.google.api.client.util.Key <fields>;
}
-keep class android.support.v4.** { *; }
-dontwarn **CompatHoneycomb
-dontwarn javax.jdo.**
-dontwarn com.google.api.client.extensions.android.**
-dontwarn com.google.api.client.googleapis.extensions.android.gms.**

# Needed by google-api-client-android when linking against an older platform version

-dontwarn com.google.api.client.googleapis.extensions.android.**

-injars lib/android-support-v4.jar
-injars lib/gcm.jar
-injars lib/google-api-client-1.18.0-rc.jar
-injars lib/google-api-client-android-1.18.0-rc.jar
-injars lib/google-http-client-1.18.0-rc.jar
-injars lib/google-http-client-android-1.18.0-rc.jar
-injars lib/google-http-client-gson-1.18.0-rc.jar
-injars lib/google-http-client-jackson2-1.18.0-rc.jar
-injars lib/google-http-client-jdo-1.18.0-rc.jar
-injars lib/google-oauth-client-1.18.0-rc.jar
-injars lib/gson-2.1.jar
-injars lib/jackson-core-2.1.3.jar
-injars lib/jsr305-1.3.9.jar

# Needed by google-play-services when linking against an older platform version

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

I am able to export my .apk file successfully from eclipse if I am using below content in my proguard-project.txt file. BUT when I am installing and running that app in device , it is crashing.

-keep class android.support.v4.** { *; }   
-dontwarn android.support.v4.**
-dontwarn javax.activation.**
-dontwarn javax.security.**
-dontwarn java.awt.**
-libraryjars <java.home>/lib/rt.jar
-keep class javax.** {*;}
-keep class com.sun.** {*;}
-keep class myjava.** {*;}
-keep class org.apache.harmony.** {*;}
-keep public class Mail {*;}        
-dontshrink
-dontwarn org.mockito.**
-dontwarn sun.reflect.**
-dontwarn android.test.**
-keep class javax.ws.rs.** { *; }
-dontwarn com.fasterxml.jackson.**
-dontwarn org.xmlpull.v1.**
-dontwarn javax.jdo.**
-dontwarn com.google.api.client.googleapis.extensions.android.gms.**

Please help me How to fix this. can't I directly export .apk file without using proguard configuration?. Thanks. please let me know if i have to provide more information.

user3687223
  • 175
  • 4
  • 13
  • I dont know why this question voted down. I know its related to proguard error which has been asked many times BUT the error which i got is not mentioned and answered anywhere. – user3687223 Aug 26 '14 at 15:05
  • It feels like you have some library that requires a newer version of the `support-v4` JAR than you presently are using. – CommonsWare Aug 26 '14 at 15:06
  • But my app executes fine in device when i run directly from eclipse. – user3687223 Aug 26 '14 at 15:15
  • Then perhaps you might consider examining LogCat and determining why you are crashing, in the cases where you are crashing. – CommonsWare Aug 26 '14 at 15:27
  • How to get crash report?. As I am installing .apk file manually in device. when I am running from eclipse directly its not crashing. Thanks – user3687223 Aug 26 '14 at 15:42
  • "How to get crash report?" -- http://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this – CommonsWare Aug 26 '14 at 15:49
  • This link is all about if some one executing app directly from eclipse to real device. This way i know how to get and see logs in logcat. BUT in my case I am exporting .apk file and installing it in device manually. There is no connection between eclipse and device. Then in that case if app crashes how to get log? – user3687223 Aug 26 '14 at 16:03
  • "This link is all about if some one executing app directly from eclipse to real device" -- no, it is all about examining LogCat, regardless of how you run the app. "There is no connection between eclipse and device" -- then buy a micro USB cable (or whatever your device requires) and connect the device to your development machine. The LogCat view in Eclipse has nothing to do with having run the app from Eclipse. It simply shows the contents of LogCat. You are also welcome to use **`adb logcat`**, again with the device plugged into your development machine. – CommonsWare Aug 26 '14 at 16:15
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/60023/discussion-between-user3687223-and-commonsware). – user3687223 Aug 26 '14 at 16:16

2 Answers2

3

perhaps some support v4 class or interface was confounded, i tried this and it works

-dontwarn android.support.v4.**     
-keep class android.support.v4.** { *; }   
-keep interface android.support.v4.app.** { *; }   
-keep public class * extends android.support.v4.**   
-keep public class * extends android.app.Fragment 
Danny Liao
  • 63
  • 1
  • 6
0

I resolved the error successfully in this way.

My project.properties file content

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt:proguard-google-api-client.txt

# Project target.
target=android-19
android.library.reference.1=../appcompat_v7

My proguard-project.txt content

-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}

# added to prevent runtime errors (kazsato)
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}

-dontwarn javax.jdo.**

My proguard-google-api-client.txt

-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault

-keepclassmembers class * {
@com.google.api.client.util.Key <fields>;
}

# Needed by google-http-client-android when linking against an older platform version

-dontwarn com.google.api.client.extensions.android.**
-dontwarn com.google.api.client.googleapis.extensions.android.gms.**

# Needed by google-api-client-android when linking against an older platform version

-dontwarn com.google.api.client.googleapis.extensions.android.**

# Needed by google-play-services when linking against an older platform version

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

I will glad if this info help some one.I

user3687223
  • 175
  • 4
  • 13