Shopify / unity-buy-sdk

The Unity Buy SDK allows Unity developers to query and sell products from Shopify directly in Unity.
https://help.shopify.com/api/sdks/custom-storefront/unity-buy-sdk
MIT License
67 stars 23 forks source link

Problem with WebView - Android #585

Open kingmoge opened 5 years ago

kingmoge commented 5 years ago

The problem: The app works fine in the editor - checkoutwithwebview opens a web browser with the cart page. If I compile and run on my android phone, the app runs fine with the exception that the webview will not load. The app does not crash, but the webview will not load. In the debugger, I can see the error noted below.

If I make another project with just Shopify and no other 3rd party extensions, I can compile to my phone and it runs as expected, no errors, and the webview loads over the app.

The error... java.lang.ClassNotFoundException: Didn't find class "android.support.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/com.ARQ

Very little comes up in a Google search, but the following article makes me think there's some incompatibility with the Facebook SDK which is also installed... stackoverflow (near the bottom of the error list you'll find a similar error) This article was found with a search for... java.lang.ClassNotFoundException: Didn't find class "android.support.customtabs.CustomTabsIntent$Builder" on path: DexPathList

I have a feeling that the fix might be outside of Unity and in the Android wrapper or something, but I know nothing of such things and I'm hoping maybe someone can point me in the right direction.

More complete version of the error...

10-23 12:52:50.856: D/Unity(24867): Uploading Crash Report 10-23 12:52:50.856: E/Unity(24867): AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/customtabs/CustomTabsIntent$Builder; 10-23 12:52:50.856: E/Unity(24867): java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/customtabs/CustomTabsIntent$Builder; 10-23 12:52:50.856: E/Unity(24867): at com.shopify.buy.web.WebCheckoutLauncher.launchChromeTab(WebCheckoutLauncher.java:114) 10-23 12:52:50.856: E/Unity(24867): at com.shopify.buy.web.WebCheckoutLauncher.launchBrowserUsingMethod(WebCheckoutLauncher.java:82) 10-23 12:52:50.856: E/Unity(24867): at com.shopify.buy.web.WebCheckoutSession.checkout(WebCheckoutSession.java:49) 10-23 12:52:50.856: E/Unity(24867): at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 10-23 12:52:50.856: E/Unity(24867): at com.unity3d.player.UnityPlayer.c(Unknown Source:0) 10-23 12:52:50.856: E/Unity(24867): at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:88) 10-23 12:52:50.856: E/Unity(24867): at android.os.Handler.dispatchMessage(Handler.java:101) 10-23 12:52:50.856: E/Unity(24867): at android.os.Looper.loop(Looper.java:164) 10-23 12:52:50.856: E/Unity(24867): at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) 10-23 12:52:50.856: E/Unity(24867): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/com.ARQ

EdwinMurari commented 4 years ago

Hey, did you come across a solution for this? I am running into the same issue.

kingmoge commented 4 years ago

I can't say I exactly figured it out, however, while trying to fix a different but somewhat similar issue it sort of resolved itself, after...

Updated java, which broke a bunch of things, which led to me... Removing and re-installing Google Play Services Creating a new Keystore (old one got corrupted) Completely resetting Facebook plugin Removing and re-installing Substance plugin

I can't say which of these (or if was all of these) that did the trick, but recommend spending a couple hours re-installing anything third party. It cleared up a few issues I was having.

EdwinMurari commented 4 years ago

Hmmm...thats strange, I will try something similar. Thank you for your help.

Edit: I think this has something to do with the androidX migration, the shopify android plugins target SDK 27.

kingmoge commented 4 years ago

@EdwinMurari I'm at a point where I need to use a few plugins targeting adroidX, so I'm back to breaking the Shopify plugin (won't open a webview). Did you find a way to update shopify to androidx? Thanks!

EdwinMurari commented 4 years ago

I still couldn't solve this, I am using this (https://docs.unity3d.com/ScriptReference/Application.OpenURL.html) for now, works fine. The only issue I am facing here is that there is no callback to see whether the user checked out successfully or not.

kingmoge commented 4 years ago

Ah, that's unfortunately a really big issue. Thanks for the reply!

ypattaphongse commented 3 years ago

Way to fix that I found.

1.Make sure Jetifier is selected. (Assets/External Dependency Manager/Andriod Resolver/Settings) 2.Go To Build Setting/Publishing Settings ---> select Custom Gradle Properties Template Checkbox 3.Let Resolve (Assets/External Dependency Manager/Andriod Resolver/Resolve) 4.Check File gradleTemplate.properties, It shoud have 2 line add.(If not add by yourself)

android.useAndroidX=true android.enableJetifier=true

5.Build and Test