简体   繁体   English

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

[英](Android) Proguard can't find dynamically referenced class javax.swing.*

I have a problem with Proguard and use of external libraries. 我有Proguard的问题和使用外部库。 My project compiles without errors and runs successfully on a real device, but only when I run it from Eclipse. 我的项目编译没有错误,并在真实设备上成功运行,但只有当我从Eclipse运行它时。 Now I want to make an obfuscated release version so I did the following: ran "android update project -p ./" added 现在我想制作一个混淆版本,所以我做了以下内容:运行“android update project -p ./”添加

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: 当我运行“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.

Obviously, javax.swing. 显然,javax.swing。 classes are not needed in Android application, as well as log4j classes. Android应用程序以及log4j类不需要类。 How do I make proguard not to search for those referenced libraries? 如何让proguard不搜索那些引用的库?

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: 如果没有Swing依赖项的log4j版本,并且如果你无法在构建过程中轻松地在jar上添加过滤器,那么最干净的解决方案是在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. 然后,您仍然会收到任何其他可能相关的警告。

Nevermind, just added 没关系,只是补充道

-dontwarn
-dontnote

to proguard.cfg 到proguard.cfg

Well, you put log4j into your classpath (libs/log4j-1.2.14.jar). 好吧,你将log4j放入你的类路径(libs / log4j-1.2.14.jar)。 That's why log4j is included. 这就是为什么包含log4j的原因。 It is also pulling in references to javax.swing. 它还引用了javax.swing。

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

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