从 3.1.4 升级到 Android Gradle 插件到 3.2.x 后,我收到多个警告,例如:
D8: Type `com.google.gson.reflect.TypeToken` was not found, it is required for default or static interface methods desugaring of `com.google.gson.reflect.TypeToken org.springframework.http.converter.json.GsonHttpMessageConverter.getTypeToken(java.lang.reflect.Type)`
D8: Type `com.squareup.okhttp.MediaType` was not found, it is required for default or static interface methods desugaring of `com.squareup.okhttp.MediaType org.springframework.http.client.OkHttpClientHttpRequest.getContentType(org.springframework.http.HttpHeaders)`
D8: Type `org.apache.http.impl.client.HttpClients` was not found, it is required for default or static interface methods desugaring of `void org.springframework.http.client.HttpComponentsClientHttpRequestFactory.<init>()`
D8: Interface `org.apache.http.HttpEntity` not found. It's needed to make sure desugaring of `org.springframework.http.client.HttpComponentsStreamingClientHttpRequest$StreamingHttpEntity` is correct. Desugaring will assume that this interface has no default method.
D8: Type `org.conscrypt.Conscrypt` was not found, it is required for default or static interface methods desugaring of `okhttp3.internal.platform.Platform okhttp3.internal.platform.ConscryptPlatform.buildIfSupported()`
...
项目正在使用 Java 1.8 源代码兼容性 (lambdas),看起来警告来自 Android gradle 类 dexer,它已在 AGP 3.2.0 中默认启用。
我试图
proguard-rules.pro
用以下几行来抑制这些警告,但似乎没有任何效果。-dontwarn com.google.gson.reflect.TypeToken -keep class com.google.gson.reflect.TypeToken { *; } -dontwarn org.apache.http.** -keep class com.squareup.okhttp.** { *; } -dontwarn com.squareup.okhttp.** -keep class org.springframework.http.client.** { *; } -dontwarn org.springframework.http.client.**
我可以使警告消失的唯一方法是在文件中设置
minifyEnabled
和useProguard
false
build.gradle
我试过 AGP 3.3.0-alpha13 和新的 AGP 3.2.1 但没有成功。