neo*_*ion 6 android proguard gradle
我正在构建一个 Android 项目,该项目有一些使用 Proguard 的 buildType。在构建过程中,我看到来自 Proguard 的大量警告。因为这些警告是为我正在使用的第三方类生成的,所以我试图在我的“proguard-rules.pro”文件中使用 -dontwarn 标志和 -dontnote 标志,这样我以后就不会看到错误输出. 但是,我看到的问题是,即使在我将这些标志添加到我的 .pro 文件并在 build.gradle 中指定 .pro 文件之后,我仍然会在构建项目时看到警告输出。
这是 build.gradle 文件的相关部分:
buildTypes {
debug {
applicationIdSuffix ".debug"
}
unitTest {
applicationIdSuffix ".unittest"
minifyEnabled true
// proguardFiles getDefaultProguardFile("proguard-android.txt")
proguardFile('proguard-rules.pro')
}
automation {
applicationIdSuffix ".automation"
minifyEnabled true
// proguardFile getDefaultProguardFile('proguard-android.txt')
proguardFile('proguard-rules.pro')
}
internal {
applicationIdSuffix ".internal"
minifyEnabled true
// proguardFiles getDefaultProguardFile('proguard-android.txt')
proguardFile('proguard-rules.pro')
}
release {
minifyEnabled true
// proguardFiles getDefaultProguardFile("proguard-android.txt")
proguardFile("proguard-rules.pro")
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 proguard-rules.pro 文件:
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Disabling obfuscation is useful if you collect stack traces from production crashes
# (unless you are using a system that supports de-obfuscate the stack traces).
-dontobfuscate
# React Native
# Keep our interfaces so they can be used by other ProGuard rules.
# See http://sourceforge.net/p/proguard/bugs/466/
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
# Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.proguard.annotations.DoNotStrip class *
-keepclassmembers class * {
@com.facebook.proguard.annotations.DoNotStrip *;
}
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
void set*(***);
*** get*();
}
-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
-dontwarn com.facebook.react.**
# okhttp
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
# okio
-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**
# stetho
-dontwarn com.facebook.stetho.**
##ADDED TO GET WARNINGS TO GO AWAY BUT NEEDS TO BE EVALED BEFORE RELEASE
-dontnote junit.runner.*
-dontnote junit.framework.*
-dontwarn org.hamcrest.**
-dontwarn android.support.test.**
Run Code Online (Sandbox Code Playgroud)
请注意, proguard-rules.pro 文件位于我的 project/app/ 目录中,在引用它的 build.gradle 文件旁边。
这是 gradle 错误输出的片段:
Note: duplicate definition of library class [junit.runner.Version]
Note: duplicate definition of library class [junit.runner.BaseTestRunner]
Note: duplicate definition of library class [junit.framework.Protectable]
Note: duplicate definition of library class [junit.framework.Assert]
Note: duplicate definition of library class [junit.framework.TestSuite]
Note: duplicate definition of library class [junit.framework.Test]
Note: duplicate definition of library class [junit.framework.ComparisonFailure]
Note: duplicate definition of library class [junit.framework.TestFailure]
Note: duplicate definition of library class [junit.framework.TestCase]
Note: duplicate definition of library class [junit.framework.AssertionFailedError]
Note: duplicate definition of library class [junit.framework.TestListener]
Note: duplicate definition of library class [junit.framework.TestResult]
Reading library jar [/Users/dhodapp/Library/Android/sdk/platforms/android-23/optional/org.apache.http.legacy.jar]
Note: duplicate definition of library class [android.net.http.SslCertificate]
Note: duplicate definition of library class [android.net.http.SslError]
Note: duplicate definition of library class [android.net.http.SslCertificate$DName]
Note: duplicate definition of library class [org.apache.http.conn.scheme.SocketFactory]
Note: duplicate definition of library class [org.apache.http.conn.scheme.HostNameResolver]
Note: duplicate definition of library class [org.apache.http.conn.ConnectTimeoutException]
Note: duplicate definition of library class [org.apache.http.params.HttpParams]
Note: there were 19 duplicate class definitions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning: org.hamcrest.integration.EasyMock2Adapter: can't find superclass or interface org.easymock.IArgumentMatcher
Warning: org.hamcrest.integration.JMock1Adapter: can't find superclass or interface org.jmock.core.Constraint
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
Run Code Online (Sandbox Code Playgroud)
当我应用 proguard-rules.pro 文件时,为什么错误消息没有被压缩?
| 归档时间: |
|
| 查看次数: |
1884 次 |
| 最近记录: |