gpt4 book ai didi

Android 使用 Parse.com - Proguard 上缺少类

转载 作者:行者123 更新时间:2023-12-05 00:22:02 25 4
gpt4 key购买 nike

我在一个项目上使用 Parse。该项目使用我自己的 Android 库项目,其中包含 Parse jar。当我尝试生成签名的 apk 时,gradle 会出现以下问题:

:exampleApp:proguardRelease Warning: com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find superclass or interface com.squareup.okhttp.RequestBody 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.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Call Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.ResponseBody Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.ResponseBody Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Headers$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Headers$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Headers$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Headers$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Headers$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Headers Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Call Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.ResponseBody Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Headers Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Call Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Call Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Call Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Headers$Builder Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Headers Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Request Warning: com.parse.ParseOkHttpClient: can't find referenced class com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient$1: can't find referenced class com.squareup.okhttp.Call Warning: com.parse.ParseOkHttpClient$1: can't find referenced class com.squareup.okhttp.Call Warning: com.parse.ParseOkHttpClient$1: can't find referenced class com.squareup.okhttp.Call Warning: com.parse.ParseOkHttpClient$1: can't find referenced class com.squareup.okhttp.Call Warning: com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find referenced class com.squareup.okhttp.RequestBody Warning: com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find referenced class com.squareup.okhttp.MediaType Warning: com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find referenced class okio.BufferedSink Warning: com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find referenced class com.squareup.okhttp.RequestBody Warning: com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find referenced class com.squareup.okhttp.MediaType Warning: com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find referenced class okio.BufferedSink Warning: com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find referenced class com.squareup.okhttp.MediaType Warning: com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find referenced class okio.BufferedSink Warning: com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find referenced class okio.BufferedSink Warning: there were 67 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) :exampleApp:proguardRelease FAILED

FAILURE: Build failed with an exception.



编辑:
根据@karama 的建议,我将此添加到我的 proguard 规则中:
-keepattributes *Annotation*
-keepattributes Signature
-dontwarn com.squareup.**
-keep class com.squareup.** { *; }

-dontwarn com.parse.ParseOkHttpClient**
-keep class com.parse.ParseOkHttpClient** { *; }

# Proguard configuration for Jackson 2.x (fasterxml package instead of codehaus package)
-keep class com.fasterxml.jackson.databind.ObjectMapper {
public <methods>;
protected <methods>;
}
-keep class com.fasterxml.jackson.databind.ObjectWriter {
public ** writeValueAsString(**);
}
-dontwarn 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.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: there were 5 unresolved references to classes or interfaces.



如果我通过添加来修复它:
-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry
当应用程序运行时,它会崩溃。我在这里看到了这个问题,但没有解决方法: https://stackoverflow.com/a/11249755/197127

使用 -dontobfuscate 运行应用程序可以正常工作。

最佳答案

该错误不是 parse sdk 的错误,它是因为 okHttp 而发生的。在您的 proguard 中添加以下行。

-keepattributes *Annotation*
-keepattributes Signature
-dontwarn com.squareup.**
-keep class com.squareup.** { *; }

编辑

对于 com.fasterxml.jackson 添加以下代码:
-keep class com.fasterxml.jackson.databind.ObjectMapper {
public <methods>;
protected <methods>;
}
-keep class com.fasterxml.jackson.databind.ObjectWriter {
public ** writeValueAsString(**);
}

引用: https://github.com/krschultz/android-proguard-snippets/issues/19

关于Android 使用 Parse.com - Proguard 上缺少类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30680868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com