如何从 proguard 构建中排除 R*.class 文件

发布于 2024-09-02 16:13:34 字数 1147 浏览 4 评论 0原文

我距离制定此处描述的方法仅一步之遥: 使用 Scala 2.8 Trunk 构建定位 Android

与单个项目配合使用(对比一个 scala 项目和一个 android 项目)。

我遇到了一个问题。使用此输入文件(参数)proguard:

-injars bin;lib/scala-library.jar(!META-INF/MANIFEST.MF,!library.properties)

-outjar lib/scandroid.jar

-libraryjars lib/android.jar

-dontwarn
-dontoptimize
-dontobfuscate
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers

-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
                SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
-keep public class org.scala.jeb.** { public protected *; }
-keep public class org.xml.sax.EntityResolver { public protected *; }

Proguard 成功构建了 scandroid.jar,但它似乎包含了 android 资源构建器生成和编译的生成的 R 类。在本例中,它们位于 bin/org/jeb/R*.class 中。这不是我想要的。 android dalvik 转换器无法构建,因为它认为存在 R 类的重复项(它位于 scandroid 以及 R*.class 文件中)。如何修改上述 proguard 参数以从 scandroid.jar 中排除 R*.class 文件,以便 dalvik 转换器满意? 编辑:我应该注意,我尝试添加 ;bin/org/jeb/R.class;etc... 到 -libraryjars 参数中,这似乎只会导致它抱怨重复的类,此外 proguard 决定排除我的 scala 类文件也是如此。

I am one step away from making the method described here:
Targeting Android with Scala 2.8 Trunk builds

work with a single project (vs one project for scala and one for android).

I've come across a problem. Using this input file (arguments to) proguard:

-injars bin;lib/scala-library.jar(!META-INF/MANIFEST.MF,!library.properties)

-outjar lib/scandroid.jar

-libraryjars lib/android.jar

-dontwarn
-dontoptimize
-dontobfuscate
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers

-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
                SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
-keep public class org.scala.jeb.** { public protected *; }
-keep public class org.xml.sax.EntityResolver { public protected *; }

Proguard successfully builds scandroid.jar, however it appears to have included the generated R classes that the android resource builder generates and compiles. In this case, they are located in bin/org/jeb/R*.class. This is not what I want. The android dalvik converter cannot build because it thinks there is a duplicate of the R class (it's in scandroid and also the R*.class files). How can I modify the above proguard arguments to exclude the R*.class files from the scandroid.jar so the dalvik converter is happy?
Edit: I should note that I tried adding ;bin/org/jeb/R.class;etc... to the -libraryjars argument, and that only seemed to cause it to complain about duplicate classes, and in addition proguard decided to exclude my scala class files too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

同展鸳鸯锦 2024-09-09 16:13:34

我使用这个选项。您可以从下面的链接找到参考并找到“完整的 Android 应用程序”。
http://proguard.sourceforge.net/index.html#/manual/examples.html

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

I use this option. You can find reference from link below and find "A complete Android application".
http://proguard.sourceforge.net/index.html#/manual/examples.html

-keepclassmembers class **.R$* {
    public static <fields>;
}
情话难免假 2024-09-09 16:13:34

文件过滤器 !**/*R.java 换句话说,这个留置权强制 Proguard 将除 R.java 文件之外的所有 java 文件保留在混淆中

file filter !**/*R.java in other words this lien forces Proguard to keep all java files except R.java files in the obfuscation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文