android - Android 12 中的异常

标签 android retrofit2 okhttp android-12

对于我来说,当使用方法(chain.proceed(request))时,出现了一个问题,即以下错误。

我的错误发生在 Android 12 中

我使用改造

class CustomInterceptor implements Interceptor {
    @NonNull
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request ();
        return chain.proceed (request);
    }
}

异常

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

最佳答案

我今天也遇到了同样的问题。根本问题不是 okHttp/Retrofit,而是 Gander,我在应用程序中使用的 Http 检查库。该库不再维护,这意味着它们不支持 Android 12。我想我必须切换到 Chucker 或其他替代方案。

如果您提供完整的堆栈跟踪,我们可以看到哪个库真正导致了您的问题。删除或更新该库可能会对您有所帮助。

另请参阅 OkHttp GitHub 存储库中的问题:https://github.com/square/okhttp/issues/7034 。 OkHttp/Retrofit 的开发人员在他们的回复中确保这两个库不是问题。

关于android - Android 12 中的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70850929/

相关文章:

java - 如何在 Android 上以编程方式自动接听来电

javascript - Cordova 安卓 : Getting 404 error in angular js app

android - 使用 OKHttp 创建适当的 MultipartBuilder Http 请求

android - AndroidEmoji-htc.ttf 文件中的表情符号图像是如何编码的?

java - Retrofit2 安卓 : Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

java - Retrofit2 HTTP 获取 Json 到 RecyclerView

android - 阵列适配器不更新

android - 如何等待 Okhttp 调用的结果以在测试中使用它?

android - 如何在 libgdx 中使用网络框架(volley、okhttp 等)?

Android PIN 或模式更改监听器