Unity 3D 插件的 Google Drive 授权错误
Posted
技术标签:
【中文标题】Unity 3D 插件的 Google Drive 授权错误【英文标题】:Google Drive Authorization Error with Unity 3D plugin 【发布时间】:2014-06-02 10:32:58 【问题描述】:我在使用适用于 android 应用的 Google Drive 服务时遇到问题。 这是一个 Unity 3D 项目,其中包含一个使用 Google Drive API https://github.com/midworld/unity-googledrive的插件
我已经在 PC 版本上使用了该插件,它工作正常。 Oauth2授权工作,我得到一个工作令牌,我可以从登录的谷歌用户帐户的谷歌驱动器写入,删除,下载等文件。在 PC 上,该插件使用网络请求与 google drive 通信。
但是当我尝试在 Android 设备上使用该插件时,我无法授权并从 google 服务获取 Oauth2 令牌。在 Android 设备上,插件使用 google drive 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>
【问题讨论】:
类似问题:***.com/questions/20251189/… 【参考方案1】:我找到了解决方案。 在统一 3D 中,我还必须说明 Unity 应该使用什么密钥库和捆绑包来签署我的 apk 文件。
所以在“编辑 -> 项目设置 -> 播放器”下,然后在“Android -> 发布设置”部分中,我必须浏览我正在使用的密钥库并输入密钥库的密码。还要选择“别名”并再次输入密码
此外,在“Android 部分 -> 其他设置”中,我必须从 google 开发者控制台将“Bundle Identifier”设置为我的包名称。
现在使用 OAuth2 令牌进行身份验证工作,我可以使用谷歌驱动器。
【讨论】:
以上是关于Unity 3D 插件的 Google Drive 授权错误的主要内容,如果未能解决你的问题,请参考以下文章
在Unity3d中使用Google.ProtocolBuffers
Unity、Torque3D、Google O3D、WebGl....选择哪个? [关闭]
在使用 Firebase 身份验证的 Unity 项目中使用 Google Drive API
Unity3D 集成 Google Play Game Service和Google In-app pucharse
与 android manifest 上的活动标签冲突:Unity3d 中的 Facebook 和 Google Play 游戏