4

我使用这个快速入门示例https://developers.google.com/drive/quickstart-android

Logcat 显示

03-21 14:44:36.213: E/AndroidRuntime(26394): FATAL EXCEPTION: Thread-1867
03-21 14:44:36.213: E/AndroidRuntime(26394): java.lang.NullPointerException
03-21 14:44:36.213: E/AndroidRuntime(26394):    at java.net.URI.parseURI(URI.java:353)
03-21 14:44:36.213: E/AndroidRuntime(26394):    at java.net.URI.<init>(URI.java:204)
03-21 14:44:36.213: E/AndroidRuntime(26394):    at com.google.api.client.http.GenericUrl.<init>(GenericUrl.java:100)
03-21 14:44:36.213: E/AndroidRuntime(26394):    at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:269)
03-21 14:44:36.213: E/AndroidRuntime(26394):    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:408)
03-21 14:44:36.213: E/AndroidRuntime(26394):    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:328)
03-21 14:44:36.213: E/AndroidRuntime(26394):    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:449)
03-21 14:44:36.213: E/AndroidRuntime(26394):    at com.mysample.google.GoogleDrive$1.run(GoogleDrive.java:161)
03-21 14:44:36.213: E/AndroidRuntime(26394):    at java.lang.Thread.run(Thread.java:856)

GoogleDrive.java:161 是

File file = service.files().insert(body, mediaContent).execute();

我已经在 Google API 控制台上打开了 Drive API 和 Drive SDK。我还在 AndroidManifest.xml 添加了这些行

<meta-data android:name="com.google.android.apps.drive.APP_ID" android:value="id=MY_APP_ID" />
<intent-filter>
    <action android:name="android.intent.action.GoogleDrive" />
    <data android:mimeType="image/png" />
    <data android:mimeType="image/jpeg" />
    <data android:mimeType="image/jpg" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

感谢您的帮助。

4

0 回答 0