2016-02-01 30 views
0

当我运行我在Android Studio中应用程序的消息错误显示我这个错误:未知的错误,当我跑我的应用程序

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. 

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/glassfish/jersey/client/ClientProperties.class

我不知道如何解决这个错误。

我觉得这个误差取决于此代码:

import com.github.irobson.jgenderize.model.NameGender; 
import java.io.Serializable; 
import java.util.List; 
import java.util.Locale; 
import javax.ws.rs.client.Client; 
import javax.ws.rs.client.ClientBuilder; 
import javax.ws.rs.client.WebTarget; 
import javax.ws.rs.core.GenericType; 
import javax.ws.rs.core.MediaType; 

public class DefaultGenderize implements Genderize, Serializable { 

    private final Client client = ClientBuilder.newClient(); 

    private static final String GENDERIZE_IO_API_URL = "https://api.genderize.io/"; 

    public NameGender getGender(String name, Locale locale) { 
     WebTarget target = client.target(GENDERIZE_IO_API_UR`enter code here`L).queryParam("name", name); 
     if (locale != null) { 
      target = target.queryParam("country_id", locale.getCountry()); 
      target = target.queryParam("language_id", locale.getLanguage()); 
     } 
     return target.request(MediaType.APPLICATION_JSON_TYPE).get(NameGender.class); 
    } 

    public List<NameGender> getGenders(String[] names, Locale locale) { 
     GenericType<List<NameGender>> genericType = new GenericType<List<NameGender>>() { 
     }; 

     WebTarget target = client.target(GENDERIZE_IO_API_URL); 
     for (int i = 0; i < names.length; i++) { 
      target = target.queryParam(String.format("name[%d]", i), names[i]); 
     } 
     if (locale != null) { 
      target = target.queryParam("country_id", locale.getCountry()); 
      target = target.queryParam("language_id", locale.getLanguage()); 
     } 
     return target.request(MediaType.APPLICATION_JSON_TYPE).get(genericType); 
    } 

    public NameGender getGender(String name) { 
     return getGender(name, null); 
    } 

    public List<NameGender> getGenders(String... names) { 
     return getGenders(names, null); 
    } 
} 

或从某个库。

+0

安置自己的'build.gradle' –

+0

在这个环节p aste它build.gradle [链接](http://pastebin.com/peBggyVU) –

+0

删除'编译'com.android.support:appcompat-v7:23.0.0'' –

回答

0

我可以看到两个“支持v7”的依赖关系。删除其中一个。

compile 'com.android.support:appcompat-v7:21.0.3' 
compile 'com.android.support:appcompat-v7:23.0.0' 

结果

dependencies { 
    testCompile 'junit:junit:4.12' 
    compile 'javax.ws.rs:javax.ws.rs-api:2.0.1' 
    compile 'com.android.support:appcompat-v7:23.0.0' 
    compile 'com.android.support:design:23.0.0' 
    compile 'com.android.support:multidex:1.0.0' 
    compile files('libs/jersey-client-2.19.jar') 
} 
1

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/glassfish/jersey/client/ClientProperties.class

您有多个appcompat-v7,这就是为什么有问题。

不要

compile 'com.android.support:appcompat-v7:21.0.3' 
compile 'com.android.support:appcompat-v7:23.0.0' 

compile 'com.android.support:appcompat-v7:21.0.3' 

编辑

apply plugin: 'com.android.library' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.0" 
    defaultConfig { 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 

    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    // compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'javax.ws.rs:javax.ws.rs-api:2.0.1' 
    compile 'com.android.support:appcompat-v7:23.0.0' 
    compile 'com.android.support:design:23.0.0' 
    // compile 'javax.websocket:javax.websocket-all:1.1' 
    // compile files('libs/hk2-api-2.2.0-b21.jar') 
    compile 'com.android.support:multidex:1.0.0' 
    // compile 'org.glassfish.jersey:project:2.22.1' 
    // compile 'org.glassfish.jersey.core:jersey-client:2.0-m04' 
    compile files('libs/jersey-client-2.19.jar') 
} 
+0

答案已经与我的朋友一样贴出解答.. –

+0

@ChintanRathod Ji。对不起,迟到的答案。但我从不复制你的答案。#MoveAheadGDG –

相关问题