13

Since upgrading to android gradle plugin 3.0.1 I am getting following error:

Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.

:app:transformClassesAndResourcesWithProguardForProductionRelease FAILED

Problem is: I don't see any warning in my log.

I also ran the build with -i flag and I am getting following (big) log: https://gist.github.com/stoefln/b5e5e899c73b52d8065a5daeead716b3

Any ideas are very welcome!

stoefln
  • 14,498
  • 18
  • 79
  • 138
  • You should run your build with the -i flag and add -verbose to your proguard rules to get more output. The warning should be printed right after reading the library which has the problem. – T. Neidhart Feb 09 '18 at 18:44

7 Answers7

13

This is because in your dependencies there are multiples rxjava implicit dependencies with different version.

From this log:

Reading program jar [/Users/steph/.gradle/caches/modules-2/files-2.1/io.reactivex/rxjava/1.2.5/b423532b5a3c949cbb799468f83bf566032fe98d/rxjava-1.2.5.jar] (filtered)

and

Reading library jar [/Users/steph/.gradle/caches/modules-2/files-2.1/io.reactivex/rxjava/1.2.3/7fe1a94c1aeb958acc876fe616922cc191f3222c/rxjava-1.2.3.jar] (filtered)

You can see that in your app, there is 2 version of rxjava: 1.2.3 and 1.2.5

One of your dependencies, android-rxlocationsettings, is using rxjava 1.2.5, you can take a look at its build.gradle:

apply plugin: 'com.android.library'

dependencies {
  compile 'pl.charmas.android:android-reactive-location:0.10@aar'
  compile 'com.google.android.gms:play-services-location:10.0.1'
  compile 'com.android.support:support-v4:25.0.1'
  compile 'io.reactivex:rxjava:1.2.5'
}

android {
  compileSdkVersion 25
  buildToolsVersion "25.0.2"

  defaultConfig {
    minSdkVersion 14
  }
}

So, you need to exclude it either using exclude from dependency:

dependencies {
  ...
  compile ('com.github.jetradarmobile:android-rxlocationsettings:1.1.0') {
    exclude group: "io.reactivex", name: "rxjava"
  }
  ...
}

or using configuration:

configurations.all {
    exclude group: "io.reactivex", module:"rxjava"
}
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
  • can you please also add how you found out about the conflict? – stoefln Mar 05 '18 at 15:01
  • @stoefln: you can found it from `Note: duplicate definition of library class [rx.BackpressureOverflow$Strategy]`. `rx.***` is part of rxjava. Btw, you also have another duplicate library, it's probably android httpclient. every line with `Note: duplicate definition of library class ` is telling you that you have duplicate dependencies whether explicitly or implicitly. – ישו אוהב אותך Mar 05 '18 at 15:34
  • Thanks, makes sense. And how did you find out which libraries are referencing rx? – stoefln Mar 05 '18 at 15:41
  • It's simple, if you try founding for `rx.` occurances in your log, you will found out something like this: `Note: duplicate definition of library class [rx.plugins.RxJava.**`. Which means rx.** is the package of rxjava. Then go to the rxjava github to make sure. There you will found out that the package is for rxjava version 1. – ישו אוהב אותך Mar 05 '18 at 16:05
  • sorry, that's not what I meant. Let me rephrase the question: how did you find out that rx is used in the rxLocationSettings library? Did you use `./gradlew dependencies` for that? – stoefln Mar 05 '18 at 16:10
  • because there are many libraries, you can't go through all of them and check their dependencies – stoefln Mar 05 '18 at 16:12
  • 1
    Yes, you're correct. You can use `./gradlew app:dependencies` to see the dependencies tree. Or you can get a quick glance of your dependencies tree in your project by selecting the Project toolbar on the left then change Android to Project. You can see the library from `External Libraries`. – ישו אוהב אותך Mar 05 '18 at 16:32
11

The only thing that worked for me was this answer by @Moti Bartov

-ignorewarnings

At the end of proguard-rules.pro

Alberto M
  • 1,608
  • 1
  • 18
  • 42
1

To view the warnings add the option -verbose to your proguard file and grep the warnings from the gradle output:

./gradlew -i clean assemble<buildtype> | grep -i "warning"

where build type can be Release or any other build type you defined which contains the proguard configuration.

Werner Altewischer
  • 10,080
  • 4
  • 53
  • 60
0

just use -dontwarn in proguard-rules.pro like below

-dontwarn com.

0

I had a similar issue, in my case I checked the logs for warnings if you find any related to class reference, it indicates you need to clean build the project.

run gradlew clean followed by

gradlew build

or combined gradlew clean build

Build Failed

Warnings to look out for

0

try this (it's work for me)

I have also issue with pro guard but i found following code from git hub more useful.

add this line on proguard-rules.pro

-dontoptimize
-dontpreverify
Jaydeep Dobariya
  • 465
  • 6
  • 12
0

Juste add ignore warnings in proguard: https://stackoverflow.com/a/59428966/7308789

Houssin Boulla
  • 2,687
  • 1
  • 16
  • 22