Fail to import Jackson Jersey and Jersey Client in Android Studio

房东的猫 提交于 2019-12-23 01:43:24

问题


I am in trouble in using Jersey dependencies with Android Studio. Here is my build.gradle file :

apply plugin: 'com.android.application'


android {
compileSdkVersion 22
buildToolsVersion "21.1.2"

defaultConfig {
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
testCompile 'junit:junit:4.12'
compile 'javax.ws.rs:javax.ws.rs-api:2.0.1'
compile 'com.android.support:appcompat-v7:22.1.1'
compile files('libs/jersey-client-2.8.jar')
compile files('libs/jersey-media-json-jackson-2.8.jar')
}

I add the following import to my Activity :

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;

public class LoginActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    Client client = ClientBuilder.newClient();

And I keep having the same ERROR :

FATAL EXCEPTION: main
Process: com.example.julie.myapplication, PID: 30599
java.lang.NoClassDefFoundError: org.glassfish.jersey.client.ClientConfig

It seems that the import fail, could someone please help me ? Thanks a lot, Julie


回答1:


From Jersey version 2.16, it should be possible to use Jersey Client on Android. The support is still not perfect. refer this this info might be helpful who searches about Support of Jersey Client in android..



来源:https://stackoverflow.com/questions/35770877/fail-to-import-jackson-jersey-and-jersey-client-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!