android代码中的odata服务不起作用

时间:2014-01-24 12:52:47

标签: android odata

我曾尝试创建一个Android程序来使用webservices,但它总是被停止....你能不能让我知道我做错了什么..

代码:::

MainActivity.java


package com.example.odata_4j;
import org.odata4j.consumer.ODataConsumer;
import org.odata4j.consumer.ODataConsumers;
import org.odata4j.core.OEntity;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.Toast;

public class MainActivity extends Activity {

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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);

        ODataConsumer consumer = DataConsumers.create("http://services.odata.org/OData/OData.svc/");

        // list category names
        for (OEntity category : consumer.getEntities("Categories").execute()) {
            String categoryName = category.getProperty("Name", String.class).getValue();
            System.out.println("Category name: " + categoryName);
        }

        return true;
    }
}

在Manifest中我添加了Internet权限&还添加了“odata4j-archives”中的所有jar文件。 我可以在LogCat上看到一些错误打印,但我没有得到如何解决它。 我添加了所有的库,这就是为什么程序正在编译但是如何在日志中突然显示方法无法找到...请帮助

日志:

01-24 17:07:42.764: I/dalvikvm(329): Could not find method org.odata4j.consumer.ODataConsumers.create, referenced from method com.example.newodata4j_inoldversion.MainActivity.GetExpenseReports
01-24 17:07:42.824: W/dalvikvm(329): VFY: unable to resolve static method 5323: Lorg/odata4j/consumer/ODataConsumers;.create  (Ljava/lang/String;)Lorg/odata4j/consumer/ODataConsumer;
01-24 17:07:42.824: D/dalvikvm(329): VFY: replacing opcode 0x71 at 0x0007
01-24 17:07:42.824: D/dalvikvm(329): VFY: dead code 0x000a-0078 in Lcom/example/newodata4j_inoldversion/MainActivity;.GetExpenseReports ()Ljava/util/ArrayList;
01-24 17:07:42.874: D/AndroidRuntime(329): Shutting down VM  
01-24 17:07:42.874: W/dalvikvm(329): threadid=1: thread exiting with uncaught exception (group=0x40015560)
01-24 17:07:42.914: E/AndroidRuntime(329): FATAL EXCEPTION: main
01-24 17:07:42.914: E/AndroidRuntime(329): java.lang.NoClassDefFoundError: org.odata4j.consumer.ODataConsumers
01-24 17:07:42.914: E/AndroidRuntime(329):  at com.example.newodata4j_inoldversion.MainActivity.GetExpenseReports(MainActivity.java:44)"

先谢谢

0 个答案:

没有答案