最近,我按照IDE的建议,将Android从0.4.2升级到0.5.0,将Android插件从0.7.2升级到0.9.0。该项目运行并安装良好,但是当我按Build->时,它会抛出一个错误,从而停止重建。下面是Messages选项卡中的一个错误:
Information:See complete output in console
Error:Execution failed for task ':projectName:proguardDebug'.
> java.io.IOException: Please correct the above warnings first.
下面是控制台中描述的问题:
:projectName:proguardDebug
Note: there were 2345 duplicate class definitions.
Warning: com.facebook.Settings: can't find referenced class com.facebook.android.BuildConfig
Warning: com.facebook.Settings: can't find referenced class com.facebook.android.BuildConfig
Warning: com.facebook.internal.Utility: can't find referenced class com.facebook.android.BuildConfig
Warning: com.facebook.internal.Utility: can't find referenced class com.facebook.android.BuildConfig
Warning: there were 4 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
:projectName:proguardDebug FAILED
FAILURE: Build failed with an exception.
据我所知,问题是缺少了BuildConfig.java,它在我从/gen迁移之前就在/gen文件夹中。但是现在没有/gen文件夹,BuildConfig.java位于/buildConfig/BuildConfig.java/ forlder中。
我找到了唯一的解决方案,它增加了行
-dontwarn com.facebook.**
配置文件,但这并不是真正的解决方案。
发布于 2014-03-07 19:53:59
问题是我们的库没有打包BuildConfig。这是因为我们允许(目前)库具有相同的包名。我们要改变这一点。
这不应该是一个问题,因为BuildConfig只是应该在代码中内联的常量。您可以通过只排除BuildConfig来做临时修正:
-dontwarn com.facebook.android.BuildConfig
我们可能很快就会解决这个问题的。
发布于 2014-03-07 19:34:34
来自警告中的链接
如果缺少的类是从预编译的第三方库中引用的,并且您的原始代码在没有它的情况下运行良好,那么缺少的依赖项似乎不会受到伤害。最干净的解决方案是从输入中筛选出引用类或类,使用类似于“mylibrary.jar(!somepackage/SomeUnusedReferencingClass.class)". -libraryjars”的过滤器。然后,ProGuard将在输入中跳过该类,并且不会遇到缺少引用的问题。但是,您可能必须筛选出其他类,而这些类反过来又引用已删除的类。实际上,如果可以使用通配符筛选器(如"-libraryjars mylibrary.jar(!someunusedpackage/**)“),可以同时过滤出整个未使用的包,这是最有效的。如果您不想筛选出有问题的类,可以尝试使用-ignorewarnings选项,甚至-dontwarn选项。只有当你真正知道你在做什么的时候,才使用这些选项。
https://stackoverflow.com/questions/22246280
复制相似问题