Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find referenced class java.lang.invoke.LambdaMetafactory

I included AndroidRate library in my project

android {
    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    ...
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.android.support:multidex:1.0.2'
    implementation 'com.android.support:support-annotations:27.0.2'
    implementation 'com.android.support:support-compat:27.0.2'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.google.android.gms:play-services-base:11.6.2'
    implementation 'com.google.android.gms:play-services-cast:11.6.2'
    implementation 'com.google.firebase:firebase-core:11.6.2'
    implementation 'com.google.firebase:firebase-crash:11.6.2'
    implementation 'com.google.firebase:firebase-appindexing:11.6.2'
    implementation 'com.vorlonsoft:androidrate:1.0.7'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
} 

For the code below I get:

Warning:com.MyCompany.MyApp.MyAppClass: can't find referenced class java.lang.invoke.LambdaMetafactory

Warning:there were 2 unresolved references to classes or interfaces.

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

Error:Execution failed for task ':mobile:transformClassesAndResourcesWithProguardForFree_Release'.

Job failed, see logs for details

AppRate.with(this)
            .setStoreType(StoreType.GOOGLEPLAY)
            .setInstallDays((byte)1) // default 10, 0 means install day.
            .setLaunchTimes((byte)3) // default 10
            .setRemindInterval((byte)1) // default 1
            .setShowLaterButton(true) // default true
            .setDebug(false) // default false
            .setOnClickButtonListener(which -> Log.d(TAG, "RateButton: " + Byte.toString(which) + ""))
            .monitor();

On the other hand, the code below works fine:

AppRate.with(this)
            .setStoreType(StoreType.GOOGLEPLAY)
            .setInstallDays((byte)1) // default 10, 0 means install day.
            .setLaunchTimes((byte)3) // default 10
            .setRemindInterval((byte)1) // default 1
            .setShowLaterButton(true) // default true
            .setDebug(false) // default false
            .setOnClickButtonListener(new OnClickButtonListener() { // callback listener.
                @Override
                public void onClickButton(byte which) {
                    Log.d(TAG, "RateButton: " + Byte.toString(which) + "");
                }
            })
            .monitor();

How can I fix error for lambda code variant .setOnClickButtonListener(which -> Log.d(TAG, "RateButton: " + Byte.toString(which) + ""))?

like image 652
Alexander Savin Avatar asked Dec 13 '17 00:12

Alexander Savin


1 Answers

It should be safe to ignore these warnings. Just add the following in your proguard config file.

-dontwarn java.lang.invoke.**
like image 135
Vicki Jin Avatar answered Oct 20 '22 14:10

Vicki Jin