在将Android Gradle插件从3.1.4升级到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源代码兼容性(lambda),看起来警告来自于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.**
我能让警告消失的唯一方法是在
build.gradle
文件中将minifyEnabled
和useProguard
设置为false
我已经尝试了AGP 3.3.0-alpha13和新的AGP 3.2.1,但都没有成功。
您可以从https://github.com/mdawid/D8WarningTest克隆带有示例项目的存储库