我的Android应用的Google云端硬盘服务出现问题。 这是一个Unity 3D项目,其中包含一个使用Google Drive API的插件https://github.com/midworld/unity-googledrive
我已经在PC版本上使用了该插件,它运行正常。 Oauth2授权有效,我得到了一个工作令牌,我可以从登录的Google用户帐户的Google云端硬盘中编写,删除,下载等文件。在PC上,该插件使用网络请求与谷歌驱动器进行通信。
但是当我尝试在Android设备上使用该插件时,我无法授权并从Google服务获取Oauth2令牌。在Android设备上,插件使用google驱动器API。 我认为错误源于我的Manifest.xml,因为我仍然不确定它应该包含什么。
错误讯息:
I/Unity (17269): Start Authorization
D/Unity-GoogleDrivePlugin(17269): setUnityActivity: com.unity3d.player.UnityPlayerNativeActivity@423bbdd0
D/Unity-GoogleDrivePlugin(17269): auth with accountName: dino******@******.com
W/AbstractGoogleClient(17269): Application name is not set. Call Builder#setApplicationName.
D/Unity-GoogleDrivePlugin(17269): google drive service: com.google.api.services.drive.Drive@423aa280
W/dalvikvm(17269): VFY: unable to resolve static field 634 (auth_client_play_services_err_notification_msg) in Lcom/google/android/gms/R$string;
D/dalvikvm(17269): VFY: replacing opcode 0x60 at 0x001a
I/dalvikvm(17269): DexOpt: unable to optimize static field ref 0x027b at 0x42 in Lcom/google/android/gms/auth/GoogleAuthUtil;.a
I/dalvikvm(17269): DexOpt: unable to optimize static field ref 0x0279 at 0x4d in Lcom/google/android/gms/auth/GoogleAuthUtil;.a
W/dalvikvm(17269): VFY: unable to resolve static field 642 (common_google_play_services_install_title) in Lcom/google/android/gms/R$string;
D/dalvikvm(17269): VFY: replacing opcode 0x60 at 0x0041
W/dalvikvm(17269): VFY: unable to resolve static field 638 (common_google_play_services_enable_title) in Lcom/google/android/gms/R$string;
D/dalvikvm(17269): VFY: replacing opcode 0x60 at 0x004c
W/dalvikvm(17269): VFY: unable to resolve static field 648 (common_google_play_services_update_title) in Lcom/google/android/gms/R$string;
D/dalvikvm(17269): VFY: replacing opcode 0x60 at 0x0057
W/dalvikvm(17269): VFY: unable to resolve static field 645 (common_google_play_services_unsupported_title) in Lcom/google/android/gms/R$string;
D/dalvikvm(17269): VFY: replacing opcode 0x60 at 0x0069
W/dalvikvm(17269): VFY: unable to resolve static field 639 (common_google_play_services_install_button) in Lcom/google/android/gms/R$string;
D/dalvikvm(17269): VFY: replacing opcode 0x60 at 0x0009
W/dalvikvm(17269): VFY: unable to resolve static field 636 (common_google_play_services_enable_button) in Lcom/google/android/gms/R$string;
D/dalvikvm(17269): VFY: replacing opcode 0x60 at 0x0010
W/dalvikvm(17269): VFY: unable to resolve static field 646 (common_google_play_services_update_button) in Lcom/google/android/gms/R$string;
D/dalvikvm(17269): VFY: replacing opcode 0x60 at 0x0017
W/dalvikvm(17269): VFY: unable to resolve static field 643 (common_google_play_services_unknown_issue) in Lcom/google/android/gms/R$string;
D/dalvikvm(17269): VFY: replacing opcode 0x60 at 0x0004
I/dalvikvm(17269): DexOpt: unable to optimize static field ref 0x0281 at 0x18 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.c
I/dalvikvm(17269): DexOpt: unable to optimize static field ref 0x0280 at 0x38 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.c
I/dalvikvm(17269): DexOpt: unable to optimize static field ref 0x027d at 0x3f in Lcom/google/android/gms/common/GooglePlayServicesUtil;.c
I/dalvikvm(17269): DexOpt: unable to optimize static field ref 0x0287 at 0x46 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.c
I/dalvikvm(17269): DexOpt: unable to optimize static field ref 0x0284 at 0x66 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.c
W/GLSUser ( 5447): GoogleAccountDataService.getToken()
W/GLSActivity( 5447): [art] Status from wire: INVALID_KEY status: null
W/GLSActivity( 5447): [art] Status from wire: INVALID_KEY status: null
I/GLSUser ( 5447): GLS error: INVALID_KEY dino******@******.com oauth2:https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.appdata
W/GLSActivity( 5447): [art] Status from wire: Unknown status: UNKNOWN
E/Unity-GoogleDrivePlugin(17269): checkAuthorized: com.google.android.gms.auth.GoogleAuthException: Unknown
I/Unity (17269): GoogleDrive+Exception: Authorization failed.
我的宣言:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="preferExternal"
package="com.studio272.unitydrivetest"
android:versionName="1.0"
android:versionCode="1">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
<application
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:debuggable="false">
<activity
android:name="com.unity3d.player.UnityPlayerProxyActivity"
android:label="@string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.unity3d.player.UnityPlayerActivity"
android:label="@string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:screenOrientation="portrait">
</activity>
<activity
android:name="com.unity3d.player.UnityPlayerNativeActivity"
android:label="@string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:screenOrientation="portrait">
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
</activity>
<activity
android:name="com.unity3d.player.VideoPlayer"
android:label="@string/app_name"
android:screenOrientation="behind"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
</activity>
<activity
android:name="com.studio272.googledriveplugin.GoogleDrivePluginActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<meta-data android:name="com.google.android.apps.drive.APP_ID" android:value="id=318737920467" />
</activity>
</application>
<uses-feature android:glEsVersion="0x00020000" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
</manifest>
答案 0 :(得分:1)
我找到了解决方案。 在统一3D中,我还要说明密钥库和Bundle Unity应该用什么来签署我的apk文件。
在“编辑 - &gt;项目设置 - >播放器”下,然后在“Android - &gt;发布设置”部分中,我不得不浏览我正在使用的密钥库并输入密钥库的密码。同时选择“别名”并再次输入密码
此外,在“Android部分 - &gt;其他设置”中,我必须将“捆绑标识符”设置为来自Google开发者控制台的我的包名称。
现在使用OAuth2令牌进行身份验证可以使用,我可以使用google驱动器。