以下は、odataを使用してデータを取得しようとしているAndroidのコードです。OdataWebNorthwindModelServiceはプロキシクラス(自動生成)の名前です...ヘルプについてはhttp://weblogs.asp.net/uruit/archive/2011/09/13/accessing-odata-from-android-using-restlet.aspxをフォローしました...しかし私はいくつかの問題を抱えています..私を助けてください。
package com.example.odatajsondatagrabbing;
import northwindmodel.Category;
import org.restlet.ext.odata.Query;
import OdataWebNorthPackage.OdataWebNorthwindModelService;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
OdataWebNorthwindModelService service = new OdataWebNorthwindModelService();
Query<Category> query = service.createCategoryQuery("/Categories");
for(Category cate: query){
System.out.println("ID::"+cate.getCategoryId());
System.out.println("Name::"+cate.getCategoryName());
System.out.println("\n");
}
}
}
以下は、アプリケーションの実行中に発生したエラーです
11-01 17:12:14.264: D/AndroidRuntime(689): Shutting down VM
11-01 17:12:14.264: W/dalvikvm(689): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-01 17:12:14.294: E/AndroidRuntime(689): FATAL EXCEPTION: main
11-01 17:12:14.294: E/AndroidRuntime(689): java.lang.NoClassDefFoundError: OdataWebNorthPackage.OdataWebNorthwindModelService
11-01 17:12:14.294: E/AndroidRuntime(689): at com.example.odatajsondatagrabbing.MainActivity.onCreate(MainActivity.java:20)
11-01 17:12:14.294: E/AndroidRuntime(689): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-01 17:12:14.294: E/AndroidRuntime(689): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-01 17:12:14.294: E/AndroidRuntime(689): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-01 17:12:14.294: E/AndroidRuntime(689): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-01 17:12:14.294: E/AndroidRuntime(689): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-01 17:12:14.294: E/AndroidRuntime(689): at android.os.Handler.dispatchMessage(Handler.java:99)
11-01 17:12:14.294: E/AndroidRuntime(689): at android.os.Looper.loop(Looper.java:123)
11-01 17:12:14.294: E/AndroidRuntime(689): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-01 17:12:14.294: E/AndroidRuntime(689): at java.lang.reflect.Method.invokeNative(Native Method)
11-01 17:12:14.294: E/AndroidRuntime(689): at java.lang.reflect.Method.invoke(Method.java:521)
11-01 17:12:14.294: E/AndroidRuntime(689): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-01 17:12:14.294: E/AndroidRuntime(689): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-01 17:12:14.294: E/AndroidRuntime(689): at dalvik.system.NativeStart.main(Native Method)
11-01 17:17:14.385: I/Process(689): Sending signal. PID: 689 SIG: 9
デバッグを試みたときにコンストラクターからエラーが発生しています。以下は自動生成されたコードです
package OdataWebNorthPackage;
import northwindmodel.*;
import org.restlet.ext.odata.Query;
public class OdataWebNorthwindModelService extends org.restlet.ext.odata.Service {
public OdataWebNorthwindModelService() {
super("http://services.odata.org/Northwind/Northwind.svc");
}
public void addEntity(Category entity) throws Exception {
addEntity("/Categories", entity);
}
public Query<Category> createCategoryQuery(String subpath) {
return createQuery(subpath, Category.class);
}
public void addEntity(CustomerDemographic entity) throws Exception {
addEntity("/CustomerDemographics", entity);
}
public Query<CustomerDemographic> createCustomerDemographicQuery(String subpath) {
return createQuery(subpath, CustomerDemographic.class);
}
}