2

我正在尝试生成我的 android 应用程序的签名 apk,但任务仍然不成功,给我这个错误:

Information:Gradle tasks [:app:assembleRelease]
Warning:com.mikepenz.fastadapter_extensions.items.SingleLineItem: can't find referenced class com.mikepenz.materialize.holder.StringHolder
Warning:com.mikepenz.fastadapter_extensions.items.SingleLineItem: can't find referenced class com.mikepenz.materialize.holder.ImageHolder
Warning:com.mikepenz.fastadapter_extensions.items.SingleLineItem: can't find referenced class com.mikepenz.materialize.holder.StringHolder
Warning:com.mikepenz.fastadapter_extensions.items.SingleLineItem: can't find referenced class com.mikepenz.materialize.holder.ImageHolder
Warning:com.mikepenz.fastadapter_extensions.items.SingleLineItem: can't find referenced class com.mikepenz.materialize.holder.StringHolder
Warning:com.mikepenz.fastadapter_extensions.items.SingleLineItem: can't find referenced class com.mikepenz.materialize.holder.ImageHolder
Warning:com.mikepenz.fastadapter_extensions.items.SingleLineItem: can't find referenced class com.mikepenz.materialize.holder.StringHolder
Warning:com.mikepenz.fastadapter_extensions.items.SingleLineItem: can't find referenced class com.mikepenz.materialize.holder.ImageHolder
Warning:com.mikepenz.fastadapter_extensions.items.ThreeLineItem: can't find referenced class com.mikepenz.materialize.holder.StringHolder
Warning:com.mikepenz.fastadapter_extensions.items.ThreeLineItem: can't find referenced class com.mikepenz.materialize.holder.ImageHolder
Warning:com.mikepenz.fastadapter_extensions.items.ThreeLineItem: can't find referenced class com.mikepenz.materialize.holder.StringHolder
Warning:com.mikepenz.fastadapter_extensions.items.ThreeLineItem: can't find referenced class com.mikepenz.materialize.holder.ImageHolder
Warning:com.mikepenz.fastadapter_extensions.items.ThreeLineItem: can't find referenced class com.mikepenz.materialize.holder.StringHolder
Warning:com.mikepenz.fastadapter_extensions.items.ThreeLineItem: can't find referenced class com.mikepenz.materialize.holder.ImageHolder
Warning:com.mikepenz.fastadapter_extensions.items.ThreeLineItem: can't find referenced class com.mikepenz.materialize.holder.StringHolder
Warning:com.mikepenz.fastadapter_extensions.items.ThreeLineItem: can't find referenced class com.mikepenz.materialize.holder.ImageHolder
Warning:com.mikepenz.fastadapter_extensions.items.TwoLineItem: can't find referenced class com.mikepenz.materialize.holder.StringHolder
Warning:com.mikepenz.fastadapter_extensions.items.TwoLineItem: can't find referenced class com.mikepenz.materialize.holder.ImageHolder
Warning:com.mikepenz.fastadapter_extensions.items.TwoLineItem: can't find referenced class com.mikepenz.materialize.holder.StringHolder
Warning:com.mikepenz.fastadapter_extensions.items.TwoLineItem: can't find referenced class com.mikepenz.materialize.holder.ImageHolder
Warning:com.mikepenz.fastadapter_extensions.items.TwoLineItem: can't find referenced class com.mikepenz.materialize.holder.StringHolder
Warning:com.mikepenz.fastadapter_extensions.items.TwoLineItem: can't find referenced class com.mikepenz.materialize.holder.ImageHolder
Warning:com.mikepenz.fastadapter_extensions.items.TwoLineItem: can't find referenced class com.mikepenz.materialize.holder.StringHolder
Warning:com.mikepenz.fastadapter_extensions.items.TwoLineItem: can't find referenced class com.mikepenz.materialize.holder.ImageHolder
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl$Builder
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Request$Builder
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Call
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Response
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.ResponseBody
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Response
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.ResponseBody
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl$Builder
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Request$Builder
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Response
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Request
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Call
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Response
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.ResponseBody
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl$Builder
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Request$Builder
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Response
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.ResponseBody
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache
Warning:rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.ConcurrentCircularArrayQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.ConcurrentSequencedCircularArrayQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.MpmcArrayQueueConsumerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.MpmcArrayQueueProducerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.MpscLinkedQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpmcArrayQueueConsumerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpmcArrayQueueProducerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpscArrayQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpscUnboundedArrayQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.UnsafeAccess: can't find referenced class sun.misc.Unsafe
Warning:there were 145 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 ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details
Information:BUILD FAILED
Information:Total time: 19.342 secs
Information:1 error
Information:69 warnings
Information:See complete output in console

这是我的proguard-rules.pro文件:

-keep public class com.mikepenz.fastadapter
-keep public class com.squareup.picasso
-keep public class rx.internal.util.unsafe

这是build.gradle文件:

apply plugin: 'com.android.application'

//Put Fabric plugin after Android plugin
apply plugin: 'io.fabric'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"

    defaultConfig {
        applicationId "com.abc.xxx"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "0.1"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    repositories {
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
        maven { url 'https://maven.fabric.io/public' }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile('com.mikepenz:fastadapter:1.8.2@aar') {
        transitive = true
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
        transitive = true;
    }
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:design:25.0.0'
    compile 'com.android.support:cardview-v7:25.0.0'
    compile 'com.android.support:recyclerview-v7:25.0.0'
    compile 'com.mikepenz:fastadapter-extensions:1.8.0@aar'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.google.android.gms:play-services:10.2.0'
    compile 'com.google.android.gms:play-services-location:10.2.0'
    compile 'com.google.firebase:firebase-auth:10.2.0'
    compile 'com.android.support:support-v4:25.0.0'
    compile 'com.google.firebase:firebase-database:10.2.0'
    compile 'com.firebase:geofire-android:2.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.firebase:firebase-storage:10.2.0'
    compile 'com.google.firebase:firebase-core:10.2.0'
    compile 'com.google.firebase:firebase-invites:10.2.0'
    compile 'hani.momanii.supernova_emoji_library:supernova-emoji-library:0.0.2'
    compile 'me.himanshusoni.chatmessageview:chat-message-view:1.0.3'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.firebaseui:firebase-ui:0.4.1'
    compile 'pl.charmas.android:android-reactive-location:0.10@aar'
    compile 'io.reactivex:rxjava:1.2.0'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.android.support:support-vector-drawable:25.0.0'
    compile 'com.github.coyarzun89:fabtransitionactivity:0.2.0'
    compile 'org.adw.library:discrete-seekbar:1.0.1'
    compile 'com.codemybrainsout.rating:ratingdialog:1.0.7'
    compile 'com.github.paolorotolo:appintro:4.1.0'
    testCompile 'junit:junit:4.12'
}

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

为什么我会收到这些警告和错误,我该如何摆脱它们?

我尝试在网上搜索并在此处阅读此文档,但我仍然无法弄清楚。

请帮我解决一下这个。

4

2 回答 2

1

您的问题似乎包括毕加索使用的 okhttp 的 proguard 异常。添加

# OkHttp
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**

有关您可能正在使用的其他库的 proguard 配置,请参见此处。

于 2017-03-02T11:55:50.513 回答
1

为了

Warning:com.mikepenz.fastadapter_extensions.items.SingleLineItem:

应用以下规则

-keep class com.mikepenz.materialize.holder.** { *; }

从评论讨论@user1140237 它为mikepenz 库解决了这个问题,但是Warning:rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeR‌​ef: can't find referenced class sun.misc.Unsafe 和相关警告呢?

添加以下规则

-dontwarn sun.misc.Unsafe
-dontwarn com.google.common.collect.MinMaxPriorityQueue

检查这个链接它我的帮助你

对于 ok http 或 square 相关,请遵循 JohnWowUs 给出的答案

于 2017-03-02T12:27:47.337 回答