Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard Warning : com.example.android.PaymentGateway: can't find referenced field 'int container_pg' in class com.example.android.R$id

I am using proguard in android app. It is required to add this to make code obfuscated and difficult to do reverse engineering.

I am getting this problem while export the apk. Proguard throws below warning even I use the -dontskipnonpubliclibraryclassmembers. I am not sure what additional things I need to do to resolve this.

Please assist and thanks in advance.

[2014-08-14 15:48:28 - ] Warning: com.example.android.PaymentGateway: can't find referenced field 'int container_pg' in class com.example.android.R$id
[2014-08-14 15:48:28 - ] Warning: com.example.android.PaymentGateway$RetrieveEncKey: can't find referenced field 'int container_pg' in class com.example.android.R$id
[2014-08-14 15:48:28 - ]       You should check if you need to specify additional program jars.
[2014-08-14 15:48:28 - ] Warning: there were 2 unresolved references to program class members.
[2014-08-14 15:48:28 - ]          Your input classes appear to be inconsistent.
[2014-08-14 15:48:28 - ]          You may need to recompile them and try again.
[2014-08-14 15:48:28 - ]          Alternatively, you may have to specify the option 
[2014-08-14 15:48:28 - ]          '-dontskipnonpubliclibraryclassmembers'.
[2014-08-14 15:48:28 - ] java.io.IOException: Please correct the above warnings first.
[2014-08-14 15:48:28 - ]    at proguard.Initializer.execute(Initializer.java:321)
[2014-08-14 15:48:28 - ]    at proguard.ProGuard.initialize(ProGuard.java:211)
[2014-08-14 15:48:28 - ]    at proguard.ProGuard.execute(ProGuard.java:86)
[2014-08-14 15:48:28 - ]    at proguard.ProGuard.main(ProGuard.java:492)
like image 361
N Sharma Avatar asked Aug 14 '14 10:08

N Sharma


1 Answers

From the Proguard troubleshooting guide:

Your compiled class files are inconsistent with the libraries. You may need to recompile the class files, or otherwise upgrade the libraries to consistent versions.

[...]

If you're developing for Android and ProGuard complains that it can't find a method that is only available in a recent version of the Android run-time, you should change the build target in your project.properties file or build.gradle file to that recent version. You can still specify a different minSdkVersion and a different targetSdkVersion in your AndroidManifest.xml file.

If you can't resolve it that way, you can try -dontwarn com.example.android.R$id and see if your application runs despite the warnings, which is sometimes the case.

like image 93
legendof Avatar answered Oct 22 '22 23:10

legendof