midworld / unity-googledrive

Google Drive for Unity3D
Apache License 2.0
121 stars 28 forks source link

Build in android error (proxy method) #31

Closed GuillermoDoradoVide closed 6 years ago

GuillermoDoradoVide commented 6 years ago

Hi! I'm trying to use this plugin as a feature (uploading screenshots to drive taken while playing). While testing in editor works just fine, when I build it in android I get this error: </i> Exception: No such proxy method: UnityEngine.AndroidJavaRunnableProxy.run() at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) [0x0015a] in /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:116 at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, UnityEngine.AndroidJavaObject[] javaArgs) [0x0002c] in /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:124 at UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, IntPtr jmethodName, IntPtr jargs) [0x00066] in /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:762 (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs Line: 116)

The error is located ( I think) before the authorization process. ` IEnumerator InitGoogleDrive() { initInProgress = true;

    drive = new GoogleDrive();

    drive.ClientID = "897584417662-rnkgkl5tlpnsau7c4oc0g2jp08cpluom.apps.googleusercontent.com";

    drive.ClientSecret = "tGNLbYnrdRO2hdFmwJAo5Fbt";

    //drive.ClientID = "897584417662-rnkgkl5tlpnsau7c4oc0g2jp08cpluom.apps.googleusercontent.com";

    //drive.ClientSecret = "tGNLbYnrdRO2hdFmwJAo5Fbt";

    Debug.Log("init googleDrive access");

    drive.Scopes = new string[] {
        "https://www.googleapis.com/auth/drive.file",
        "https://www.googleapis.com/auth/userinfo.email",
        "https://www.googleapis.com/auth/drive.appdata",
    };

    Debug.Log("pre googleDrive authorization");

    var authorization = drive.Authorize();

    yield return StartCoroutine(authorization);

    Debug.Log("doesnt trigger <<----- error");`

I followed the instalation and authorization steps, so I don't know how to solve this problem. PD: It's for a VR daydream game, but I think the problem is with the android configuration.

midworld commented 6 years ago

Hello, I think this link can help you: https://github.com/BranchMetrics/unity-branch-deep-linking/issues/93 Could you please let me know your build options about IL2CPP/Mono and stripping level? Thanks.

GuillermoDoradoVide commented 6 years ago

I'm checking tour link. Here is the data you asked! Scripting Runtime Version > Stable (.NET 3.5 Equivalent) Scripting Backend Mono Api Compatibilirt Level .Net2.0 Stripping Level Disabled

midworld commented 6 years ago

I think your Android app cannot find functions in Java library. Please check following path: unity-googledrive/Assets/Plugins/Android/googledriveplugin.jar on your Unity inspector. It needs check on Android platform: https://docs.unity3d.com/Manual/AndroidJARPlugins.html. I think you can check which library is not loaded on Android log.

GuillermoDoradoVide commented 6 years ago

Okey, I updated my androidSDK (think was missing one of the latest google plugins features) and in the demo proyect is working! But when I try it to work on my VRdaydream game the android-manifest is giving me some trouble and not allowing me to build it to mobile. (If i don't include the android-manifest of your plugin it will build but dont work, An no error will launch. The problem will still be in the authorization process). Anyway, thanks for the help!

midworld commented 6 years ago

Hi, Please add following lines to your custom AndroidManifest.xml to add an activity and get permissions:

<activity android:name="com.studio272.googledriveplugin.GoogleDrivePluginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar">
</activity>

(in <application>)

<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" />

(in <manifest>)

GuillermoDoradoVide commented 6 years ago

I included those lines in all the android-manifest (including cardboard and daydream ones) and the same problem persist. Also now the .apk thinks the app is build for cardboard and not daydream with a notification message.

Android-cardboard manifest:

Android daydream manifest:

` <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.google.vr.cardboard.unity.TreasureHunt" android:installLocation="preferExternal"> <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" /> <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false" android:isGame="true" android:banner="@drawable/app_banner" android:theme="@style/VrActivityTheme"> <activity android:label="@string/app_name" android:name="com.unity3d.player.UnityPlayerActivity" android:screenOrientation="landscape" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale" android:enableVrMode="@string/gvr_vr_mode_component" android:resizeableActivity="false">

        <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
<activity android:name="com.studio272.googledriveplugin.GoogleDrivePluginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar">

`

midworld commented 6 years ago

Your app fails on authorization or doesn't show the authorization popup?

GuillermoDoradoVide commented 6 years ago

It crashes while doing the authorization check. On this step >

Debug.Log("pre googleDrive authorization");

var authorization = drive.Authorize(); yield return StartCoroutine(authorization); Debug.Log("doesnt trigger <<----- error");

It shows the first debug message, but not the second one and the app minimize and reestart.

midworld commented 6 years ago

Ah, that’s good. Could you please upload the crash dump in debug build?

On Tue, Nov 28, 2017 at 7:32 PM Guillermo notifications@github.com wrote:

It crashes while doing the authorization check. On this step >

Debug.Log("pre googleDrive authorization");

var authorization = drive.Authorize(); yield return StartCoroutine(authorization); Debug.Log("doesnt trigger <<----- error");

It shows the first debug message, but not the second one and the app minimize and reestart.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/midworld/unity-googledrive/issues/31#issuecomment-347480838, or mute the thread https://github.com/notifications/unsubscribe-auth/ABnn7IYX5nkNRJn6AiWCH6V3mLcedDEFks5s6-EhgaJpZM4QooLu .

GuillermoDoradoVide commented 6 years ago

Okey, I don´t know how to do that. I'm debugging on android conecting to the editor log. I have to change my debugging configuration or the crash file is beeing generated on a folder?

midworld commented 6 years ago

1) Turn on 'Script Debugging'. image 2) Refer following page(use logcat): https://docs.unity3d.com/Manual/MobileCrashes.html

GuillermoDoradoVide commented 6 years ago

In the logcat: (Now I'm looking at the other methods in the documentation) 11-28 12:40:39.254: W/AbstractGoogleClient(15743): Application name is not set. Call Builder#setApplicationName. 11-28 12:40:39.254: D/Unity-GoogleDrivePlugin(15743): google drive service: com.google.api.services.drive.Drive@83f90b8 11-28 12:40:39.264: W/art(15743): Unresolved exception class when finding catch block: com.google.android.gms.auth.UserRecoverableAuthException 11-28 12:40:39.264: E/AndroidRuntime(15743): FATAL EXCEPTION: Thread-16 11-28 12:40:39.264: E/AndroidRuntime(15743): Process: com.VRAgent.quickstart, PID: 15743 11-28 12:40:39.264: E/AndroidRuntime(15743): java.lang.Error: FATAL EXCEPTION [Thread-16] 11-28 12:40:39.264: E/AndroidRuntime(15743): Unity version : 2017.1.0f3 11-28 12:40:39.264: E/AndroidRuntime(15743): Device model : ZTE ZTE A2017G 11-28 12:40:39.264: E/AndroidRuntime(15743): Device fingerprint: ZTE/P996A04_N/ailsa_ii:7.1.1/NMF26V/20170609.173836:user/release-keys 11-28 12:40:39.264: E/AndroidRuntime(15743): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/auth/GoogleAuthUtil; 11-28 12:40:39.264: E/AndroidRuntime(15743): at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.getToken(GoogleAccountCredential.java:192) 11-28 12:40:39.264: E/AndroidRuntime(15743): at com.studio272.googledriveplugin.GoogleDrivePlugin$1.run(GoogleDrivePlugin.java:178) 11-28 12:40:39.264: E/AndroidRuntime(15743): at java.lang.Thread.run(Thread.java:762) 11-28 12:40:39.264: E/AndroidRuntime(15743): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.auth.GoogleAuthUtil" on path: DexPathList[[zip file "/data/app/com.VRAgent.quickstart-1/base.apk"],nativeLibraryDirectories=[/data/app/com.VRAgent.quickstart-1/lib/arm, /data/app/com.VRAgent.quickstart-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]] 11-28 12:40:39.264: E/AndroidRuntime(15743): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 11-28 12:40:39.264: E/AndroidRuntime(15743): at java.lang.ClassLoader.loadClass(ClassLoader.java:380) 11-28 12:40:39.264: E/AndroidRuntime(15743): at java.lang.ClassLoader.loadClass(ClassLoader.java:312) 11-28 12:40:39.264: E/AndroidRuntime(15743): ... 3 more

midworld commented 6 years ago

You should import Google Play Services in Eclipse or Android Studio. Or you can use this library: https://github.com/playgameservices/play-games-plugin-for-unity