Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用来自Square-Reformation、okhttp、okio和okhttp urlconnection的最新JAR时出现问题_Java_Android_Jenkins_Retrofit_Okhttp - Fatal编程技术网

Java 使用来自Square-Reformation、okhttp、okio和okhttp urlconnection的最新JAR时出现问题

Java 使用来自Square-Reformation、okhttp、okio和okhttp urlconnection的最新JAR时出现问题,java,android,jenkins,retrofit,okhttp,Java,Android,Jenkins,Retrofit,Okhttp,我为正在开发的功能引入了以下方形罐: okttp-2.0.0 okhttp-urlconnection-2.0.0.jar okio-1.0.0.jar 改装-1.6.1.jar 我从中央maven repo下载了这些 在本地一切正常,我将代码提交给svn。我们有一个Jenkins CI服务器,用于生成调试和发布版本。这失败了 我当地的环境和詹金斯有很多不同之处: 我在本地运行Java8,Jenkins运行Java6 在本地,我只生成调试版本,Jenkins同时生成调试版本和发布版本 在本

我为正在开发的功能引入了以下方形罐:

  • okttp-2.0.0
  • okhttp-urlconnection-2.0.0.jar
  • okio-1.0.0.jar
  • 改装-1.6.1.jar
我从中央maven repo下载了这些

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

我当地的环境和詹金斯有很多不同之处:

  • 我在本地运行Java8,Jenkins运行Java6
  • 在本地,我只生成调试版本,Jenkins同时生成调试版本和发布版本
  • 在本地,我有22.6.2版的构建工具,Jenkins运行18.0.1
这些是我在詹金斯日志中看到的问题:

    -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文件有以下关于LIB的指令:

-dontwarn com.squareup.okhttp.**
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
@retrofit.http.* <methods>;
}
-dontwarn com.squareup.okhttp**
-保持类更新。**{*;}
-keepclassswithmembers类*{
@http.*;
}

有这么多不同之处,我正试图找到可能的罪魁祸首!你知道从哪里开始吗?如果我可以不做任何改动的话,我很不愿意更改jenkins上的配置。

更新你的dx,这是你android SDK的一部分。

这最终解决了,但需要多次更改

  • 我在运行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
    
    -dontwarn com.facebook.android.BuildConfig
    -dontwarn rx**
    -唐特沃恩·奥基奥**
    -dontwarn com.squareup.okhttp*
    -dontwarn改装.appengine.UrlFetchClient
    -keepattributes*注释*
    -保持类更新。**{*;}
    -keepclassswithmembers类*{
    @http.*;
    }
    -保留署名
    

  • 添加-dontwarn java.util.zip.*和-dontnote java.util.zip.*对我来说很有用