Question

Recently I updated Android Studio from 0.4.2 to 0.5.0 and Android Gradle Plug-In from 0.7.2 to 0.9.0 as the IDE suggested. The project runs and installs good but when I press Build->Rebuild Project it throws an error, which stops the rebuild. Here is an error in Messages tab:

Information:See complete output in console
Error:Execution failed for task ':projectName:proguardDebug'.
> java.io.IOException: Please correct the above warnings first.

And here is the problem discribed in the console:

: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.

As I understood, the problem is missing BuildConfig.java, which was in /gen folder before I migrated from Eclipse. But now there is not /gen folder and BuildConfig.java is in the /build/source/buildConfig/debug/ forlder.

I found the only sollution that really does something to this, it is adding the line

-dontwarn com.facebook.** 

to the proguard config file, but it isn't really the sollution.

Was it helpful?

Solution

The problem is that our libraries don't package BuildConfig. This is because we allow (for now) libraries to have the same package name. we are going to change this.

This shouldn't be a problem as BuildConfig is only constants that should get inlined in the code anyway. You can do a temp fix with excluding only BuildConfig:

-dontwarn com.facebook.android.BuildConfig

We'll probably fix this soon.

OTHER TIPS

From the link in the warning:

  • If the missing class is referenced from a pre-compiled third-party library, and your original code runs fine without it, then the missing dependency doesn't seem to hurt. The cleanest solution is to filter out the referencing class or classes from the input, with a filter like "-libraryjars mylibrary.jar(!somepackage/SomeUnusedReferencingClass.class)". ProGuard will then skip this class entirely in the input, and it will not bump into the problem of its missing reference. However, you may then have to filter out other classes that are in turn referencing the removed class. In practice, this works best if you can filter out entire unused packages at once, with a wildcard filter like "-libraryjars mylibrary.jar(!someunusedpackage/**)".

  • If you don't feel like filtering out the problematic classes, you can try your luck with the -ignorewarnings option, or even the -dontwarn option. Only use these options if you really know what you're doing though.

  • Licensed under: CC-BY-SA with attribution
    Not affiliated with StackOverflow
    scroll top