Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.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 需要Android改型错误HTTP方法注释(例如@GET、@POST等)_Java_Android_Runtime Error_Retrofit - Fatal编程技术网

Java 需要Android改型错误HTTP方法注释(例如@GET、@POST等)

Java 需要Android改型错误HTTP方法注释(例如@GET、@POST等),java,android,runtime-error,retrofit,Java,Android,Runtime Error,Retrofit,我有一个问题,我的改装代码,我似乎要么错过了一些东西或没有完全理解我需要做什么。这是我的错误的完整副本。我没有使用ProGuard,但我已经在规则集中应用了您认为应该应用的所有异常,以确保安全。对于调试和发布,Minify都设置为false 如果有人能帮我解决这个问题,我将不胜感激 05-01 11:08:37.967 12277-12357/com.gbp.sean.reorderscanner E/VMIROrderService﹕ Exception Postin

我有一个问题,我的改装代码,我似乎要么错过了一些东西或没有完全理解我需要做什么。这是我的错误的完整副本。我没有使用ProGuard,但我已经在规则集中应用了您认为应该应用的所有异常,以确保安全。对于调试和发布,Minify都设置为false

如果有人能帮我解决这个问题,我将不胜感激

    05-01 11:08:37.967  12277-12357/com.gbp.sean.reorderscanner         E/VMIROrderService﹕ Exception Posting Order
retrofit.RetrofitError: OrderEntryInterface.update: HTTP method annotation is required (e.g., @GET, @POST, etc.).
        at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:400)
        at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
        at java.lang.reflect.Proxy.invoke(Proxy.java:397)
        at $Proxy0.update(Unknown Source)
        at com.gbp.sean.reorderscanner.VMIROrderService.getEntryResult(VMIROrderService.java:65)
        at com.gbp.sean.reorderscanner.VMIROrderService.onHandleIntent(VMIROrderService.java:41)
        at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.os.HandlerThread.run(HandlerThread.java:61)
 Caused by: java.lang.IllegalArgumentException: OrderEntryInterface.update: HTTP method annotation is required (e.g., @GET, @POST, etc.).
        at retrofit.RestMethodInfo.methodError(RestMethodInfo.java:107)
        at retrofit.RestMethodInfo.parseMethodAnnotations(RestMethodInfo.java:179)
        at retrofit.RestMethodInfo.init(RestMethodInfo.java:117)
        at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:294)
        at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
        at java.lang.reflect.Proxy.invoke(Proxy.java:397)
        at $Proxy0.update(Unknown Source)
        at com.gbp.sean.reorderscanner.VMIROrderService.getEntryResult(VMIROrderService.java:65)
        at com.gbp.sean.reorderscanner.VMIROrderService.onHandleIntent(VMIROrderService.java:41)
        at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.os.HandlerThread.run(HandlerThread.java:61)
这是我的OrderEntryInterface的副本

 import retrofit.http.GET;
 import retrofit.http.Path;

 public interface OrderEntryInterface {

    @GET("/ServiceNameFilteredOut/json/@id={id}@ord={ord}")
    OrderDetails details(
        @Path("id") String id,
        @Path("ord") String ord
    );
    OrderInfo update();
}
这是我的订单服务的重要部分

@Override
protected void onHandleIntent(Intent intent) {
    try {
        this.id = intent.getExtras().getString("id");
        this.ord = intent.getExtras().getString("ord");
        String result=getEntryResult();

        Log.d(getClass().getSimpleName(),result);

        if(result != null) {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(getApplicationContext(), "Posted Successfully", Toast.LENGTH_LONG).show();
                }
            });
        }
    }
    catch (Exception e) {
        Log.e(getClass().getSimpleName(), "Exception Posting Order", e);
    }
}

private String getEntryResult() {
    RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint("http://WebPageURLFilteredOut/").build();
    OrderEntryInterface entryInterface = restAdapter.create(OrderEntryInterface.class);

    entryInterface.details(id,ord);

    OrderInfo info = entryInterface.update();

    if (info.PostOrderResult == "Confirmed") {
        return (info.PostOrderResult);
    }

    return (null);
}

details()
方法上有一个注释。您正在调用
update()
方法。错误消息表明
update()
方法缺少注释。而且,根据您的代码,在
update()
方法上没有注释


因此,在
update()
方法中添加一个改装注释。

确保所有导入都是改装的2。e、 g

import retrofit2.http.POST;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
或者你正在使用的任何版本