android - Google Play, Drive API sample code in IntelliJ -
i'm following google drive quickstart on android instructions , have working in eclipse/kepler. (juno plain dodgy.) however, i'm more familiar intellij, i'm trying figure out how install these apis there in corresponding manner.
i think i'm getting tripped on drive api part. eclipse plugin installs drive in special way or place. added google-api-services-drive-v2-rev63-1.14.1-beta.jar library, same others (google-play-services , api_java_client). when run application comes with
java.lang.noclassdeffounderror: com.google.api.client.googleapis.extensions.android.gms.auth.googleaccountcredential
and i've gotten noclassdeffounderror having drive$builder.
in intellij .jar scopes set "compile" except api_java_client libraries set "provided." none of them have "export" checked.
edit: added module & dependency. have different error:
04-07 00:39:59.766: error/androidruntime(10697): fatal exception: main java.lang.noclassdeffounderror: com.google.api.client.googleapis.extensions.android.gms.auth.googleaccountcredential @ com.fallinghawks.weight4.app.oncreate(app.java:15)
app.java:15 is
credential = googleaccountcredential.usingoauth2(this, drivescopes.drive);
i can find class it's asking for....
edit 2, after adding libraries per crazycoder's instructions: compiles, runs, following error. sure missed doing right, i'll try again in minute in meantime error is:
04-10 18:02:35.120: error/androidruntime(740): fatal exception: main java.lang.exceptionininitializererror @ com.google.api.services.drive.drive$builder.build(drive.java:7301) @ com.example.drivequickstart.myactivity.getdriveservice(myactivity.java:110) @ com.example.drivequickstart.myactivity.onactivityresult(myactivity.java:49) @ android.app.activity.dispatchactivityresult(activity.java:5293) @ android.app.activitythread.deliverresults(activitythread.java:3315) @ android.app.activitythread.handlesendresult(activitythread.java:3362) @ android.app.activitythread.access$1100(activitythread.java:141) @ android.app.activitythread$h.handlemessage(activitythread.java:1282) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:5041) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) @ dalvik.system.nativestart.main(native method) caused by: java.lang.noclassdeffounderror: com.google.common.base.preconditions @ com.google.api.services.drive.drive.<clinit>(drive.java:63)
(hopefully final edit): yes, missed , beast working! thank much!!
can use intellij again work on "real" project... sooooo better :)
i went ahead , created intellij idea project scratch, spent 15 minutes, works fine.
download drive api v2 library , dependencies.
unpack somewhere, open
readme.html
, spend couple of minutes reading understand jars needed.create new android application project in idea using wizard
com.example.drivequickstart
package ,mainactivity
. use android 4.2.2 google apis platform.copy following jars downloaded drive api library project
libs
folder (you should have learned jars use step 2):google-api-client-1.14.1-beta.jar
google-api-client-android-1.14.1-beta.jar
google-http-client-1.14.1-beta.jar
google-http-client-android-1.14.1-beta.jar
google-http-client-gson-1.14.1-beta.jar
google-oauth-client-1.14.1-beta.jar
gson-2.1.jar
jsr305-1.3.9.jar
google-api-services-drive-v2-rev65-1.14.1-beta.jar
configure project library these jars. can done selecting jars in project view, right click, add library..., add library dependencies of main module.
file
|import module
, browseandroid_sdk\extras\google\google_play_services\libproject\google-play-services_lib
, existing sources.add
google-play-services.jar
dependencies of imported module, enable export checkbox, should like this.add module created in step 6 dependencies of main application module.
copy
mainactivity
sample code quick start, step 4mainactivity.java
file replacing old code, editandroidmanifest.xml
per guide.build, run in emulator or on device test (don't forget steps 1-2 quick start).
or can download , use isolated sample i've created following above steps (module step 6 included in project).
it failed me in emulator because of camera app error (the sample uses camera , emulator didn't have configured), worked on galaxy nexus device. sample takes picture using device camera , uploads google drive.
Comments
Post a Comment