I'm not using new relic in my app and it still shows class not found error.
Only solution that worked for me is to include new relic. I'm using eclipse.
App works in debug, now I want to use proguard and I'm new to it.
What do I need to write in proguard-project.txt to include newrelic in proguard.
Thanks!
After some testing and researching, to launch an Android app with NewRelic and have ProGuard enabled, just copy and paste the following snippet in your proguard.cfg file (or if you have yours specified as proguard-properties.txt):
-keep class com.newrelic.** { *; }
-dontwarn com.newrelic.**
-keepattributes Exceptions, Signature, InnerClasses
Source
You'll need to add the following -keep code to your proguard.cfg file (or if you have yours specified as proguard-properties.txt):
-keep public class com.newrelic.** {
public *;
private *;}
Install the agent and add that code snippet to your progaurd.cfg file.
As for the issue with non-New Relic apps throwing errors when New Relic is installed, this seems to be an issue with the build path settings in Eclipse, you can open a support ticket with us at support#newrelic.com and we can take a look at your specific environment settings, but prior cases indicate that this isn't really a New Relic-specific error.
Related
I activated google analytics for my android application, when I tried to use proguard I got this errors.
What is the solution?
It means that class is obfuscated by proguard.
Personally I always add the generic rule
-keep class com.google.** { *; }
in my proguard because I only care for obfuscation of my own code. That should fix your error. But if you just want to add that class only it should also work I guess.
I've searched discuss.cocos for an example but there isn't one. Feeling this to be a more OS agnostic platform to ask on I search for enlightenment here.
I got a massive headache after turning it on by writing
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt
in project.properties in my project's base directory.
I couldn't copy-past text because the console display in Eclipse immediately cleared and presented like there was nothing wrong but I got "error code 1. See console" type of message, repeatedly.
Though the problem appears to be with twitter4j I'm sure there are many more warnings that scrolled by before that, well, I'm not sure, the whole thing was so sudden.
I've trawled this site for help and while most advice consists of adding dontwarn lines I feel I need to be exporting libraries instead of, as I did with twitter4j, just copying the libjar to my project's own lib folder.
I've tried adding:
-dontwarn twitter4j.management.**
-dontwarn twitter4j.**
-dontwarn javax.management.**
-dontwarn com.google.api.client.googleapis.extensions.android.gms.**
-keep class javax.** { *; }
-keep class org.** { *; }
-keep class twitter4j.** { *; }
-keep class java.lang.management.** { *; }
-keep class com.google.code.** { *; }
-keep class oauth.signpost.** { *; }
-libraryjars /libs/twitter4j-core-3.0.3.jar
-keep class twitter4j.**
-keepclassmembers class twitter4j.** {
<init>(...);
<methods>;
<fields>;
}
To proguard-project.txt but it had no effect. I'm tending not to want to bother with proguard since C++ is much better for obfuscation anyway. It's strange how none of the howto's I read promoted including the entire twitter4j project. I prefer the small 300kb library. But not if it's limiting optimisations in other respects.
My SDK is version 22.6 by the way.
____EDIT____
In looking for a complete example i found SDK/tools/proguard/examples/android.pro
I tried copy pasting the lot to no further effect but was disconcerted by the advice in the header of that file:
If you're using the Android SDK (version 2.3 or higher), the android tool
already creates a file like this in your project, called proguard.cfg.
It should contain the settings of this file, minus the input and output paths
(-injars, -outjars, -libraryjars, -printmapping, and -printseeds).
The generated Ant build file automatically sets these paths.
Android tool? proguard.cfg? Surely proguard knows the new files are merely instructed to reference the configs in the SDK/tools/proguard directory?
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt
You say you're changing proguard-project.txt, but are you actually using that file? Have you changed project.properties to point to your file instead of the default android one?
proguard.config=proguard-project.txt
Your project.properties file should point to Android's default configuration and to your own project-specific configuration:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
This is the standard line in the properties files that the Android SDK generates.
In your proguard-project.txt file, you can then add -keep options to avoid problems with code that performs reflection. In this case, you should also add -dontwarn options to reassure ProGuard that the missing dependencies are not a problem in practice. It will then proceed processing the application.
You should not add -libraryjars options, since the Android build process already automatically specifies all necessary -injars, -outjars, and -libraryjars for you.
My app is able to run without any issues during testing etc. But when I export out apk compiled with ProGuard, there are issues like random crashing and some features not working as expected.
I not sure is it due to the external jar libraries I have included in the project which is not properly configured in Proguard.
I have included the following in the proguard-android.txt file. I have two libraries so I added these:
-keep class org.apache.commons.net.** { *; }
-keep class org.jsoup.** { *; }
Is it the correct way? Is there any other way?
To add libraries just add -libraryjars ../libs/<libname>
After that you may need to keep classes and interfaces based on the errors you receive
I'm trying to build an Android release with Ant and ProGuard. I uncommented the following line in project.properties, despite the comment in said file noting that you shouldn't modify it ;):
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
When obfuscating, I get the following notes:
[proguard] Note: the configuration refers to the unknown class 'com.google.vending.licensing.ILicensingService'
[proguard] Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService'
I do understand why this is happening. These lines can be found in the default ProGuard config file (${sdk.dir}/tools/proguard/proguard-android.txt):
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
I'm not using the Google Licensing Service, so the classes are indeed unknown. I found a solution to get rid of these notes by updating the proguard-project.txt:
-dontnote **ILicensingService
My question: Is this the correct way of handling this? It seems to me that these classes shouldn't be kept by default anyway, since that lib isn't mandatory for an android project. The only way I can think of to achieve this is by copying the default config file to my project, removing the -keep lines and ignoring the default config file in the SDK completely. Which doesn't seem as the proper way to go either. Or am I missing something?
The setting "-dontnote com.google.vending.licensing.ILicensingService" is fine. In fact, it could have been part of the default configuration file.
The -keep option may be necessary for projects that use the library.
The -dontnote option may be nice to suppress the note about the -keep option, for projects that don't use the library. The note is just a gentle reminder that the configuration file could contain a typo, because the specified class doesn't seem to exist. It doesn't affect the processing.
I recently signed an apk file for release on Google Play and when I downloaded the application on Google Play and installed it, it would throw java.lang.ExceptionInInitializerError.
My co-worker and I are suspecting that the library was not being added to our signed apk file.
We added our additional library to our project by adding it to our build path for the project.
Also, the library we are trying to add to our project is ActionBarSherlock.
Is there a reason why our library is not being included in our signed apk file, because we notice the file size for our signed apk is alot smaller than our unsigned version?
Can anyone point us in the right direction in signing our apk file correctly so that it includes the library we added into our build path?
I had the exact same error missing android.support.v4 jar file. deeJ is right if you look at ActionBarSherlock website it tells you to add the following in your proguard file:
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
-keepattributes *Annotation*
I found out that the problem was Proguard not playing well with ActionBarSherlock. Try using tips given here:
http://actionbarsherlock.com/faq.html
Not sure on your exact build process, my suggestion would be to use Maven for your builds. It might be that your dependancies are only used on your debug build rather than your release build. Another thing I would suggest, before putting something on the app store use the Android Debug Bridge (adb) to manually install it on a device and check for these kinds of errors.