Сбой сборки ProGuard Неразрешенные ссылки

Я работаю над новейшей версией своего приложения, и оно отлично тестируется, но когда я делаю выпускную сборку ProGuard, я получаю много ошибок, в основном о том, что не могу найти org.apache.http.*, который я не использую в своем проекте. Я искал весь свой проект для этого текста и не могу найти его. Я добавил несколько зависимостей, но ни одна из них, думаю, не будет использовать HTTP.

Как понять, почему ProGuard жалуется, и как правильно решить эту проблему? В нем говорится, что я могу запустить «с опцией --stacktrace», но я не могу понять, как это сделать.

Я ценю любую помощь, так как ProGuard часто сбивает меня с толку.

Выход сборки:

Warning: com.google.android.gms.internal.zzw$zza: can't find superclass or interface org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning: com.google.android.gms.analytics.internal.zzam: can't find referenced class org.apache.http.NameValuePair
Warning: com.google.android.gms.analytics.internal.zzam: can't find referenced class org.apache.http.client.utils.URLEncodedUtils
Warning: com.google.android.gms.analytics.internal.zzam: can't find referenced class org.apache.http.client.utils.URLEncodedUtils
Warning: com.google.android.gms.analytics.internal.zzam: can't find referenced class org.apache.http.NameValuePair
Warning: com.google.android.gms.analytics.internal.zzam: can't find referenced class org.apache.http.NameValuePair
Warning: com.google.android.gms.analytics.internal.zzj: can't find referenced class org.apache.http.NameValuePair
Warning: com.google.android.gms.analytics.internal.zzj: can't find referenced class org.apache.http.client.utils.URLEncodedUtils
Warning: com.google.android.gms.analytics.internal.zzj: can't find referenced class org.apache.http.client.utils.URLEncodedUtils
Warning: com.google.android.gms.analytics.internal.zzj: can't find referenced class org.apache.http.NameValuePair
Warning: com.google.android.gms.analytics.internal.zzj: can't find referenced class org.apache.http.NameValuePair
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification
Warning: com.google.android.gms.internal.zzac: can't find referenced class android.net.http.AndroidHttpClient
Warning: com.google.android.gms.internal.zzac: can't find referenced class android.net.http.AndroidHttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.StatusLine
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.methods.HttpGet
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.conn.ClientConnectionManager
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.params.BasicHttpParams
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.methods.HttpGet
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.params.BasicHttpParams
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.StatusLine
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.conn.ClientConnectionManager
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.Header
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.Header
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.StatusLine
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.impl.cookie.DateUtils
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.impl.cookie.DateUtils
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.Header
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.Header
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.StatusLine
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.StatusLine
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.StatusLine
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.Header
Warning: com.google.android.gms.internal.zzt: can't find referenced class org.apache.http.Header
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpDelete
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpGet
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpHead
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpOptions
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpPost
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpPut
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpTrace
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.entity.ByteArrayEntity
Warning: com.google.android.gms.internal.zzw: can't find referenced method 'void addHeader(java.lang.String,java.lang.String)' in program class com.google.android.gms.internal.zzw$zza
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpDelete
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpGet
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpHead
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpOptions
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpPost
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpPost
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpPost
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpPut
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpPut
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpTrace
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.entity.ByteArrayEntity
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning: com.google.android.gms.internal.zzw: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning: com.google.android.gms.internal.zzw$zza: can't find referenced class org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning: com.google.android.gms.internal.zzw$zza: can't find referenced method 'void setURI(java.net.URI)' in program class com.google.android.gms.internal.zzw$zza
Warning: com.google.android.gms.internal.zzw$zza: can't find referenced class org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning: com.google.android.gms.internal.zzx: can't find referenced class org.apache.http.impl.cookie.DateParseException
Warning: com.google.android.gms.internal.zzx: can't find referenced class org.apache.http.impl.cookie.DateUtils
Warning: com.google.android.gms.internal.zzx: can't find referenced class org.apache.http.impl.cookie.DateUtils
Warning: com.google.android.gms.internal.zzy: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzy: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.ProtocolVersion
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.entity.BasicHttpEntity
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.message.BasicHeader
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.message.BasicHttpResponse
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.message.BasicStatusLine
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.ProtocolVersion
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.entity.BasicHttpEntity
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.entity.BasicHttpEntity
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.entity.BasicHttpEntity
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.entity.BasicHttpEntity
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.entity.BasicHttpEntity
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.message.BasicHeader
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.message.BasicHttpResponse
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.message.BasicHttpResponse
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.message.BasicHttpResponse
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.message.BasicStatusLine
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzz: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.tagmanager.zzby: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning: com.google.android.gms.tagmanager.zzby: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.Header
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpHost
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.StatusLine
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.client.ClientProtocolException
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.message.BasicHttpEntityEnclosingRequest
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpHost
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpHost
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.message.BasicHttpEntityEnclosingRequest
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.StatusLine
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest
Warning: there were 148 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: there were 1 unresolved references to library class members.
         You probably need to update the library versions.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
:GradeTrackerPro:proguardRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':MyApp:proguardRelease'.
> java.io.IOException: Please correct the above warnings first.

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

BUILD FAILED

Из моего файла Gradle:

android {
    compileSdkVersion 23
    buildToolsVersion "23"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')


        buildTypes {
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'),
                        'proguard-rules.pro'
            }
        }

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }


    // to ignore warnings and strings not converted to all languages
    android {
        lintOptions {
            checkReleaseBuilds false
            // Or, if you prefer, you can continue to check for errors in release builds,
            // but continue the build even when errors are found:
            abortOnError false
        }
    }

Мой proguard-rules.pro файл:

-keep class !android.support.v7.internal.view.menu.MenuBuilder, !android.support.v7.internal.view.menu.SubMenuBuilder, android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
-dontwarn com.opencsv.bean.**

-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable  # these last two lines keep info for debugging

# added these because proguard was complaining. Not sure where they could be referenced!



# For Flurry
-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
-keepattributes *Annotation*, EnclosingMethod
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int) ;
}
# Google Play Services library
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents() ;
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}

person NSouth    schedule 25.09.2015    source источник
comment
Пожалуйста, ознакомьтесь с проблемой № 3001: проблемы PlayServices с прогард   -  person JJD    schedule 26.09.2015
comment
возможный дубликат Proguard и ошибка   -  person JJD    schedule 26.09.2015
comment
это действительно простая проблема для решения. см. мой ответ здесь: stackoverflow.com/a/34483791/4538504   -  person hadi    schedule 28.12.2015


Ответы (2)


Я никогда не сталкивался с этой проблемой до обновления buildTool до 23.0. Единственный обходной путь, который я мог видеть с этой новой версией инструментов сборки для моего приложения, заключался в том, что вам нужно добавить это в свой файл Progaurd.txt.

-dontwarn android.support.v4.**
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**

Если вы используете Apache Http в своем проекте, вам также необходимо включить следующие строки:

-keepnames class org.apache.** {*;}
-keep public class org.apache.** {*;}    
-dontwarn org.apache.commons.logging.LogFactory
-dontwarn org.apache.http.annotation.ThreadSafe
-dontwarn org.apache.http.annotation.Immutable
-dontwarn org.apache.http.annotation.NotThreadSafe

Дайте мне знать, поможет ли это решить и вашу проблему.

person Haresh Chaudhary    schedule 03.10.2015
comment
У меня была такая же проблема после обновления 23.0, и -dontwarn com.google.android.gms.** исправил ее. Мне не нужны были другие. Спасибо - person Shine; 14.10.2015
comment
@Shine На самом деле вам нужно добавить эти другие строки, только если вы все еще используете старую библиотеку Apache Http для сетевых вызовов. Я дополнительно уточнил в ответе. Спасибо, что указали. - person Haresh Chaudhary; 14.10.2015
comment
Зачем вам нужен public для com.google.android.gms? - person IgorGanapolsky; 31.10.2016
comment
У меня все еще есть проблема с Warning:twitter4j.TwitterAPIMonitor и Warning:com.squareup.picasso, как я могу ее решить? - person natsumiyu; 08.11.2016

Вы должны добавить в свой файл build.gradle следующее, если ваше приложение использует старый apache HttpClient:

useLibrary 'org.apache.http.legacy'

как описано здесь: https://www.youtube.com/watch?v=yYU4DHLwoRk.

person Ozzz    schedule 05.10.2015
comment
Я уже поставил org.apache.http.legacy в свой build.gradle, но у меня все еще есть ошибки - person natsumiyu; 08.11.2016