Giter VIP home page Giter VIP logo

Comments (21)

cdecron avatar cdecron commented on June 10, 2024 1

Hello,
I'll keep you updated if I find a solution. Also I'm going to create a new thread.

By the way, do you test your app on Desktop, with Unity Editor, before testing it on mobile?
That was I used to do, but with new recent updates I made, now I can't auth through Google (cf. this thread).
Maybe you have some thoughts about this!

Thank you :)

from unity-google-drive.

elringus avatar elringus commented on June 10, 2024

Make sure to use latest versions of the auth libs.

from unity-google-drive.

DavidJH2 avatar DavidJH2 commented on June 10, 2024

I ran into this exact issue a while back. Sorry, I should have written up a StackOverflow answer for it.

The problem is that with API 30+ you need to give your app permission to "Query Chrome":

You do this by adding Query to a Custom Manifest:
Query

If you don't give it this permission, when the API tries to query Chrome it can't find the activity

from unity-google-drive.

DavidJH2 avatar DavidJH2 commented on June 10, 2024

Make sure to use latest versions of the auth libs.

What and where are the 'auth libs'?

from unity-google-drive.

elringus avatar elringus commented on June 10, 2024

https://github.com/Elringus/UnityGoogleDrive/blob/master/Assets/UnityGoogleDrive/Editor/Dependencies.xml

from unity-google-drive.

elringus avatar elringus commented on June 10, 2024

Also google play services resolver grabs something, iirc.

from unity-google-drive.

DavidJH2 avatar DavidJH2 commented on June 10, 2024

Hello, and first of all thank you for this plugin.

My Android app throws an exception when the authorization screen should appear. This exception happens only when targetting Android API >= 30. It works perfectly when targeting API 29 and below.

Here is the complete stacktrace:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xyz.xyz/com.elringus.unitygoogledriveandroid.AuthorizationActivity}: android.content.ActivityNotFoundException
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3645)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3782)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7924)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
	Caused by: android.content.ActivityNotFoundException
	at net.openid.appauth.AuthorizationService.prepareAuthorizationRequestIntent(AuthorizationService.java:372)
	at net.openid.appauth.AuthorizationService.getAuthorizationRequestIntent(AuthorizationService.java:267)
	at net.openid.appauth.AuthorizationService.getAuthorizationRequestIntent(AuthorizationService.java:296)
	at com.elringus.unitygoogledriveandroid.AuthorizationActivity.onCreate(AuthorizationActivity.java:50)
	at android.app.Activity.performCreate(Activity.java:8342)
	at android.app.Activity.performCreate(Activity.java:8321)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3626)

Is there a way to fix this? Thank you very much for your answer

Were you able to resolve this issue already?

from unity-google-drive.

DavidJH2 avatar DavidJH2 commented on June 10, 2024

I ran into this exact issue a while back. Sorry, I should have written up a StackOverflow answer for it.

The problem is that with API 30+ you need to give your app permission to "Query Chrome":

You do this by adding Query to a Custom Manifest: Query

If you don't give it this permission, when the API tries to query Chrome it can't find the activity

@elringus, is this the proper way to resolve this issue?

from unity-google-drive.

github-actions avatar github-actions commented on June 10, 2024

This issue is stale because it has been open 14 days with no activity. It will be automatically closed in 7 days.

from unity-google-drive.

cdecron avatar cdecron commented on June 10, 2024

Hello, sorry for my late answer, and thank you for your answers.

Unfortunately, the solution given by @DavidJH2 doesn't work for me: adding the <queries> item in Manifest gives me the same exception.

@elringus, what are the latest version of the auth libs? I'm using 0.7.+ / 1.3.0, as shown in the file you provided

from unity-google-drive.

elringus avatar elringus commented on June 10, 2024

No idea, but definitely above the ones specified in the project.

from unity-google-drive.

cdecron avatar cdecron commented on June 10, 2024

Indeed!
I updated Android AppAuth version to 0.11.1, which seems to be the last one, but I still have the exception. However, this one slightly changed:

AndroidJavaException: java.lang.ClassNotFoundException: com.elringus.unitygoogledriveandroid.AuthorizationActivity$OnAuthorizationResponseListener
java.lang.ClassNotFoundException: com.elringus.unitygoogledriveandroid.AuthorizationActivity$OnAuthorizationResponseListener
	at java.lang.Class.classForName(Native Method)
	at java.lang.Class.forName(Class.java:454)
	at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
	at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
	at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:83)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
	Caused by: java.lang.ClassNotFoundException: com.elringus.unitygoogledriveandroid.AuthorizationActivity$OnAuthorizationResponseListener
	... 9 more
	at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 

Any thoughts on this...?
Thank you

from unity-google-drive.

DavidJH2 avatar DavidJH2 commented on June 10, 2024

Indeed!
I updated Android AppAuth version to 0.11.1, which seems to be the last one, but I still have the exception. However, this one slightly changed:

AndroidJavaException: java.lang.ClassNotFoundException: com.elringus.unitygoogledriveandroid.AuthorizationActivity$OnAuthorizationResponseListener
java.lang.ClassNotFoundException: com.elringus.unitygoogledriveandroid.AuthorizationActivity$OnAuthorizationResponseListener
	at java.lang.Class.classForName(Native Method)
	at java.lang.Class.forName(Class.java:454)
	at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
	at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
	at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:83)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
	Caused by: java.lang.ClassNotFoundException: com.elringus.unitygoogledriveandroid.AuthorizationActivity$OnAuthorizationResponseListener
	... 9 more
	at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 

Any thoughts on this...?
Thank you

Did you delete your Library folder before rebuilding?

Also, are you targeting 33+

from unity-google-drive.

cdecron avatar cdecron commented on June 10, 2024

Ok, so after a lot of tests, it seems that I have solved the problem and discovered some things:

  • In Unity, 'Development build' has to be checked in Build Settings, otherwise exception is always thrown (probably because I don't use Google API in production mode for now, something like this)
  • On Android API <= 29, it works with AppAuth v0.7.+ and with Chrome not installed
  • On Android API > 29, it works with AppAuth v0.7.+ BUT Chrome has to be installed (and <queries> item needs to be included in Manifest)
  • On Android API > 29, it works with AppAuth v0.11.1 AND Chrome doesn't have to be installed (thus <queries> item is useless)

I hope this is a bit clearer now!

from unity-google-drive.

cdecron avatar cdecron commented on June 10, 2024

Unfortunately, my problem is still there because if I uncheck 'Development Build' in Build Settings (what I need to do to upload app on Play Store), even with AppAuth v0.11.1, Chrome installed and <queries> item included, the exception is thrown.
And it's not related to Google API 'Test mode' because I switched to 'Production mode'...
I'm stuck on this right now.

from unity-google-drive.

DavidJH2 avatar DavidJH2 commented on June 10, 2024

Unfortunately, my problem is still there because if I uncheck 'Development Build' in Build Settings (what I need to do to upload app on Play Store), even with AppAuth v0.11.1, Chrome installed and <queries> item included, the exception is thrown. And it's not related to Google API 'Test mode' because I switched to 'Production mode'... I'm stuck on this right now.

I have it working on Android with a published app so I know it's possible.

In that vain, here is my setup:

  1. I HAVE to use Unity 2023.1.17 in order to avoid a weird crash ONLY in Google Play Console testing ONLY on the Pixel 2
  2. I Had to recreate the Custom manifest file by unchecking the box, deleting it and rechecking the box and then re-adding the Queries option (not sure if it's still needed at this point)
  3. I have Chrome installed
  4. Works with Both Dev builds AND Release (I can publish it on the Google Play Store which was a whole thing in itself)
  5. Had to set Stripping level to minimal (Unity 2023.17 was breaking on build at Anything higher

Hope I didn't miss anything.
It took quite a bit of trial and error to get it building so I'm not sure an exact procedure to get it working, but we should be able to get yours building at least for Android and hopefully it will either just work on iOS or you can carry it on to it.

from unity-google-drive.

DavidJH2 avatar DavidJH2 commented on June 10, 2024

Unfortunately, my problem is still there because if I uncheck 'Development Build' in Build Settings (what I need to do to upload app on Play Store), even with AppAuth v0.11.1, Chrome installed and <queries> item included, the exception is thrown. And it's not related to Google API 'Test mode' because I switched to 'Production mode'... I'm stuck on this right now.

If you like, I could help you to troubleshoot this. It was a bit convoluted to get it working on the Published app, but we should be able to resolve it partly by looking at the differences between your project and mine. I had something like 4 separate issues I had to resolve to get it working, one being I HAD to use 2023.1.17.

Let me know if you want me to help you work through it

from unity-google-drive.

cdecron avatar cdecron commented on June 10, 2024

Thank you a lot!
First of all, i'm updating to Unity 2023.1.17 because I was using an older version.
For now I have some errors to fix, but hopefully it will work after the update.

I keep you updated
Thank you again for your help

from unity-google-drive.

cdecron avatar cdecron commented on June 10, 2024

It works!!

Thank you very much for your insights.
I made it work with Unity version 2023.1.17, and with minimal Stripping level.

I did a few tests (Android only), and with AppAuth version 0.11.1, you don't need to have Chrome anymore installed (thus the <queries> item is not needed). Apparently, the opened web page is opened with Firefox on my phone, but I guess it's opening with the default browser.

However, I still have an exception thrown (but it's less annoying), when I close the browser page without choosing the desired Google Account.

Ambiguous overloads found for onAuthorizationResponse with given parameters
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.IntPtr javaArgs) [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) [0x00000] in <00000000000000000000000000000000>:0 
Error Unity Rethrow as TargetInvocationException: UnityGoogleDrive.AndroidAccessTokenProvider+OnAuthorizationResponseListener.onAuthorizationResponse(System.Boolean,null,System.String,System.String,System.String)
Error Unity   at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0 
Error Unity   at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.IntPtr javaArgs) [0x00000] in <00000000000

Maybe you managed to avoid this?
Thank you again

from unity-google-drive.

DavidJH2 avatar DavidJH2 commented on June 10, 2024

It works!!

Thank you very much for your insights. I made it work with Unity version 2023.1.17, and with minimal Stripping level.

I did a few tests (Android only), and with AppAuth version 0.11.1, you don't need to have Chrome anymore installed (thus the <queries> item is not needed). Apparently, the opened web page is opened with Firefox on my phone, but I guess it's opening with the default browser.

However, I still have an exception thrown (but it's less annoying), when I close the browser page without choosing the desired Google Account.

Ambiguous overloads found for onAuthorizationResponse with given parameters
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.IntPtr javaArgs) [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) [0x00000] in <00000000000000000000000000000000>:0 
Error Unity Rethrow as TargetInvocationException: UnityGoogleDrive.AndroidAccessTokenProvider+OnAuthorizationResponseListener.onAuthorizationResponse(System.Boolean,null,System.String,System.String,System.String)
Error Unity   at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0 
Error Unity   at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.IntPtr javaArgs) [0x00000] in <00000000000

Maybe you managed to avoid this? Thank you again

Awesome, good to hear!

I'm not sure about this last exception.
I get it as well. I didn't know about it until now since I haven't reached the point of hard-core testing yet.
I agree, I'm not super concerned about it (yet!) since it seems very sensible. I'll let you know what I find out when I get there unless you find the answer first. Maybe not too far off.
We should create a new issue if it is not just our failiar to error check.

Good work!!

from unity-google-drive.

DavidJH2 avatar DavidJH2 commented on June 10, 2024

Hello, I'll keep you updated if I find a solution. Also I'm going to create a new thread.

By the way, do you test your app on Desktop, with Unity Editor, before testing it on mobile? That was I used to do, but with new recent updates I made, now I can't auth through Google (cf. this thread). Maybe you have some thoughts about this!

Thank you :)

Yes, I do test on Desktop with the Unity Editor. I've yet to have a problem with it.
I'll continue on the other thread

from unity-google-drive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.