我正在尝试构建我的apk并在发布版本类型中启用了以下标志

  • minifyEnabled是的

  • shrinkResources为true

在构建apk以供发布时,我收到来自proguard的警告,最终我的构建失败(见下文) .

我尝试通过在proguard pro文件中添加以下内容来禁止警告

-dontwarn android.test . ** -dontwarn com.amazonaws . ** -dontwarn com.android.volley . ** -dontwarn com.fasterxml.jackson . ** -dontwarn com.viewpagerindicator . ** -dontwarn okio . * * -dontwarn org.joda.time . ** -dontwarn se.walkercrou . ** -dontwarn org.codehaus.mojo . **

在此之后,我能够生成APK但是当我尝试在我的手机中启动APK时它会在启动时崩溃 .

然后我甚至探讨了,我们可以添加

-libraryjars'path / to / jar / file.jar'但是在这里,如果它们在通过Gradle下载的第三方库中,如何找到jar的路径 .

Following are build errors:

:app:proguardRelease
Note: there were 12 duplicate class definitions.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning: library class android.test.AndroidTestCase extends or implements program class junit.framework.TestCase
Warning: library class android.test.AndroidTestRunner extends or implements program class junit.runner.BaseTestRunner
Warning: library class android.test.InstrumentationTestCase extends or implements program class junit.framework.TestCase
Warning: library class android.test.InstrumentationTestSuite extends or implements program class junit.framework.TestSuite
Warning: library class android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests extends or implements program class junit.framework.TestCase
Warning: com.amazonaws.http.HttpClientFactory: can't find referenced method 'void setHttpRequestRetryHandler(org.apache.http.client.HttpRequestRetryHandler)' in program class com.amazonaws.http.impl.client.SdkHttpClient
Warning: com.amazonaws.http.HttpClientFactory: can't find referenced method 'void setRedirectHandler(org.apache.http.client.RedirectHandler)' in program class com.amazonaws.http.impl.client.SdkHttpClient
Warning: com.amazonaws.http.HttpClientFactory: can't find referenced method 'org.apache.http.conn.ClientConnectionManager getConnectionManager()' in program class com.amazonaws.http.impl.client.SdkHttpClient
Warning: com.amazonaws.http.HttpClientFactory: can't find referenced method 'org.apache.http.params.HttpParams getParams()' in program class com.amazonaws.http.impl.client.SdkHttpClient
Warning: com.amazonaws.http.HttpClientFactory: can't find referenced method 'org.apache.http.client.CredentialsProvider getCredentialsProvider()' in program class com.amazonaws.http.impl.client.SdkHttpClient
Warning: com.amazonaws.http.RepeatableInputStreamRequestEntity: can't find referenced method 'void setChunked(boolean)' in program class com.amazonaws.http.RepeatableInputStreamRequestEntity
Warning: com.amazonaws.http.RepeatableInputStreamRequestEntity: can't find referenced method 'void setContent(java.io.InputStream)' in program class com.amazonaws.http.RepeatableInputStreamRequestEntity
Warning: com.amazonaws.http.RepeatableInputStreamRequestEntity: can't find referenced method 'void setContentType(java.lang.String)' in program class com.amazonaws.http.RepeatableInputStreamRequestEntity
Warning: com.amazonaws.http.RepeatableInputStreamRequestEntity: can't find referenced method 'void setContentLength(long)' in program class com.amazonaws.http.RepeatableInputStreamRequestEntity
Warning: com.amazonaws.metrics.MetricInputStreamEntity: can't find referenced method 'java.io.InputStream getContent()' in program class com.amazonaws.metrics.MetricInputStreamEntity
Warning: com.amazonaws.metrics.MetricInputStreamEntity: can't find referenced method 'long getContentLength()' in program class com.amazonaws.metrics.MetricInputStreamEntity
Warning: com.android.volley.toolbox.HttpClientStack: can't find referenced method 'void addHeader(java.lang.String,java.lang.String)' in program class com.android.volley.toolbox.HttpClientStack$HttpPatch
Warning: com.android.volley.toolbox.HttpClientStack$HttpPatch: can't find referenced method 'void setURI(java.net.URI)' in program class com.android.volley.toolbox.HttpClientStack$HttpPatch
Warning: com.android.volley.toolbox.Volley: can't find referenced class android.net.http.AndroidHttpClient
Warning: com.android.volley.toolbox.Volley: can't find referenced class android.net.http.AndroidHttpClient
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.viewpagerindicator.LinePageIndicator: can't find referenced method 'float ceil(float)' in library class android.util.FloatMath
Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: org.joda.time.DateMidnight: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.DateTime: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.DateTimeZone: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.DateTimeZone: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.Days: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.Days: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.Duration: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.Hours: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.Hours: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.Instant: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.LocalDate: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.LocalDate: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.LocalDateTime: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.LocalDateTime: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.LocalTime: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.LocalTime: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.Minutes: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.Minutes: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.MonthDay: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.MonthDay: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.Months: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.Months: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.MutableDateTime: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.MutablePeriod: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.Period: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.Seconds: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.Seconds: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.Weeks: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.Weeks: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.YearMonth: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.YearMonth: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.Years: can't find referenced class org.joda.convert.FromString
Warning: org.joda.time.Years: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.base.AbstractDateTime: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.base.AbstractDuration: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.base.AbstractInstant: can't find referenced class org.joda.convert.ToString
Warning: org.joda.time.base.AbstractPeriod: can't find referenced class org.joda.convert.ToString
Warning: se.walkercrou.places.Photo: can't find referenced class javax.imageio.ImageIO
Warning: se.walkercrou.places.Photo: can't find referenced class javax.imageio.ImageIO
Warning: se.walkercrou.places.Photo: can't find referenced class java.awt.image.BufferedImage
Warning: se.walkercrou.places.Place: can't find referenced class javax.imageio.ImageIO
Warning: se.walkercrou.places.Place: can't find referenced class javax.imageio.ImageIO
Warning: se.walkercrou.places.Place: can't find referenced class java.awt.image.BufferedImage
Warning: there were 63 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 5 instances of library classes depending on program classes.
         You must avoid such dependencies, since the program classes will
         be processed, while the library classes will remain unchanged.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#dependency)
Warning: there were 13 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)
:app:proguardRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app: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