web-dev-qa-db-ja.com

ProGuardビルドが「未解決の参照」に失敗する

私は自分のアプリの最新バージョンに取り組んでおり、それは問題なくテストされますが、リリースProGuardビルドを実行すると、多くのエラーが発生します。ほとんどの場合、使用していないorg.Apache.http.*が見つかりません。私のプロジェクトで。プロジェクト全体でそのテキストを検索しましたが、見つかりません。いくつかの依存関係を追加しましたが、HTTPを使用する依存関係はありませんthink

why 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;
}
11
NSouth

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

これがあなたの問題の解決にも役立つかどうか教えてください。

18

アプリが古いApacheHttpClientを使用している場合は、build.gradleファイルに次を追加する必要があります。

useLibrary'org.Apache.http.legacy '

ここで説明されているように: https://www.youtube.com/watch?v=yYU4DHLwoRk

1
Ozzz