Reputation: 24012
While trying to use any Drive class function:
Drive service = new Drive.Builder(AndroidHttp.newCompatibleTransport(),new GsonFactory(), credential).build();
I have included the right jar in the libs folders:
google-api-services-drive-v2-rev123-1.18.0-rc.jar
and the imports are fine:
import com.google.api.services.drive.Drive; import com.google.api.services.drive.DriveScopes;
But it keeps on showing the error:
05-07 11:54:37.865: E/AndroidRuntime(25824): FATAL EXCEPTION: AsyncTask #1
05-07 11:54:37.865: E/AndroidRuntime(25824): java.lang.RuntimeException: An error occured while executing doInBackground()
05-07 11:54:37.865: E/AndroidRuntime(25824): at android.os.AsyncTask$3.done(AsyncTask.java:299)
05-07 11:54:37.865: E/AndroidRuntime(25824): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
05-07 11:54:37.865: E/AndroidRuntime(25824): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
05-07 11:54:37.865: E/AndroidRuntime(25824): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
05-07 11:54:37.865: E/AndroidRuntime(25824): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
05-07 11:54:37.865: E/AndroidRuntime(25824): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
05-07 11:54:37.865: E/AndroidRuntime(25824): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
05-07 11:54:37.865: E/AndroidRuntime(25824): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
05-07 11:54:37.865: E/AndroidRuntime(25824): at java.lang.Thread.run(Thread.java:838)
05-07 11:54:37.865: E/AndroidRuntime(25824): Caused by: java.lang.NoClassDefFoundError: com.google.api.services.drive.Drive$Builder
05-07 11:54:37.865: E/AndroidRuntime(25824): at com.example.googledrivetest.MainActivity$getAccountDetails.doInBackground(MainActivity.java:138)
05-07 11:54:37.865: E/AndroidRuntime(25824): at com.example.googledrivetest.MainActivity$getAccountDetails.doInBackground(MainActivity.java:1)
05-07 11:54:37.865: E/AndroidRuntime(25824): at android.os.AsyncTask$2.call(AsyncTask.java:287)
05-07 11:54:37.865: E/AndroidRuntime(25824): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
05-07 11:54:37.865: E/AndroidRuntime(25824): ... 5 more
Upvotes: 0
Views: 3532
Reputation: 17615
I believe you have not included google-api-client-1.18.0-rc.jar
library, that is the reason you are getting the exception.
Once you download and unzip the Drive API library, please read the drive/readme.html
. It has listed the dependent jars for google-api-services-drive-v2-rev123-1.18.0-rc.jar
that need to be included. The dependent jars can be located in drive/libs
folder.
Following are the complete set of jars that need to be included for Android application:
Upvotes: 2