creator 2.4.6 发布google play的时候有兼容性问题 okhttp3

我查了下 说是 okhttp3的问题,虽然自己测试还有云测都没影响到游戏的样子。但是看着很膈应,
查了下说升级 okhttp3可以解决,有没有大佬教教怎么搞?

直接把 okhttp-3.12.7.jar 换了重新构建行?

Android 兼容性 使用公共 Android SDK 中没有的 API 可能会导致您的应用无法运行。我们的测试可能无法找出所有不受支持的 API。系统仅会显示非重复堆栈轨迹。
API Lcom/android/org/conscrypt/ConscryptEngineSocket;->setHostname(Ljava/lang/String;)V
第 1 个堆栈轨迹 StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Lcom/android/org/conscrypt/ConscryptEngineSocket;->setHostname(Ljava/lang/String;)V
“StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Lcom/android/org/conscrypt/ConscryptEngineSocket;->setHostname(Ljava/lang/String;)V
at android.os.StrictMode.lambda$static$1(StrictMode.java:416)
at android.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(Unknown Source:2)
at java.lang.Class.getDeclaredMethodInternal(Native Method)
at java.lang.Class.getPublicMethodRecursive(Class.java:2079)
at java.lang.Class.getMethod(Class.java:2066)
at java.lang.Class.getMethod(Class.java:1693)
at org.cocos2dx.okhttp3.internal.platform.d.a(SourceFile:164)
at org.cocos2dx.okhttp3.internal.platform.d.a(SourceFile:149)
at org.cocos2dx.okhttp3.internal.platform.d.a(SourceFile:66)
at org.cocos2dx.okhttp3.internal.platform.d.b(SourceFile:86)
at org.cocos2dx.okhttp3.internal.platform.a.configureTlsExtensions(SourceFile:123)
at org.cocos2dx.okhttp3.internal.connection.RealConnection.connectTls(SourceFile:315)
at org.cocos2dx.okhttp3.internal.connection.RealConnection.establishProtocol(SourceFile:284)
at org.cocos2dx.okhttp3.internal.connection.RealConnection.connect(SourceFile:169)
at org.cocos2dx.okhttp3.internal.connection.StreamAllocation.findConnection(SourceFile:258)
at org.cocos2dx.okhttp3.internal.connection.StreamAllocation.findHealthyConnection(SourceFile:135)
at org.cocos2dx.okhttp3.internal.connection.StreamAllocation.newStream(SourceFile:114)
at org.cocos2dx.okhttp3.internal.connection.ConnectInterceptor.intercept(SourceFile:42)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:147)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:121)
at org.cocos2dx.okhttp3.internal.cache.CacheInterceptor.intercept(SourceFile:93)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:147)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:121)
at org.cocos2dx.okhttp3.internal.http.BridgeInterceptor.intercept(SourceFile:93)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:147)
at org.cocos2dx.okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(SourceFile:127)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:147)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:121)
at org.cocos2dx.okhttp3.a.e(SourceFile:257)
at org.cocos2dx.okhttp3.a$a.execute(SourceFile:201)
at org.cocos2dx.okhttp3.internal.NamedRunnable.run(SourceFile:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)”

API Lcom/android/org/conscrypt/ConscryptEngineSocket;->setUseSessionTickets(Z)V
第 1 个堆栈轨迹 "
StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Lcom/android/org/conscrypt/ConscryptEngineSocket;->setUseSessionTickets(Z)V"
“StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Lcom/android/org/conscrypt/ConscryptEngineSocket;->setUseSessionTickets(Z)V
at android.os.StrictMode.lambda$static$1(StrictMode.java:416)
at android.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(Unknown Source:2)
at java.lang.Class.getDeclaredMethodInternal(Native Method)
at java.lang.Class.getPublicMethodRecursive(Class.java:2079)
at java.lang.Class.getMethod(Class.java:2066)
at java.lang.Class.getMethod(Class.java:1693)
at org.cocos2dx.okhttp3.internal.platform.d.a(SourceFile:164)
at org.cocos2dx.okhttp3.internal.platform.d.a(SourceFile:149)
at org.cocos2dx.okhttp3.internal.platform.d.a(SourceFile:66)
at org.cocos2dx.okhttp3.internal.platform.d.b(SourceFile:86)
at org.cocos2dx.okhttp3.internal.platform.a.configureTlsExtensions(SourceFile:122)
at org.cocos2dx.okhttp3.internal.connection.RealConnection.connectTls(SourceFile:315)
at org.cocos2dx.okhttp3.internal.connection.RealConnection.establishProtocol(SourceFile:284)
at org.cocos2dx.okhttp3.internal.connection.RealConnection.connect(SourceFile:169)
at org.cocos2dx.okhttp3.internal.connection.StreamAllocation.findConnection(SourceFile:258)
at org.cocos2dx.okhttp3.internal.connection.StreamAllocation.findHealthyConnection(SourceFile:135)
at org.cocos2dx.okhttp3.internal.connection.StreamAllocation.newStream(SourceFile:114)
at org.cocos2dx.okhttp3.internal.connection.ConnectInterceptor.intercept(SourceFile:42)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:147)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:121)
at org.cocos2dx.okhttp3.internal.cache.CacheInterceptor.intercept(SourceFile:93)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:147)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:121)
at org.cocos2dx.okhttp3.internal.http.BridgeInterceptor.intercept(SourceFile:93)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:147)
at org.cocos2dx.okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(SourceFile:127)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:147)
at org.cocos2dx.okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:121)
at org.cocos2dx.okhttp3.a.e(SourceFile:257)
at org.cocos2dx.okhttp3.a$a.execute(SourceFile:201)
at org.cocos2dx.okhttp3.internal.NamedRunnable.run(SourceFile:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)”

同个问题 解决了吗?

同问。 解决了吗?

同问,解决了吗?

看来没能解决

引擎的 okhttp3跟 普通的okhttp3不是一回事,包名都不一样,可以共存

最近也在折腾这个,有点儿疼。

参考 这里,重新编译出 jar 替换即可。
或直接用我编译的这个版本:okhttp-3.14.9.jarokio-1.17.3.jar

但是需要 minSDKVersion 30 且 gradle 需添加(反正上架 Google play 也是需要的):

compileOptions {
    targetCompatibility JavaVersion.VERSION_1_8
    sourceCompatibility JavaVersion.VERSION_1_8
}

okhttp 官方在 Version 3.12.9 版本修复了这个问题, 见日志
而最终选择了 okhttp-3.14.9 是因为用 jdk11 跑 mvn 这个版本最顺利。

也可以将 okhttp 官方的修复比对后合并到 creator 引擎组开发人员 @397136899repo 中,太麻烦,实在不想折腾了。

希望官方能解决一下,毕竟 okhttp-3.14.9 需要的 minSDKVersion 太高。
而且这种重命名 package 的方式,也非常不方便三方库的后续升级。@jare

2赞

configurations {
// all*.exclude group: ‘com.google.code.gson’
all*.exclude group: ‘com.squareup.okhttp3’
all*.exclude group: ‘com.squareup.okio’
// all*.exclude group: ‘com.android.support’,module:‘support-v13’
}

谢谢反馈1

okhttp 已升级到 3.12.14, 参见PR https://github.com/cocos-creator/engine-native/pull/4264

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。