Сбой сборки Proguard с добавлением внешних библиотек - PullRequest
0 голосов
/ 28 декабря 2018

У меня есть следующий файл 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 голосов
/ 28 декабря 2018

minifyEnabled true включает proguard.Таким образом, у вас есть 2 варианта: 1. Если вам не нужен proguard, просто сделайте его ложным 2. В противном случае вам нужно написать правила proguard для библиотек, вызывающих проблему.Вы можете легко получить их на Git.

...