1

My project is no longer compiling with Proguard optimisations. As you will see below it mentions dagger but I have not been using anything related to that directly. I recently updated many dependencies at once.

Warning: dagger.android.AndroidMemorySensitiveReferenceManager: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager_Factory: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager_Factory: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager_Factory: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager_Factory: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager_Factory: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager_Factory: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.AndroidMemorySensitiveReferenceManager_Factory: can't find referenced class dagger.releasablereferences.TypedReleasableReferenceManager
Warning: dagger.android.ReleaseReferencesAt: can't find referenced class dagger.releasablereferences.CanReleaseReferences

If I use dontwarn to suppress dagger related lines, I get the following messages (I tried to get more lines with --info, --debug and --scan but output has the same detail):

> Task :app:transformClassesAndResourcesWithProguardForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 2

I tried the latest(6.1.1) Proguard too (overriding the default one), the result is the same.

What can be the reason?

App's build.gradle contents:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {

    compileSdkVersion 29//28
    buildToolsVersion "29.0.0" //"28.0.3"
    defaultConfig {
        applicationId "myapp"
        minSdkVersion 16
        targetSdkVersion 28

        versionName "1.1.1"
        multiDexEnabled true
        manifestPlaceholders.crashlyticsEnabled = "true"
    }
    buildTypes {
        release {
            useProguard true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    dexOptions {
        javaMaxHeapSize "2g"
    }
}
configurations {
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}

dependencies {
    implementation 'com.android.billingclient:billing:2.0.0'
    implementation 'androidx.media:media:1.1.0-rc01'
    implementation 'androidx.preference:preference:1.1.0-beta01'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
    implementation 'com.google.android.material:material:1.1.0-alpha07'
    implementation files('libs/juniversalchardet-1.0.3.jar')
    implementation project(path: ':ViewPageIndicator')

    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-inappmessaging-display:18.0.0'
    implementation 'com.google.firebase:firebase-ads:18.0.0'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
    implementation 'com.google.firebase:firebase-analytics:17.0.0'

    implementation 'androidx.multidex:multidex:2.0.1'

    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.browser:browser:1.0.0'
    implementation 'com.facebook.android:facebook-login:4.42.0'
    implementation 'com.facebook.android:facebook-share:4.42.0'
    implementation 'com.amplitude:android-sdk:2.23.0'
    implementation 'com.flurry.android:analytics:11.5.0@aar'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'android.arch.lifecycle:runtime:1.1.1'
    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    implementation('io.socket:socket.io-client:1.0.0') {
        exclude group: 'org.json', module: 'json'
    }
}

apply plugin: 'com.google.gms.google-services'

UPDATE I reverted the dependencies to their previos versions. The problem is implementation 'com.google.firebase:firebase-inappmessaging-display:18.0.0' If I change the version to 17.1.0, "dagger" related problem disappears. If I change it to 17.2.0, the problem comes back.

UPDATE2 This may be a bug with Firebase. I have contacted them and they created an internal bug report. I will update this question when I have the answer.

frankish
  • 6,738
  • 9
  • 49
  • 100
  • what version of dagger are you using? – coroutineDispatcher Jun 20 '19 at 07:16
  • I have no idea. I am not using it directly. Something I have updated is using it perhaps? How can I check the version? (When I search dagger in the whole project/directory I find 0 results.) – frankish Jun 20 '19 at 07:21
  • can you update the question pasting your `build.graddle`? – coroutineDispatcher Jun 20 '19 at 07:33
  • I updated the question with the contents of `build.gradle` – frankish Jun 20 '19 at 07:39
  • If you do minifyEnabled false and useProguard false then you project builds or not? please check. meanwhile, share your progaurd file as well. Did you change anything in your progaurd? – Pranav P Jun 20 '19 at 07:48
  • I have not changed anything in proguard. If I disable proguard optimisations it compiles and runs. – frankish Jun 20 '19 at 07:50
  • please try this code to add in your progaurd file and let me know it works or not. – Pranav P Jun 20 '19 at 07:56
  • If I change the version of `com.google.firebase:firebase-inappmessaging-display` to `17.1.0`, "dagger" related problem disappears. If I change it to `17.2.0` or higher, the problem comes back. – frankish Jun 20 '19 at 09:10

2 Answers2

0

I had a very similar problem when I added the new version of firebase crashlytics to my project, the output was the same as yours, What I did was added a dontwarn for the dagger library on the pro-guard file, because this dagger problem was not affecting the project at all it is just a problem with the pro-guard obfuscation task.

#dagger
-dontwarn  dagger.android.**

That solved the problem for me.

dicarlomagnus
  • 576
  • 4
  • 17
-2

Because you don't know what is your dagger version it is very hard to find what is an exact issue in your project but you can add below code in your progaurd-rules.pro file and your project will successfully build.

-ignorewarnings
-keep class * {
    public private *;
}

Try and let me know. Hope it will work for you. Happy coding :)

Pranav P
  • 1,755
  • 19
  • 39
  • why would you do that? Might as well not use proguard then – Tim Jun 20 '19 at 08:01
  • I do not know tha dagger version because "I" am not using dagger myself. It seems like, one of the dependencies I updated, started to use it (perhaps). – frankish Jun 20 '19 at 08:02
  • That's not a good practice that you release your build with disable progaurd. You should know benefits of using progaurd in release build. – Pranav P Jun 20 '19 at 08:02
  • Yes Frankish, That's fine if you don't find out your dagger version so, just add this code. Hope it will work for you to release your build. – Pranav P Jun 20 '19 at 08:04
  • 1
    I tried it and yes it compiles but I cannot release my app with this :| I need better obfuscation so, I need to find another solution. Thank you. – frankish Jun 20 '19 at 08:25
  • Is that shows any other error during your release? or the same errors which you mentioned in the question? – Pranav P Jun 20 '19 at 08:27
  • It shows the same warnings but it also shows that I am ignoring all warnings. So, the same warnings, but it just does not stop the task. – frankish Jun 20 '19 at 08:32