Log in or register to post comments

Proguard problems -Release version Android Market

October 13, 2011 - 2:00am #10

Hi,

I am trying to build a simple project for release in the Android Market.

I enable proguard in my default.properties file

When I do this and run the apk on the device my app crashes. When i see the LogCat output I see the following error

FATAL EXCEPTION: main

java.lang.ExceptionInInitializerError

10-13 11:45:04.695: ERROR/AndroidRuntime(5656): FATAL EXCEPTION: main
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): java.lang.ExceptionInInitializerError
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at java.lang.Class.newInstanceImpl(Native Method)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at java.lang.Class.newInstance(Class.java:1409)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at android.os.Handler.dispatchMessage(Handler.java:99)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at android.os.Looper.loop(Looper.java:123)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at android.app.ActivityThread.main(ActivityThread.java:3687)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at java.lang.reflect.Method.invokeNative(Native Method)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at java.lang.reflect.Method.invoke(Method.java:507)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at dalvik.system.NativeStart.main(Native Method)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): Caused by: java.lang.NoClassDefFoundError: com.qualcomm.QCAR.BitmapSurface

10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at java.lang.Runtime.nativeLoad(Native Method)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at java.lang.Runtime.loadLibrary(Runtime.java:432)
10-13 11:45:04.695: ERROR/AndroidRuntime(5656): at java.lang.System.loadLibrary(System.java:554)
10-13 11:58:16.921: ERROR/DataRouter(81): __initialize_usb_ipc before accept
....

How should I configure the proguard.cfg in order to avoid this error???

I tried several options in proguard according to Proguard manual but with no luck...

Thanks in advance,

Andreas

Re: Proguard problems -Release version Android Market

October 14, 2011 - 6:32am #9

It's possible that the level of obfuscation is too high, you may want to try reducing that. Have you tried using the Google default Proguard config?

- Kim

Re: Proguard problems -Release version Android Market

October 14, 2011 - 6:45am #8

what do you mean? I am using the Google default one.. The default one messes app with QCAR..how can I avoid it..please be more specific..

Thank you for your reply,

Andreas

ps. This is my last effort


-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-libraryjars ./theqcar/

-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

-keep class com.qualcomm.QCAR.*{

}

-keepclasseswithmembernames class * {
native ;
}

-keepclasseswithmembers class * {
public (android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
public (android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

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

Re: Proguard problems -Release version Android Market

October 14, 2011 - 8:34am #7

To be honest we don't have much Proguard experience, it isn't something we officially support. It looks like it's stripping out some of our Java classes. Try searching the web a bit, here's something that might help:

http://stackoverflow.com/questions/4830474/how-to-keep-exclude-a-particular-package-path-when-using-proguard

- Kim

Re: Proguard problems -Release version Android Market

October 14, 2011 - 10:18am #6

I had seen this and I had tried several other things..

I think it is something you should consider. Almost every app published in the Android Market using proguard before exporting a signed apk.

QCAR seems to have a conflict with that and even with certain "keeps" in proguard configuration it cannot prevent problems while exporting.

I even tried to unzip the QCAR.jar and use all the .class files it contains. The project works ok but when activating proguard and adjusting configuration it is still immpossible to export a working apk...

I hope you could help as solve this issue, it seems to be critical..

Thanks in advance,

Andreas

Does anybody solved that

January 7, 2013 - 2:33pm #5

Does anybody solved that problem? I have similar problems with Vuforia 2.0.

Hi machowy, the issue is that

January 8, 2013 - 8:26am #4

Hi machowy,

the issue is that the default settings of proguard can strip the QCAR classes away;

to fix that, you can follow this process:

 1- add this line to your "project.properties":

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

2- add a file named "proguard-project.txt" to your project root folder

3- put this line into the "proguard-project.txt":

       -keep class com.qualcomm.** { *; }

 

This should avoid that the Vuforia classes get stripped away by proguard.

 

 

 

 

working fine, thanks.

January 8, 2013 - 10:16pm #3

working fine, thanks.

You're welcome.

January 8, 2013 - 11:09pm #2

You're welcome.

Proguard problems -Release version Android Market

July 19, 2013 - 11:05am #1

Hello Al,

I followed your steps and configured ProGuard for my video player project. I was able to export the APK succesfully. But, the app is crashing when invoked from the real device. I think ProGurad is avoiding/wrapping up the native methods. How can I fix the issue?

Please see the log below.

---

07-19 23:29:12.905: E/AndroidRuntime(6029): FATAL EXCEPTION: main
07-19 23:29:12.905: E/AndroidRuntime(6029): java.lang.NoSuchMethodError: no method with name='getTextureCount' signature='()I' in class Lcom/nautilus/labs/VideoPlayer/VideoPlayer;
07-19 23:29:12.905: E/AndroidRuntime(6029): at com.nautilus.labs.VideoPlayer.VideoPlayer.initApplicationNative(Native Method)
07-19 23:29:12.905: E/AndroidRuntime(6029): at com.nautilus.labs.VideoPlayer.VideoPlayer.i(Unknown Source)
07-19 23:29:12.905: E/AndroidRuntime(6029): at com.nautilus.labs.VideoPlayer.VideoPlayer.a(Unknown Source)
07-19 23:29:12.905: E/AndroidRuntime(6029): at com.nautilus.labs.VideoPlayer.VideoPlayer.a(Unknown Source)
07-19 23:29:12.905: E/AndroidRuntime(6029): at com.nautilus.labs.VideoPlayer.VideoPlayer.a(Unknown Source)
07-19 23:29:12.905: E/AndroidRuntime(6029): at com.nautilus.labs.VideoPlayer.o.a(Unknown Source)
07-19 23:29:12.905: E/AndroidRuntime(6029): at com.nautilus.labs.VideoPlayer.o.onPostExecute(Unknown Source)
07-19 23:29:12.905: E/AndroidRuntime(6029): at android.os.AsyncTask.finish(AsyncTask.java:631)
07-19 23:29:12.905: E/AndroidRuntime(6029): at android.os.AsyncTask.access$600(AsyncTask.java:177)
07-19 23:29:12.905: E/AndroidRuntime(6029): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
07-19 23:29:12.905: E/AndroidRuntime(6029): at android.os.Handler.dispatchMessage(Handler.java:99)
07-19 23:29:12.905: E/AndroidRuntime(6029): at android.os.Looper.loop(Looper.java:137)
07-19 23:29:12.905: E/AndroidRuntime(6029): at android.app.ActivityThread.main(ActivityThread.java:4895)
07-19 23:29:12.905: E/AndroidRuntime(6029): at java.lang.reflect.Method.invokeNative(Native Method)
07-19 23:29:12.905: E/AndroidRuntime(6029): at java.lang.reflect.Method.invoke(Method.java:511)
07-19 23:29:12.905: E/AndroidRuntime(6029): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
07-19 23:29:12.905: E/AndroidRuntime(6029): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
07-19 23:29:12.905: E/AndroidRuntime(6029): at dalvik.system.NativeStart.main(Native Method)
07-19 23:29:12.967: E/android.os.Debug(361): !@Dumpstate > dumpstate -k -t -z -d -o /data/log/dumpstate_app_error
 
---
 
Thanks,
Binu Paul
Log in or register to post comments