0
votes

I'm trying to use a google lib to read and write inside the google cloud datastore from an Android App.

The library is this one: google-api-services-datastore-protobuf-java-v1beta1-rev1-1.0.0

I already made a std java project that uses this library and all is working. In Android when I try to compile it, I get this error:

[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

So I tried to import source api too, but got hundreds of errors

After a while I solved this problem and application launches on android but I get this run time error:

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

In the end the question is:

How shoud I access the google cloud datastore from android??

I'm start thinking that this library is not compatible with Android...

Thank you

1
which version of the android sdk are you using?proppy
Sorry for the delay. I'm using this one: ADT v. 22.0.1FrankPak

1 Answers

1
votes

I found out that the error was given by the dx component: it seems that in android it is not possible to use an external jar library with packages named java.* or javax.*

Look at this link here: https://stackoverflow.com/a/11547272/223969