0

I'm uploading file on google drive using drive api in my android application.I have created api project using package name & SHA1 key. But getting below error/warning-

static final int REQUEST_AUTHORIZATION = 2;
    Context context;
    String filename;
    Drive service;
    static GoogleAccountCredential credential;
    private static final int NOTIFY_ME_ID=111991;
    private NotificationManager mgr=null;


    @Override
    public void onCreate() {  
        super.onCreate();
        credential = GoogleAccountCredential.usingOAuth2(this, Arrays.asList(DriveScopes.DRIVE_FILE));
    }

    @Override
    public void onDestroy() {        
        super.onDestroy();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {       
        context=UploadService.this;


        filename=intent.getStringExtra("file_name");
        System.out.println(" in service .. account - "+filename);
        String accountName=intent.getStringExtra("accountName");
        //service=GoogleDrive.service;

        if (accountName != null) {
            System.out.println("I am in");

            credential.setSelectedAccountName(accountName);

            service = getDriveService(credential);
            //   service = GoogleDrive.service;//getDriveService(credential);
            Uploading upload = new Uploading();
            upload.execute();
        }
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public IBinder onBind(Intent arg0) {
        // TODO Auto-generated method stub
        return null;
    }

    private Drive getDriveService(GoogleAccountCredential credential) {
        return new Drive.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential)
        .build();
    }



    public class Uploading extends AsyncTask<String,Void,Boolean>{
        ProgressDialog pDialog;

        boolean value1;
        @Override
        protected void onPreExecute(){
            /*   pDialog = new ProgressDialog(context);
              pDialog.setTitle("Please Wait");
              pDialog.setMessage("Uploading...");
              pDialog.setCancelable(false);
              pDialog.show();*/
            //finish();
        }
        @Override
        protected Boolean doInBackground(String... params) {

            try {
                // File's binary content //application/json; charset=UTF-8 image/jpeg
                System.out.println(" file name account - "+filename);
                java.io.File fileContent = new java.io.File(""+filename);//Environment.getExternalStorageDirectory().getAbsolutePath()+"/app.wgz");//(fileUri.getPath());
                FileContent mediaContent = new FileContent("video/mpeg", fileContent);

                // File's metadata.
                File body = new File();
                body.setTitle(fileContent.getName());
                body.setMimeType("video/mpeg");

                File file = service.files().insert(body, mediaContent).execute();
                if (file != null) {
                    //showToast("Photo uploaded: " + file.getTitle());
                    //startCameraIntent();
                    value1=true;
                }
                else
                {
                    value1=false;
                }
            } catch (UserRecoverableAuthIOException e) {
                // startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
            } catch (IOException e) {
                e.printStackTrace();
            }

            return value1;
        }
        protected void onPostExecute(Boolean params){
            super.onPostExecute(params);
            //  pDialog.dismiss();
            if(params){

                Toast.makeText(context, "File Uploaded", 10000).show();
            }
            else{
                Toast.makeText(context, "Error while uploading", 10000).show();

            }
            NotificationManager nMgr = (NotificationManager)  getSystemService(Context.NOTIFICATION_SERVICE);
            nMgr.cancel(NOTIFY_ME_ID);
            UploadService.this.stopSelf();
        }
    }

log info-

05-26 16:35:58.390: W/dalvikvm(8203): VFY: unable to resolve static field 4547 (auth_client_play_services_err_notification_msg) in Lcom/google/android/gms/R$string;
05-26 16:35:58.390: D/dalvikvm(8203): VFY: replacing opcode 0x60 at 0x001a
05-26 16:35:58.390: I/dalvikvm(8203): DexOpt: unable to optimize static field ref 0x11c4 at 0x42 in Lcom/google/android/gms/auth/GoogleAuthUtil;.a
05-26 16:35:58.390: I/dalvikvm(8203): DexOpt: unable to optimize static field ref 0x11c5 at 0x54 in Lcom/google/android/gms/auth/GoogleAuthUtil;.a
05-26 16:35:58.400: I/dalvikvm(8203): DexOpt: unable to optimize static field ref 0x11c1 at 0x73 in Lcom/google/android/gms/auth/GoogleAuthUtil;.a
05-26 16:35:58.400: I/dalvikvm(8203): DexOpt: unable to optimize static field ref 0x11c2 at 0x76 in Lcom/google/android/gms/auth/GoogleAuthUtil;.a
05-26 16:35:58.400: I/dalvikvm(8203): DexOpt: unable to optimize static field ref 0x11c0 at 0x79 in Lcom/google/android/gms/auth/GoogleAuthUtil;.a
05-26 16:35:58.400: W/dalvikvm(8203): VFY: unable to resolve static field 4556 (common_google_play_services_install_title) in Lcom/google/android/gms/R$string;
05-26 16:35:58.400: D/dalvikvm(8203): VFY: replacing opcode 0x60 at 0x0041
05-26 16:35:58.400: W/dalvikvm(8203): VFY: unable to resolve static field 4552 (common_google_play_services_enable_title) in Lcom/google/android/gms/R$string;
05-26 16:35:58.400: D/dalvikvm(8203): VFY: replacing opcode 0x60 at 0x004c
05-26 16:35:58.400: W/dalvikvm(8203): VFY: unable to resolve static field 4562 (common_google_play_services_update_title) in Lcom/google/android/gms/R$string;
05-26 16:35:58.400: D/dalvikvm(8203): VFY: replacing opcode 0x60 at 0x0057
05-26 16:35:58.400: W/dalvikvm(8203): VFY: unable to resolve static field 4559 (common_google_play_services_unsupported_title) in Lcom/google/android/gms/R$string;
05-26 16:35:58.400: D/dalvikvm(8203): VFY: replacing opcode 0x60 at 0x0069
05-26 16:35:58.400: W/dalvikvm(8203): VFY: unable to resolve static field 4553 (common_google_play_services_install_button) in Lcom/google/android/gms/R$string;
05-26 16:35:58.400: D/dalvikvm(8203): VFY: replacing opcode 0x60 at 0x0009
05-26 16:35:58.400: W/dalvikvm(8203): VFY: unable to resolve static field 4550 (common_google_play_services_enable_button) in Lcom/google/android/gms/R$string;
05-26 16:35:58.400: D/dalvikvm(8203): VFY: replacing opcode 0x60 at 0x0010
05-26 16:35:58.400: W/dalvikvm(8203): VFY: unable to resolve static field 4560 (common_google_play_services_update_button) in Lcom/google/android/gms/R$string;
05-26 16:35:58.400: D/dalvikvm(8203): VFY: replacing opcode 0x60 at 0x0017
05-26 16:35:58.410: W/dalvikvm(8203): VFY: unable to resolve static field 4557 (common_google_play_services_unknown_issue) in Lcom/google/android/gms/R$string;
05-26 16:35:58.410: D/dalvikvm(8203): VFY: replacing opcode 0x60 at 0x0004
05-26 16:35:58.410: W/dalvikvm(8203): VFY: unable to resolve static field 4557 (common_google_play_services_unknown_issue) in Lcom/google/android/gms/R$string;
05-26 16:35:58.410: D/dalvikvm(8203): VFY: replacing opcode 0x60 at 0x000c
05-26 16:35:58.410: I/dalvikvm(8203): DexOpt: unable to optimize static field ref 0x11cb at 0x18 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b
05-26 16:35:58.410: I/dalvikvm(8203): DexOpt: unable to optimize static field ref 0x11ca at 0x38 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b
05-26 16:35:58.410: I/dalvikvm(8203): DexOpt: unable to optimize static field ref 0x11c7 at 0x3f in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b
05-26 16:35:58.410: I/dalvikvm(8203): DexOpt: unable to optimize static field ref 0x11d1 at 0x46 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b
05-26 16:35:58.410: I/dalvikvm(8203): DexOpt: unable to optimize static field ref 0x11ce at 0x66 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b
05-26 16:35:58.420: E/GooglePlayServicesUtil(8203): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
05-26 16:35:58.460: W/GLSUser(1114): GoogleAccountDataService.getToken()

How can i resolve this?is there any solution?

yuva ツ
  • 3,707
  • 9
  • 50
  • 78

1 Answers1

0

The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

As the setup manual says

To make the Google Play services APIs available to your app, you must reference the library project you created in step 4 of the installation instructions.

Not just the jar.

Yaroslav Mytkalyk
  • 16,950
  • 10
  • 72
  • 99