对于我来说,当使用方法(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/