0

我正在尝试使用谷歌库从 Android 应用程序在谷歌云数据存储中读取和写入。

该库是这个:google-api-services-datastore-protobuf-java-v1beta1-rev1-1.0.0

我已经制作了一个使用这个库的 std java 项目,并且一切正常。在Android中,当我尝试编译它时,我收到了这个错误:

[2013-07-01 12:54:33 - AndroidDatastore] Dx 1 error; aborting
[2013-07-01 12:54:33 - AndroidDatastore] Conversion to Dalvik format failed with error 1

所以我也尝试导入源api,但出现数百个错误

过了一会儿,我解决了这个问题并在 android 上启动了应用程序,但我得到了这个运行时错误:

07-08 11:14:26.002: I/dalvikvm(14946): Could not find method com.google.api.services.datastore.DatastoreV1$Entity.newBuilder, referenced from method it.micrel.androiddatastore.MainActivity.addEntry
07-08 11:14:26.002: W/dalvikvm(14946): VFY: unable to resolve static method 9: Lcom/google/api/services/datastore/DatastoreV1$Entity;.newBuilder ()Lcom/google/api/services/datastore/DatastoreV1$Entity$Builder;
07-08 11:14:26.002: D/dalvikvm(14946): VFY: replacing opcode 0x71 at 0x0002
07-08 11:14:26.002: E/dalvikvm(14946): Could not find class 'com.google.api.services.datastore.client.DatastoreOptions$Builder', referenced from method it.micrel.androiddatastore.MainActivity.connectToDatastore
07-08 11:14:26.002: W/dalvikvm(14946): VFY: unable to resolve new-instance 32 (Lcom/google/api/services/datastore/client/DatastoreOptions$Builder;) in Lit/micrel/androiddatastore/MainActivity;
07-08 11:14:26.002: D/dalvikvm(14946): VFY: replacing opcode 0x22 at 0x0000
07-08 11:14:26.012: I/dalvikvm(14946): Could not find method com.google.api.services.datastore.DatastoreV1$BlindWriteRequest.newBuilder, referenced from method it.micrel.androiddatastore.MainActivity.insertAutoId
07-08 11:14:26.012: W/dalvikvm(14946): VFY: unable to resolve static method 5: Lcom/google/api/services/datastore/DatastoreV1$BlindWriteRequest;.newBuilder ()Lcom/google/api/services/datastore/DatastoreV1$BlindWriteRequest$Builder;
07-08 11:14:26.012: D/dalvikvm(14946): VFY: replacing opcode 0x71 at 0x0000
07-08 11:14:26.012: I/dalvikvm(14946): Could not find method com.google.api.services.datastore.DatastoreV1$Query.newBuilder, referenced from method it.micrel.androiddatastore.MainActivity.listEntry
07-08 11:14:26.012: W/dalvikvm(14946): VFY: unable to resolve static method 16: Lcom/google/api/services/datastore/DatastoreV1$Query;.newBuilder ()Lcom/google/api/services/datastore/DatastoreV1$Query$Builder;
07-08 11:14:26.012: D/dalvikvm(14946): VFY: replacing opcode 0x71 at 0x0000
07-08 11:14:26.012: I/dalvikvm(14946): Could not find method com.google.api.services.datastore.DatastoreV1$RunQueryRequest.newBuilder, referenced from method it.micrel.androiddatastore.MainActivity.runQuery
07-08 11:14:26.012: W/dalvikvm(14946): VFY: unable to resolve static method 21: Lcom/google/api/services/datastore/DatastoreV1$RunQueryRequest;.newBuilder ()Lcom/google/api/services/datastore/DatastoreV1$RunQueryRequest$Builder;
07-08 11:14:26.012: D/dalvikvm(14946): VFY: replacing opcode 0x71 at 0x0000
07-08 11:14:26.012: W/dalvikvm(14946): VFY: unable to find class referenced in signature (Lcom/google/api/services/datastore/client/Datastore;)
07-08 11:14:26.022: W/dalvikvm(14946): VFY: unable to resolve exception class 29 (Lcom/google/api/services/datastore/client/DatastoreException;)
07-08 11:14:26.022: W/dalvikvm(14946): VFY: unable to find exception handler at addr 0x68
07-08 11:14:26.022: W/dalvikvm(14946): VFY:  rejected Lit/micrel/androiddatastore/MainActivity;.onCreate (Landroid/os/Bundle;)V
07-08 11:14:26.022: W/dalvikvm(14946): VFY:  rejecting opcode 0x0d at 0x0068
07-08 11:14:26.022: W/dalvikvm(14946): VFY:  rejected Lit/micrel/androiddatastore/MainActivity;.onCreate (Landroid/os/Bundle;)V
07-08 11:14:26.022: W/dalvikvm(14946): Verifier rejected class Lit/micrel/androiddatastore/MainActivity;
07-08 11:14:26.022: W/dalvikvm(14946): Class init failed in newInstance call (Lit/micrel/androiddatastore/MainActivity;)
07-08 11:14:26.092: D/AndroidRuntime(14946): Shutting down VM
07-08 11:14:26.092: W/dalvikvm(14946): threadid=1: thread exiting with uncaught exception (group=0x40aac210)
07-08 11:14:26.202: E/AndroidRuntime(14946): FATAL EXCEPTION: main
07-08 11:14:26.202: E/AndroidRuntime(14946): java.lang.VerifyError: it/micrel/androiddatastore/MainActivity
07-08 11:14:26.202: E/AndroidRuntime(14946):    at java.lang.Class.newInstanceImpl(Native Method)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at java.lang.Class.newInstance(Class.java:1319)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1882)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at android.app.ActivityThread.access$600(ActivityThread.java:127)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at android.os.Looper.loop(Looper.java:137)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at android.app.ActivityThread.main(ActivityThread.java:4448)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at java.lang.reflect.Method.invokeNative(Native Method)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at java.lang.reflect.Method.invoke(Method.java:511)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
07-08 11:14:26.202: E/AndroidRuntime(14946):    at dalvik.system.NativeStart.main(Native Method)
07-08 11:14:32.558: I/Process(14946): Sending signal. PID: 14946 SIG: 9

最后的问题是:

我应该如何从 android 访问谷歌云数据存储?

我开始认为这个库与Android不兼容......

谢谢

4

1 回答 1

1

我发现错误是由 dx 组件给出的:似乎在 android 中无法使用名为 java.* 或 javax.* 的包的外部 jar 库

在此处查看此链接:https ://stackoverflow.com/a/11547272/223969

于 2013-07-08T12:28:50.693 回答