(Android) Proguard 找不到动态引用的类 javax.swing.*

发布于 2024-10-09 05:33:51 字数 3266 浏览 3 评论 0原文

我对 Proguard 和外部库的使用有疑问。我的项目编译没有错误并在真实设备上成功运行, 但只有当我从 Eclipse 运行它时。现在我想制作一个混淆的发行版本,所以我做了以下操作: 运行“android更新项目-p ./” 添加

proguard.dir=/home/stoned/android-sdk-linux_86/proguard4.5.1/lib
proguard.config=/home/stoned/workspace/Fidoo/proguard.cfg

当我运行“ant release”时我得到以下信息:

... skipped many irrelevant messages ...

-obfuscate:
    [mkdir] Created dir: /home/stoned/workspace/Fidoo/bin/proguard
      [jar] Building jar: /home/stoned/workspace/Fidoo/bin/proguard/original.jar
 [proguard] ProGuard, version 4.4
 [proguard] ProGuard is released under the GNU General Public License. The authors of all
 [proguard] programs or plugins that link to it (com.android.ant, ...) therefore
 [proguard] must ensure that these programs carry the GNU General Public License as well.
 [proguard] Reading input...
 [proguard] Reading program jar [/home/stoned/workspace/Fidoo/bin/proguard/original.jar]
 [proguard] Reading program jar [/home/stoned/workspace/Fidoo/libs/exapi-1.16.jar]
 [proguard] Reading program jar [/home/stoned/workspace/Fidoo/libs/libthrift.jar]
 [proguard] Reading program jar [/home/stoned/workspace/Fidoo/libs/log4j-1.2.14.jar]
 [proguard] Reading library jar [/home/stoned/android-sdk-linux_86/platforms/android-4/android.jar]
 [proguard] Initializing...
 [proguard] Warning: org.apache.log4j.lf5.viewer.categoryexplorer.CategoryNodeRenderer: can't find superclass or interface javax.swing.tree.DefaultTreeCellRenderer
 [proguard] Warning: org.apache.log4j.lf5.viewer.categoryexplorer.TreeModelAdapter: can't find superclass or interface javax.swing.event.TreeModelListener
 [proguard] Warning: org.apache.log4j.lf5.viewer.LogBrokerMonitor$32: can't find superclass or interface java.awt.event.ActionListener
 [proguard] Warning: org.apache.log4j.lf5.viewer.LogBrokerMonitor$31: can't find superclass or interface java.awt.event.ActionListener

... skipped many lines of similar messages ...

 [proguard] Note: org.apache.log4j.lf5.viewer.categoryexplorer.CategoryAbstractCellEditor: can't find dynamically referenced class javax.swing.event.CellEditorListener
 [proguard] Note: org.apache.log4j.lf5.viewer.categoryexplorer.CategoryAbstractCellEditor: can't find dynamically referenced class javax.swing.event.CellEditorListener
 [proguard] Note: org.apache.log4j.lf5.viewer.categoryexplorer.CategoryAbstractCellEditor: can't find dynamically referenced class javax.swing.event.CellEditorListener
 [proguard] Note: org.apache.log4j.lf5.viewer.categoryexplorer.CategoryAbstractCellEditor: can't find dynamically referenced class javax.swing.event.CellEditorListener
 [proguard] Note: org.apache.log4j.spi.LocationInfo: can't find dynamically referenced class com.ibm.uvm.tools.DebugSupport
 [proguard] Note: there were 5 unresolved dynamic references to classes or interfaces.
 [proguard]       You should check if you need to specify additional program jars.
 [proguard] Warning: there were 1656 unresolved references to classes or interfaces.
 [proguard]          You may need to specify additional library jars (using '-libraryjars'),
 [proguard]          or perhaps the '-dontskipnonpubliclibraryclasses' option.

显然,javax.swing。 Android 应用程序中不需要类,log4j 类也是如此。如何让 proguard 不搜索那些引用的库?

I have a problem with Proguard and use of external libraries. My project compiles without errors and runs successfully on a real device,
but only when I run it from Eclipse. Now I want to make an obfuscated release version so I did the following:
ran "android update project -p ./"
added

proguard.dir=/home/stoned/android-sdk-linux_86/proguard4.5.1/lib
proguard.config=/home/stoned/workspace/Fidoo/proguard.cfg

when I run "ant release" I get the following:

... skipped many irrelevant messages ...

-obfuscate:
    [mkdir] Created dir: /home/stoned/workspace/Fidoo/bin/proguard
      [jar] Building jar: /home/stoned/workspace/Fidoo/bin/proguard/original.jar
 [proguard] ProGuard, version 4.4
 [proguard] ProGuard is released under the GNU General Public License. The authors of all
 [proguard] programs or plugins that link to it (com.android.ant, ...) therefore
 [proguard] must ensure that these programs carry the GNU General Public License as well.
 [proguard] Reading input...
 [proguard] Reading program jar [/home/stoned/workspace/Fidoo/bin/proguard/original.jar]
 [proguard] Reading program jar [/home/stoned/workspace/Fidoo/libs/exapi-1.16.jar]
 [proguard] Reading program jar [/home/stoned/workspace/Fidoo/libs/libthrift.jar]
 [proguard] Reading program jar [/home/stoned/workspace/Fidoo/libs/log4j-1.2.14.jar]
 [proguard] Reading library jar [/home/stoned/android-sdk-linux_86/platforms/android-4/android.jar]
 [proguard] Initializing...
 [proguard] Warning: org.apache.log4j.lf5.viewer.categoryexplorer.CategoryNodeRenderer: can't find superclass or interface javax.swing.tree.DefaultTreeCellRenderer
 [proguard] Warning: org.apache.log4j.lf5.viewer.categoryexplorer.TreeModelAdapter: can't find superclass or interface javax.swing.event.TreeModelListener
 [proguard] Warning: org.apache.log4j.lf5.viewer.LogBrokerMonitor$32: can't find superclass or interface java.awt.event.ActionListener
 [proguard] Warning: org.apache.log4j.lf5.viewer.LogBrokerMonitor$31: can't find superclass or interface java.awt.event.ActionListener

... skipped many lines of similar messages ...

 [proguard] Note: org.apache.log4j.lf5.viewer.categoryexplorer.CategoryAbstractCellEditor: can't find dynamically referenced class javax.swing.event.CellEditorListener
 [proguard] Note: org.apache.log4j.lf5.viewer.categoryexplorer.CategoryAbstractCellEditor: can't find dynamically referenced class javax.swing.event.CellEditorListener
 [proguard] Note: org.apache.log4j.lf5.viewer.categoryexplorer.CategoryAbstractCellEditor: can't find dynamically referenced class javax.swing.event.CellEditorListener
 [proguard] Note: org.apache.log4j.lf5.viewer.categoryexplorer.CategoryAbstractCellEditor: can't find dynamically referenced class javax.swing.event.CellEditorListener
 [proguard] Note: org.apache.log4j.spi.LocationInfo: can't find dynamically referenced class com.ibm.uvm.tools.DebugSupport
 [proguard] Note: there were 5 unresolved dynamic references to classes or interfaces.
 [proguard]       You should check if you need to specify additional program jars.
 [proguard] Warning: there were 1656 unresolved references to classes or interfaces.
 [proguard]          You may need to specify additional library jars (using '-libraryjars'),
 [proguard]          or perhaps the '-dontskipnonpubliclibraryclasses' option.

Obviously, javax.swing. classes are not needed in Android application, as well as log4j classes. How do I make proguard not to search for those referenced libraries?

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

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

发布评论

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

评论(3

睫毛溺水了 2024-10-16 05:33:51

如果没有没有 Swing 依赖项的 log4j 版本,并且您无法在构建过程中轻松地在 jar 上添加过滤器,那么最干净的解决方案是仅关闭 proguard.cfg 中的这些特定警告

-dontwarn org.apache.log4j.lf5.viewer.**
-dontnote org.apache.log4j.lf5.viewer.**

:仍然会收到任何其他可能相关的警告。

If there is no version of log4j without the Swing dependencies, and if you can't easily add a filter on the jar in the build process, the cleanest solution is to switch off just these particular warnings in proguard.cfg:

-dontwarn org.apache.log4j.lf5.viewer.**
-dontnote org.apache.log4j.lf5.viewer.**

You'll then still get any other warnings that might be relevant.

无敌元气妹 2024-10-16 05:33:51

好吧,您将 log4j 放入类路径中(libs/log4j-1.2.14.jar)。这就是包含 log4j 的原因。它还引入了对 javax.swing 的引用。

Well, you put log4j into your classpath (libs/log4j-1.2.14.jar). That's why log4j is included. It is also pulling in references to javax.swing.

合约呢 2024-10-16 05:33:51

没关系,只是添加

-dontwarn
-dontnote

到 proguard.cfg 中

Nevermind, just added

-dontwarn
-dontnote

to proguard.cfg

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