无法成功运行Google云端硬盘GDAA演示应用

时间:2017-02-10 16:40:18

标签: android google-drive-api google-play-services google-drive-android-api

我无法成功执行示例Google云端硬盘应用。当我在我的Moto X上运行应用程序时,我收到以下错误:

I/DriveDemo: GoogleApiClient connection failed: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{867e070: android.os.BinderProxy@13cdfe9}, message=null}

到目前为止我采取的步骤:

  1. 创建了OAuth证书。
  2. 启用了Google云端硬盘API。
  3. 按照https://developers.google.com/identity/sign-in/android/start-integrating上的说明进行整合登录。
  4. 将client_id.json移至app目录
  5. 的manifest.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.lightkeeper54.chuck.drivedemo" >
        <uses-permission android:name="android.permission.GET_ACCOUNTS" />
        <uses-permission android:name="android.permission.INTERNET" />
        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:supportsRtl="true"
            android:theme="@style/AppTheme" >
            <activity android:name=".MainActivity" >
                <meta-data android:name="com.google.android.apps.drive.APP_ID" android:value="id=MY_ID" />
    
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
                <intent-filter>
                    <action android:name="com.google.android.apps.drive.DRIVE_OPEN" />
                    <data android:mimeType="application/vnd.google-apps.drive-sdk.MY_ID" />
                </intent-filter>
            </activity>
        </application>
    
    </manifest>
    

    MY_ID是API Manager凭据屏幕中的数字ID,使用数字前缀直到客户端ID中的连字符。我不清楚这是否正确,因为我无法找到关于此的更多信息。

    build.gradle(project)

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.2.3'
            classpath 'com.google.gms:google-services:3.0.0'
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    build.gradle(app)

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 24
        buildToolsVersion "25.0.1"
        defaultConfig {
            applicationId "com.lightkeeper54.chuck.drivedemo"
            minSdkVersion 22
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.google.android.gms:play-services:10.0.1'
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        testCompile 'junit:junit:4.12'
        }
    apply plugin: 'com.google.gms.google-services'
    

    我做错了什么?

0 个答案:

没有答案