Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload file on google drive using my android application

I start with google drive sdk. I follows steps which describe in that post.

But I face problem in Step 3: Create and Configure an Android Project

Add Google APIs

I cant find options in my eclipse so I add plugins for google. After installation of plugins, Eclipse give errors and we now update my SDK also. So for that I update my SDK but now All projects giving me error in eclipse. I cant run any projects. So I use my old SDK back.

Now I stuck with this How to create Project for Google Drive and how to integrate it.

I need to upload file from my android application to Google Drive.

Please help me to find this.

EDIT

Now I successfully create project with error free. But when I run project it give me following errors.

 12-12 11:05:08.788: E/AndroidRuntime(377): java.lang.NoClassDefFoundError: com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential
12-12 11:05:08.788: E/AndroidRuntime(377):  at com.rarenoice.screen.MainActivity.onCreate(MainActivity.java:42)
12-12 11:05:08.788: E/AndroidRuntime(377):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-12 11:05:08.788: E/AndroidRuntime(377):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-12 11:05:08.788: E/AndroidRuntime(377):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-12 11:05:08.788: E/AndroidRuntime(377):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-12 11:05:08.788: E/AndroidRuntime(377):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-12 11:05:08.788: E/AndroidRuntime(377):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 11:05:08.788: E/AndroidRuntime(377):  at android.os.Looper.loop(Looper.java:123)
12-12 11:05:08.788: E/AndroidRuntime(377):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-12 11:05:08.788: E/AndroidRuntime(377):  at java.lang.reflect.Method.invokeNative(Native Method)
12-12 11:05:08.788: E/AndroidRuntime(377):  at java.lang.reflect.Method.invoke(Method.java:521)
12-12 11:05:08.788: E/AndroidRuntime(377):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-12 11:05:08.788: E/AndroidRuntime(377):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-12 11:05:08.788: E/AndroidRuntime(377):  at dalvik.system.NativeStart.main(Native Method)

At Following line :-

private GoogleAccountCredential credential;
 credential = GoogleAccountCredential.usingOAuth2(MainActivity.this,
                DriveScopes.DRIVE);
like image 659
Hardik Joshi Avatar asked Dec 12 '12 05:12

Hardik Joshi


People also ask

What are 2 ways you can upload files to Google Drive?

There are two ways to upload files to Google Drive: Drag-and-drop files. If you're using the latest versions of Chrome or Firefox, you can simply drag-and-drop files directly from your computer into Google Drive. You can even drag-and-drop files directly into folders or sub-folders.


Video Answer


1 Answers

You need to add the Google Play Services jars to your project, as explained in Step 3 of the quickstart guide you are following.

You can also watch this video where I go through all the steps to build the same quickstart application for Android: http://www.youtube.com/watch?v=Ied1CjJ0iP0

like image 73
Claudio Cherubino Avatar answered Oct 11 '22 00:10

Claudio Cherubino