简体   繁体   English

使用proguard构建Android Studio版本:在程序中找不到引用的字段

[英]Android Studio release build with proguard: can't find referenced field in program

this is the newest hot issue for every android pro coder. 这是每个Android专业编码人员的最新热点问题。 Will you shine in the glory of wisdom? 你会在智慧的荣耀中闪耀吗?

I got a warning from proguard. 我收到了proguard的警告。 The class Appirater cause this warning: Appirater类导致此警告:

can't find referenced field in program class de.xxx.xxx.R.$id 在程序类de.xxx.xxx.R. $ id中找不到引用的字段

From the proguard website proguard troubleshooting 来自proguard网站的proguard故障排除

A program class is referring to a field or a method that is missing from another program class. 程序类指的是另一个程序类中缺少的字段或方法。 The warning lists both the referencing class and the missing referenced class member. 警告列出了引用类和缺少的引用类成员。 Your compiled class files are most likely inconsistent. 您编译的类文件很可能不一致。 Possibly, some class file didn't get recompiled properly, or some class file was left behind after its source file was removed. 可能一些类文件没有被正确地重新编译,或者在删除源文件后遗留了一些类文件。 Try removing all compiled class files and rebuilding your project. 尝试删除所有已编译的类文件并重建项目。

A Build --> Clean --> Rebuild is not working. 构建 - >清理 - >重建不起作用。

If I add 如果我加

-dontwarn -dontwarn

the code compiles but the app crashes on startup. 代码编译但应用程序在启动时崩溃。

To add the whole proguard.cfg from the Appirater repo leads to no success. Appirater repo添加整个proguard.cfg导致没有成功。

Try 尝试

-keepclassmembers class **.R$* {
    public static <fields>;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM