Proguard构建失败,并添加了外部库

时间:2018-12-28 05:47:39

标签: android proguard android-proguard

我有以下build.gradle文件

`     应用插件:“ com.android.application”     应用插件:“ com.google.gms.google-services”

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.anuj.auth"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    buildToolsVersion '28.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.2'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.firebaseui:firebase-ui:4.1.0'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
    implementation 'com.github.chathuralakmal:AndroidImagePopup:1.2.1'
    implementation 'com.google.zxing:core:3.2.1'
    implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
    implementation 'com.google.firebase:firebase-ml-vision:15.0.0'
    implementation 'com.androidessence:pinchzoomtextview:1.0.1'
}

`

我已经启用了proguard规则,但是即使我将proguard-rules.pro留空,也会出现以下错误。 我对proguard的概念是陌生的,并且感到很困惑。

这是我在启用proguard规则的情况下构建应用程序时收到的消息。

`

Warning: com.ceylonlabs.imageviewpopup.ImagePopup: can't find referenced method 'com.squareup.picasso.Picasso with(android.content.Context)' in program class com.squareup.picasso.Picasso
Warning: com.ceylonlabs.imageviewpopup.ImagePopup: can't find referenced method 'com.bumptech.glide.request.target.Target into(android.widget.ImageView)' in program class com.bumptech.glide.RequestBuilder
Warning: com.jakewharton.picasso.OkHttp3Downloader: can't find referenced class com.squareup.picasso.Downloader$ResponseException
Warning: com.jakewharton.picasso.OkHttp3Downloader: can't find referenced class com.squareup.picasso.Downloader$ResponseException
Warning: com.jakewharton.picasso.OkHttp3Downloader: can't find referenced class com.squareup.picasso.Downloader$Response
Warning: com.jakewharton.picasso.OkHttp3Downloader: can't find referenced class com.squareup.picasso.Downloader$Response
Warning: com.jakewharton.picasso.OkHttp3Downloader: can't find referenced class com.squareup.picasso.Downloader$Response
Note: com.bumptech.glide.Glide: can't find dynamically referenced class com.bumptech.glide.GeneratedAppGlideModuleImpl
Note: io.grpc.Context: can't find dynamically referenced class io.grpc.override.ContextStorageOverride
Note: io.grpc.ManagedChannelProvider: can't find dynamically referenced class io.grpc.netty.NettyChannelProvider
Note: io.grpc.internal.DnsNameResolver: can't find dynamically referenced class javax.naming.directory.InitialDirContext
Note: io.grpc.internal.DnsNameResolver: can't find dynamically referenced class com.sun.jndi.dns.DnsContextFactory
Note: io.grpc.okhttp.internal.Platform: can't find dynamically referenced class org.conscrypt.OpenSSLProvider

> Task :app:transformClassesAndResourcesWithProguardForRelease 
Request to incrementing alive workforce from 0. Current workforce (dead or alive) 4
thread-pool size=8

Note: there were 6 unresolved dynamic references to classes or interfaces.
      You should check if you need to specify additional program jars.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Warning: there were 5 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)
Warning: there were 2 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile the code.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
Thread(Tasks limiter_5): destruction

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s
24 actionable tasks: 3 executed, 21 up-to-date

`

1 个答案:

答案 0 :(得分:0)

minifyEnabled true启用proguard。因此,您有2个选择: 1.如果您不需要保护者,则将其设置为false 2.否则,您需要为引起问题的库编写proguard规则。您可以在Git上轻松获得它们。