1

我的项目不再使用 Proguard 优化进行编译。正如您将在下面看到的那样,它提到dagger但我没有直接使用与此相关的任何东西。我最近一次更新了许多依赖项。

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

如果我dontwarn用来抑制dagger相关行,我会收到以下消息(我尝试使用 获取更多行--info--debug--scan输出具有相同的详细信息):

> 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

我也尝试了最新的(6.1.1)Proguard(覆盖默认的),结果是一样的。

可能是什么原因?

应用程序build.gradle内容:

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'

更新 我将依赖项恢复到他们以前的版本。问题是 implementation 'com.google.firebase:firebase-inappmessaging-display:18.0.0' 如果我将版本更改为17.1.0,“匕首”相关问题就会消失。如果我将其更改为17.2.0,问题又回来了。

UPDATE2 这可能是 Firebase 的一个错误。我已经联系了他们,他们创建了一个内部错误报告。当我有答案时,我会更新这个问题。

4

2 回答 2

0

当我将新版本的 firebase crashlytics 添加到我的项目时,我遇到了一个非常相似的问题,输出与您的相同,我所做的是在 pro-guard 文件中为 dagger 库添加了一个 dontwarn,因为这个 dagger 问题是完全不影响项目,这只是 pro-guard 混淆任务的问题。

#dagger
-dontwarn  dagger.android.**

这为我解决了问题。

于 2020-11-04T15:56:30.003 回答
-2

因为您不知道您的 dagger 版本是什么,所以很难在您的项目中找到确切的问题,但是您可以在 progaurd-rules.pro 文件中添加以下代码,您的项目将成功构建。

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

试着让我知道。希望它对你有用。快乐编码:)

于 2019-06-20T07:56:21.027 回答