AndroidAnnotations Rest SourceHttpMessageConverter error

只谈情不闲聊 提交于 2019-12-25 02:55:26

问题


I'm trying to use the RestClient of AndroidAnnotations but when I call one of the methods in the client I get the following error:

04-10 10:07:23.624    7528-7528/eu.shareforce.vitens E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.VerifyError: org/springframework/http/converter/xml/SourceHttpMessageConverter
        at org.springframework.web.client.RestTemplate.<init>(RestTemplate.java:149)
        at eu.shareforce.vitens.Interfaces.VitensRestClient_.<init>(VitensRestClient_.java:23)
        at eu.shareforce.vitens.Activities.LoginActivity_.init_(LoginActivity_.java:42)
        at eu.shareforce.vitens.Activities.LoginActivity_.onCreate(LoginActivity_.java:34)
        at android.app.Activity.performCreate(Activity.java:5165)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1103)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2419)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2520)
        at android.app.ActivityThread.access$600(ActivityThread.java:162)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1366)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:158)
        at android.app.ActivityThread.main(ActivityThread.java:5751)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
        at dalvik.system.NativeStart.main(Native Method)

The RestClient.java

@Rest(rootUrl = "http://meer-likes.nl/api/?call=", converters = {
    MappingJackson2HttpMessageConverter.class,
    StringHttpMessageConverter.class })
    public interface RestClient {

    @Get("/user/forgot-password/{email}")
        String forgotPassword(String email);
    }
}

The Activity:

@EActivity(R.layout.activity_forgotpassword)
public class ForgotPassword extends Activity {

    @RestService
    VitensRestClient client;

    @ViewById
    Button forgotButton;

    @ViewById
    EditText email_address;

    @Click
    void forgotButton() {
        forgotPassword();
    }

    @Background
    void forgotPassword() {
        client.forgotPassword(email_address.getText().toString());
    }
}

I am using Android Studio 1.0.1, AndroidAnnotations 3.2 and SpringFramework 4.1.6.


回答1:


Found a solution! I had to use different Spring dependencies. I have to use:

compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'

Instead of:

compile 'org.springframework:spring-context:4.1.6.RELEASE'
compile ('org.springframework:spring-web:4.1.6.RELEASE') {
    exclude group: 'commons-logging', module: 'commons-logging'
}


来源:https://stackoverflow.com/questions/29556560/androidannotations-rest-sourcehttpmessageconverter-error

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