How to fix warning 'can't find referenced class' in Android Eclipse ProGuard Rule?

前提是你 提交于 2019-12-18 08:27:33

问题


I am using Eclipse. In my Android code, I have used ProGuard. But while exporting the APK, I encountered the following warnings:

Proguard returned with error code 1. See console
Warning: okio.DeflaterSink: can't find referenced class     org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
       You should check if you need to specify additional program jars.
Warning: there were 14 unresolved references to classes or interfaces.
          You may need to specify additional library jars (using '-libraryjars').
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:211)
at proguard.ProGuard.execute(ProGuard.java:86)
at proguard.ProGuard.main(ProGuard.java:492)

What's wrong?


回答1:


You can Solve that by modifying the 'progaurd-rules.pro' which seems that you are using Progaurd for Shrinking your Code.

You must use -dontwarn But be careful before adding this to proguard file as there will not be errors at testing because Proguard had already delete some classes not being used

for case of OKiO add these lines

-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**

For any other library you can see this link for further proguard operations https://github.com/krschultz/android-proguard-snippets




回答2:


Probably its better to add Okio rules from android-proguard-snippets:

# Okio
-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**


来源:https://stackoverflow.com/questions/36737073/how-to-fix-warning-cant-find-referenced-class-in-android-eclipse-proguard-rul

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!