使用Square最新罐子的问题 - 改造,okhttp,okio和okhttp-urlconnection

 mobiledu2502870957 发布于 2023-01-01 19:31

我为我正在研究的一个功能介绍了以下Square广口瓶:

okttp-2.0.0

okhttp-的URLConnection-2.0.0.jar

奥基奥-1.0.0.jar

改装的1.6.1.jar

我从中央maven repo下载了这些.

一切都在本地工作正常,我将我的代码提交给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文件有关于libs的以下指令:

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

由于存在这么多差异,我试图找到可能的罪魁祸首!任何想法从哪里开始?我不愿意改变jenkins的配置,如果我可以通过proguard更改来逃脱.

1 个回答
  • 这最终解决了,但需要多次更改.

      我在运行Jenkins的节点上将jdk更新为7.

      我更新了android sdk工具

      我在proguard中添加了以下内容:

      -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
      

    2023-01-01 19:34 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有