我正试图通过Package Explorer Export>中的内置Proguard支持来使用Proguard。导出Android应用程序。主项目是使用一个库项目,而该库项目又使用了android兼容库,它也使用了这个兼容性库本身。基本上是这样的:
BaseLibraryProject BaseActitivity 库:Android的支持,v4.jar MainProject 使用库BaseLibraryProject 库:机器人支撑-v4.jar
此应用在设备和模拟器上运行正常。 然而,Proguard会发出很多警告并存在代码1。
这是Proguard相关列表的最后一点:
[2012-04-09 14:19:49 - MainProject] Warning: android.support.v4.widget.SearchViewCompatHoneycomb: can't find referenced class android.widget.SearchView
[2012-04-09 14:19:49 - MainProject] Warning: android.support.v4.widget.SearchViewCompatHoneycomb: can't find referenced class android.widget.SearchView
[2012-04-09 14:19:49 - MainProject] Warning: android.support.v4.widget.SearchViewCompatHoneycomb: can't find referenced class android.widget.SearchView$OnQueryTextListener
[2012-04-09 14:19:49 - MainProject] Warning: android.support.v4.widget.SearchViewCompatHoneycomb: can't find referenced class android.widget.SearchView
[2012-04-09 14:19:49 - MainProject] Warning: android.support.v4.widget.SearchViewCompatHoneycomb$1: can't find referenced class android.widget.SearchView$OnQueryTextListener
[2012-04-09 14:19:49 - MainProject] Warning: android.support.v4.widget.SearchViewCompatHoneycomb$1: can't find referenced class android.widget.SearchView
[2012-04-09 14:19:49 - MainProject] Warning: there were 131 unresolved references to classes or interfaces.
[2012-04-09 14:19:49 - MainProject] You may need to specify additional library jars (using '-libraryjars').
[2012-04-09 14:19:49 - MainProject] Warning: there were 29 unresolved references to program class members.
[2012-04-09 14:19:49 - MainProject] Your input classes appear to be inconsistent.
[2012-04-09 14:19:49 - MainProject] You may need to recompile them and try again.
[2012-04-09 14:19:49 - MainProject] Alternatively, you may have to specify the option
[2012-04-09 14:19:49 - MainProject] '-dontskipnonpubliclibraryclassmembers'.
[2012-04-09 14:19:49 - MainProject] java.io.IOException: Please correct the above warnings first.
如您所见:它无法找到兼容性库。
这是proguard.cfg文件的开头,包括-libraryjars和-dontskipnonpubliclibraryclassmembers:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-libraryjars libs/android-support-v4.jar
没有区别。我尝试了将库添加到BaseLibrary项目/ MainProject的各种组合,完全限定的路径名。似乎没有任何帮助。
关于proguard的大多数stackoverflow问题似乎都涉及设置Ant。 知道什么可能导致这个问题,以及如何让Proguard在这个使用多个库的项目上工作?
提前谢谢,
答案 0 :(得分:17)
ADT 17的发布为Proguard的工作方式带来了许多改进,包括更好的默认值,我认为这应该可以解决你的支持库问题。
请参阅 - http://tools.android.com/recent/proguardimprovements
Eclipse(project.properties)
从ADT 17开始,默认的project.properties文件现在包含以下行,该行引用标准的Proguard配置文件(proguard-android.txt)和项目特定的Proguard配置文件(proguard-project.txt)...... / p>
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
我建议创建一个新的Android项目,看看它是如何布局的并使用这些新文件。您的应用程序将长期受益,因为Proguard和默认配置都有所改进。
<强>更新强>
Gradle(build.gradle)
以下将使用默认标准proguard config&amp;当地项目的规则。
android {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}