gpt4 book ai didi

java - 使用来自 Square 的最新 jar 的问题 - retrofit、okhttp、okio 和 okhttp-urlconnection

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:55:21 29 4
gpt4 key购买 nike

我为我正在开发的功能引入了以下 Square jars:

  • okttp-2.0.0
  • okhttp-urlconnection-2.0.0.jar
  • okio-1.0.0.jar
  • retrofit-1.6.1.jar

我从中央 Maven 仓库下载了这些。

在本地一切正常,我将我的代码提交给 svn。我们有一个生成调试和发布版本的 Jenkins CI 服务器。这失败了。

我的本​​地环境和 Jenkins 有很多不同:

  • 我在本地运行 java 8,Jenkins 运行 java 6
  • 在本地我只生成调试版本,Jenkins 生成调试版本和发布版本
  • 本地我有构建工具版本 22.6.2,Jenkins 运行 18.0.1

这些是我在 Jenkins 日志中看到的问题:

    -compile:
[javac] Compiling 545 source files to /var/lib/jenkins/jobs/Planner_4_10_Retrofit/workspace/Planner_4_10_Retrofit/bin/classes
[javac] warning: /var/lib/jenkins/jobs/Planner_4_10_Retrofit/workspace/Planner_4_10_Retrofit/libs/okhttp-2.0.0.jar(com/squareup/okhttp/OkHttpClient.class): major version 51 is newer than 50, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.

[dex] Pre-Dexing /var/lib/jenkins/jobs/Planner_4_10_Retrofit/workspace/Planner_4_10_Retrofit/libs/okhttp-urlconnection-2.0.0.jar -> okhttp-urlconnection-2.0.0-5f923d75acdde39a4616800eb222e1bf.jar
[dx]
[dx] trouble processing:
[dx] bad class file magic (cafebabe) or version (0033.0000)
[dx] ...while parsing com/squareup/okhttp/internal/huc/CacheAdapter.class
[dx] ...while processing com/squareup/okhttp/internal/huc/CacheAdapter.class

[proguard] Initializing...
[proguard] Warning: retrofit.RxSupport$1: can't find superclass or interface rx.Observable$OnSubscribe
[proguard] Warning: okio.DeflaterSink: can't find referenced method 'int deflate(byte[],int,int,int)' in class java.util.zip.Deflater
[proguard] Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
[proguard] Warning: okio.Okio: can't find referenced class java.nio.file.Files
[proguard] Warning: retrofit.appengine.UrlFetchClient: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
[proguard] Warning: retrofit.appengine.UrlFetchClient: can't find referenced class com.google.appengine.api.urlfetch.URLFetchServiceFactory
[proguard] Warning: retrofit.appengine.UrlFetchClient: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService
[proguard] Note: there were 10 unresolved dynamic references to classes or interfaces.
[proguard] You should check if you need to specify additional program jars.
[proguard] Warning: there were 90 unresolved references to classes or interfaces.
[proguard] You may need to specify additional library jars (using '-libraryjars').
[proguard] Warning: there were 1 unresolved references to program class members.
[proguard] Your input classes appear to be inconsistent.
[proguard] You may need to recompile them and try again.
[proguard] Alternatively, you may have to specify the option
[proguard] '-dontskipnonpubliclibraryclassmembers'.

即使在 Jenkins 上,调试版本也说它通过了但发布版本失败了。问题只是 Proguard 吗?

我确实找到了一些设置,我当前的 proguard 文件有以下关于库的指令:

-dontwarn com.squareup.okhttp.**
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
@retrofit.http.* <methods>;
}

由于差异如此之大,我正试图找出可能的罪魁祸首!任何想法从哪里开始?如果我可以通过 proguard 更改摆脱困境,我不愿意更改 jenkins 上的配置。

最佳答案

这个问题终于解决了,但需要进行多次更改。

  1. 我在运行 Jenkins 的节点上将 jdk 更新为 7。
  2. 我更新了android sdk工具
  3. 我在混淆器中添加了以下内容:

    -dontwarn com.facebook.android.BuildConfig

    -dontwarn rx.**

    -dontwarn okio.**

    -dontwarn com.squareup.okhttp.*

    -dontwarn retrofit.appengine.UrlFetchClient

    -keepattributes *Annotation*

    -keep class retrofit.** { *; }

    -keepclasseswithmembers class * {
    @retrofit.http.* <methods>;
    }

    -keepattributes Signature

关于java - 使用来自 Square 的最新 jar 的问题 - retrofit、okhttp、okio 和 okhttp-urlconnection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24871219/

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