GoogleCloudPlatform / recaptcha-enterprise-flutter

Apache License 2.0
23 stars 8 forks source link

Can't use on android off play applications #9

Closed 865102930 closed 1 year ago

865102930 commented 1 year ago

I've set the apikey, I can use it and can also get the token on ios but cant init on android.

[✓] Flutter (Channel unknown, 3.0.0, on macOS 13.3 22E252 darwin-x64, locale zh-Hans-CN) • Flutter version 3.0.0 at /Users/btcc/Development/flutter • Upstream repository unknown • Framework revision ee4e09cce0 (1 year, 1 month ago), 2022-05-09 16:45:18 -0700 • Engine revision d1b9a6938a • Dart version 2.17.0 • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at /Users/btcc/Library/Android/sdk • Platform android-33, build-tools 32.0.0 • Java binary at: /Users/btcc/Library/Java/JavaVirtualMachines/corretto-11.0.18/Contents/Home/bin/java • Java version OpenJDK Runtime Environment Corretto-11.0.18.10.1 (build 11.0.18+10-LTS) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.3

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version 2022.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart ✗ Unable to find bundled Java version. • Try updating or re-installing Android Studio.

I/flutter (21185): Caught exception on init: PlatformException(FL_INIT_FAILED, com.google.android.recaptcha.RecaptchaException: Internal Error, null, null) I/chromium(21185): [INFO:CONSOLE(1)] "Uncaught ReferenceError: recaptcha is not defined", source: https://www.recaptcha.net/recaptcha/api3/mwv (1)

mcorner commented 1 year ago

Would you mind posting the code you are using with the SDK?

Does this happen every time you use it?

865102930 commented 1 year ago

Would you mind posting the code you are using with the SDK?

Does this happen every time you use it?

I use GetX in the app, When I get in the login page and then init Google Recaptcha.

@override
  void onReady() async {
    // TODO: implement onReady

    /// init Google recaptcha
    initClient();

    super.onReady();
}

// step1
void initClient() async {
    try {
      await RecaptchaEnterprise.initClient(Platform.isAndroid ? AppGlobalConfig.captchaKey_android : AppGlobalConfig.captchaKey_ios);
    } on PlatformException catch (err) {
      print('Caught Platform exception on init: code:${err.code}-----msg:${err.message}');
    } catch (error) {
      print('Caught exception on init: $error');
    }
  }

on Android: I/flutter (20348): Caught Platform exception on init: code:FL_INIT_FAILED-----msg:com.google.android.recaptcha.RecaptchaException: Internal Error I/chromium(20348): [INFO:CONSOLE(1)] "Uncaught ReferenceError: recaptcha is not defined", source: https://www.recaptcha.net/recaptcha/api3/mwv (1) E/chromium(20348): [ERROR:aw_browser_terminator.cc(125)] Renderer process (22025) crash detected (code -1).

on iOS: [ViewportSizing] maximumViewportInset cannot be larger than frame [ViewportSizing] minimumViewportInset cannot be larger than frame [ViewportSizing] maximumViewportInset cannot be larger than frame [ViewportSizing] minimumViewportInset cannot be larger than frame

mcorner commented 1 year ago

Thanks for this. Let's see if we can narrow it down more.

This is the interesting line: E/chromium(20348): [ERROR:aw_browser_terminator.cc(125)] Renderer process (22025) crash detected (code -1). It looks like you are running into a Chromium bug, which is pretty odd.

What kind of device/emulator are you running this on?

Can you try running the sample application that is included in the repository on the same device?

Can you try running your app on another device?

865102930 commented 1 year ago

Thanks for this. Let's see if we can narrow it down more.

This is the interesting line: E/chromium(20348): [ERROR:aw_browser_terminator.cc(125)] Renderer process (22025) crash detected (code -1). It looks like you are running into a Chromium bug, which is pretty odd.

What kind of device/emulator are you running this on?

Can you try running the sample application that is included in the repository on the same device?

Can you try running your app on another device?

This error msg show on the device(OPPO A32, Android Version 11, Mode PDVM00)

IMAGE 2023-06-12 16:53:26

it shows a different error msg on another device(HONOR 70)

E/hwschromium-4598(13383): [ERROR:ssl_client_socket_impl.cc(981)] handshake failed; returned -1, SSL error code 1, net_error -202
I/hwschromium-4598(13383): [INFO:aw_ssl_host_state_delegate.cc(287)] QueryPolicy for host: *** cert serial number: 018893909B29 cert subject: misc.google.com cert issuer: Charles Proxy CA (8 三月 2019, 192.168.0.104) cert errorno: -202 this: 0x6a00523100
I/hwschromium-4598(13383): [INFO:aw_ssl_host_state_delegate.cc(301)] QueryPolicy for "***" result is denied
I/hwschromium-4598(13383): [INFO:network_service_network_delegate.cc(246)] final url https//*** error_code -3 ip address: ignored
I/hwbr_engine_a(13383): connectionTypeChanged connectionType = 2, connectionSubType = 0
I/flutter (13383): Caught Platform exception on init: code:FL_INIT_FAILED-----msg:com.google.android.recaptcha.RecaptchaException: Network Error
I/hwbr_engine_a(13383): connectionTypeChanged connectionType = 2, connectionSubType = 0

IMAGE 2023-06-12 16:30:37

mcorner commented 1 year ago

1) At least on your HONOR 70 device you are sending traffic through Charles Proxy and having an SSL error. I am not sure what you are trying to do there, but probably not going to work. Please retry this with a non-proxied device.

2) Please try the example app on your device. I think there is something wrong with this particular device, but we have to narrow it down.

3) You should also try the regular SDK (https://cloud.google.com/recaptcha-enterprise/docs/instrument-android-apps) in a sample app on that device to see if that works for you.

865102930 commented 1 year ago
  1. At least on your HONOR 70 device you are sending traffic through Charles Proxy and having an SSL error. I am not sure what you are trying to do there, but probably not going to work. Please retry this with a non-proxied device.
  2. Please try the example app on your device. I think there is something wrong with this particular device, but we have to narrow it down.
  3. You should also try the regular SDK (https://cloud.google.com/recaptcha-enterprise/docs/instrument-android-apps) in a sample app on that device to see if that works for you.
SDK:3.3.0
V/AudioManager(24736): querySoundEffectsEnabled...
I/SysUtils(24736): hw theme is enabled(false)
I/SysUtils(24736): build factory is HONOR
I/SysUtils(24736): the package isBuildAtLeastMagic6:true
W/SysUtils(24736): Exception--NullPointerException
I/SysUtils(24736): honor theme is enabled(false)
I/AwSettings(24736): selectHandleChangeEnbled(false)
I/hwbr_engine_a(24736): connectionTypeChanged connectionType = 2, connectionSubType = 0
I/SysUtils(24736): build factory is HONOR
I/SysUtils(24736): the package isBuildAtLeastMagic6:true
I/AwSettings(24736): getAdBlockEnabled:false
W/GooglePlayServicesUtil(24736): com.arnia.whk requires the Google Play Store, but it is missing.
I/hwschromium-4598(24736): [INFO:render_frame_host_manager.cc(2080)] HWBFCACHE: should_swap_result = 1
I/hwschromium-4598(24736): [INFO:render_frame_host_manager.cc(1035)] HWBFCACHE: GetSiteInstanceForNavigationRequest reason=DetermineSiteInstanceForURL => current_instance_impl
I/AwSettings(24736): getAdBlockEnabled:false
I/hwbr_engine_a(24736): connectionTypeChanged connectionType = 2, connectionSubType = 0
I/hwbr_engine_ChildProcLauncher(24736): on connect callback, pid=25025
I/hwschromium-4598(24736): [INFO:render_frame_host_manager.cc(2080)] HWBFCACHE: should_swap_result = 1
I/hwschromium-4598(24736): [INFO:render_frame_host_manager.cc(1035)] HWBFCACHE: GetSiteInstanceForNavigationRequest reason=DetermineSiteInstanceForURL => current_instance_impl
I/hwschromium-4598(24736): [INFO:adaptive_relayout_impl.cc(27)] enter ShouldDoAdaptiveRelayout
I/hwschromium-4598(24736): [INFO:adaptive_relayout_impl.cc(37)] exit ShouldDoAdaptiveRelayout, should[0]
W/hwschromium-4598(24736): [WARNING:browser_context.cc(611)] CloudControl BrowserContext::GetControlConfigByUrl cloud control config is empty or unenable
I/flutter (24736): Caught Platform exception on init: code:FL_INIT_FAILED-----msg:com.google.android.recaptcha.RecaptchaException: Key type invalid
I/hwschromium-4598(24736): [INFO:network_service_network_delegate.cc(161)] INFO: resource : https//*** error code: 404

When I configured and run the example, also has the same error msg.

SDK:master
I/Hwaps   (31756): APS: EventAnalyzed: initAPS: version is 11.0.0.4
D/Hwaps   (31756): Fpsrequest create,type:EXACTLY_IDENTIFY
D/Hwaps   (31756): Fpsrequest create,type:EXACTLY_IDENTIFY
D/Hwaps   (31756): Fpsrequest create,type:OPENGL_SETTING
D/Hwaps   (31756): FpsController create
D/Hwaps   (31756): APS: EventAnalyzed: reInitFpsPara :mBaseFps = 120; mMaxFps = 120
D/Hwaps   (31756): APS: EventAnalyzed: registerCallbackInApsManagerService, mPkgName:com.arnia.whk; result = false
W/HwApsManager(31756): HwApsManagerService, registerCallback, start !
V/AudioManager(31756): querySoundEffectsEnabled...
I/WebViewFactory(31756): Loading com.huawei.webview version 12.1.1.324 (code 4598)
D/nativeloader(31756): classloader namespace configured for unbundled product apk. library_path=/system/product/app/HwWebview/lib/arm64:/system/product/app/HwWebview/HwWebview.apk!/lib/arm64-v8a:/system/product/app/HwTriWebviewLib/HwTriWebviewLib.apk!/lib/arm64-v8a:/product/lib64:/system/product/lib64
D/nativeloader(31756): classloader namespace configured for unbundled product apk. library_path=/system/product/app/HwWebview/lib/arm64:/system/product/app/HwWebview/HwWebview.apk!/lib/arm64-v8a:/system/product/app/HwTriWebviewLib/HwTriWebviewLib.apk!/lib/arm64-v8a:/product/lib64:/system/product/lib64
W/com.arnia.whk(31756): Accessing hidden method Landroid/os/Trace;->isTagEnabled(J)Z (unsupported, reflection, allowed)
W/com.arnia.whk(31756): Accessing hidden method Landroid/os/Trace;->traceBegin(JLjava/lang/String;)V (unsupported, reflection, allowed)
W/com.arnia.whk(31756): Accessing hidden method Landroid/os/Trace;->traceEnd(J)V (unsupported, reflection, allowed)
W/com.arnia.whk(31756): Accessing hidden method Landroid/os/Trace;->asyncTraceBegin(JLjava/lang/String;I)V (unsupported, reflection, allowed)
W/com.arnia.whk(31756): Accessing hidden method Landroid/os/Trace;->asyncTraceEnd(JLjava/lang/String;I)V (unsupported, reflection, allowed)
I/hwbr_engine_WVCFactoryProvider(31756): use triwebview:false
I/SysUtils(31756): build factory is HONOR
E/SysUtils(31756): getMagicSdkVersion fail for:java.lang.ClassNotFoundException: com.hihonor.android.os.Build.VERSION
I/SysUtils(31756): magic sdk version by inner class invoke is35
I/SysUtils(31756): the package isBuildAtLeastMagic6:true
I/SysUtils(31756): build factory is HONOR
I/SysUtils(31756): the package isBuildAtLeastMagic6:true
I/hwbr_engine_WVCFactoryProvider(31756): Loaded version=92.0.4515.105 minSdkVersion=29 isBundle=false multiprocess=true packageId=3
I/hwbr_engine_LibraryLoader(31756): loadLibrary: ffmpeg.huawei
I/hwbr_engine_PathUtils(31756): Get data directory:/data/user/0/com.arnia.whk/app_hws_webview
I/hwbr_engine_LibraryLoader(31756): loadLibrary: webviewchromium.huawei
I/hwbr_engine_jni(31756): JNI_OnLoad(0xb400006edfc166d0)
I/hwbr_engine_LibraryLoader(31756): loadLibrary: webviewchromium_plat_support.huawei
I/hwbr_engine_jni(31756): enter JNI_LibraryLoader_LibraryLoaded(3)
I/hwbr_engine_jni(31756): IsUsingOrderfileOptimization
I/hwbr_engine_jni(31756): exit JNI_LibraryLoader_LibraryLoaded
I/hwbr_engine_LibraryLoader(31756): Successfully loaded native library
I/hwbr_engine_CachingUmaRecorder(31756): Flushed 8 samples from 8 histograms.
I/SysUtils(31756): build factory is HONOR
I/SysUtils(31756): the package isBuildAtLeastMagic6:true
I/SysUtils(31756): [variable fonts] cannot get areFontsVariable
I/ApkAssets(31756): prepare to openNonAssetFd:assets/hw/snapshot_blob_32.bin
I/ApkAssets(31756): open apk asset:assets/hw/snapshot_blob_32.bin, return {146, 6533012, 48349}
I/ApkAssets(31756): prepare to openNonAssetFd:assets/hw/snapshot_blob_64.bin
I/ApkAssets(31756): open apk asset:assets/hw/snapshot_blob_64.bin, return {149, 6581428, 49413}
I/ApkAssets(31756): prepare to openNonAssetFd:assets/hw/icudtl.dat
I/ApkAssets(31756): open apk asset:assets/hw/icudtl.dat, return {150, 964, 6531984}
I/ApkAssets(31756): prepare to openNonAssetFd:assets/hw/chrome_100_percent.pak
I/ApkAssets(31756): open apk asset:assets/hw/chrome_100_percent.pak, return {155, 5716, 69822}
I/ApkAssets(31756): prepare to openNonAssetFd:assets/hw/stored-locales/zh-CN.pak
I/ApkAssets(31756): open apk asset:assets/hw/stored-locales/zh-CN.pak, return {156, 3542460, 13634}
I/ApkAssets(31756): prepare to openNonAssetFd:assets/hw/resources.pak
I/ApkAssets(31756): open apk asset:assets/hw/resources.pak, return {157, 75596, 1584424}
I/hwschromium-4598(31756): [INFO:dns_session.cc(52)] DOH-Fallback not enabled.
I/hwschromium-4598(31756): [INFO:url_request_context_builder.cc(661)] Builder updates quic third party tracking enabled 0
I/hwschromium-4598(31756): [INFO:url_request_context_builder.cc(670)] Builder set quic stk expire days 0
I/hwschromium-4598(31756): [INFO:network_service.cc(401)] Register network context and set network timeout 0 second(s)
E/ReflectUtils(31756): No field HW_EXTFLAG_XLAYOUT_ENABLED in class Ljava/lang/Object; (declaration of 'java.lang.Object' appears in /apex/com.android.art/javalib/core-oj.jar)
E/ReflectUtils(31756): No field hw_extra_flags in class Ljava/lang/Object; (declaration of 'java.lang.Object' appears in /apex/com.android.art/javalib/core-oj.jar)
I/SysUtils(31756): [ditto] 0 & 0
E/HwApkAssets(31756): Unable to read assetfile[easygo.json]
I/hwschromium-4598(31756): [INFO:hw_plugin_config.cc(117)] no valid config found in all plugin config files
I/SysUtils(31756): hw theme is enabled(false)
I/SysUtils(31756): build factory is HONOR
I/SysUtils(31756): the package isBuildAtLeastMagic6:true
W/SysUtils(31756): Exception--NullPointerException
I/SysUtils(31756): honor theme is enabled(false)
I/AwSettings(31756): selectHandleChangeEnbled(false)
D/CompatibilityChangeReporter(31756): Compat change id reported: 171228096; UID 10308; state: ENABLED
I/hwschromium-4598(31756): [INFO:aw_ssl_host_state_delegate.cc(164)] AwSSLHostStateDelegate is constructed is_incognito: 0
I/hwbr_engine_a(31756): connectionTypeChanged connectionType = 2, connectionSubType = 0
I/SysUtils(31756): build factory is HONOR
I/SysUtils(31756): the package isBuildAtLeastMagic6:true
I/AwSettings(31756): getAdBlockEnabled:false
W/GooglePlayServicesUtil(31756): com.arnia.whk requires the Google Play Store, but it is missing.
I/hwschromium-4598(31756): [INFO:render_frame_host_manager.cc(2080)] HWBFCACHE: should_swap_result = 1
I/hwschromium-4598(31756): [INFO:render_frame_host_manager.cc(1035)] HWBFCACHE: GetSiteInstanceForNavigationRequest reason=DetermineSiteInstanceForURL => current_instance_impl
W/com.arnia.whk(31756): Accessing hidden method Landroid/media/AudioManager;->getOutputLatency(I)I (unsupported, reflection, allowed)
I/ApkAssets(31756): prepare to openNonAssetFd:assets/hw/snapshot_blob_32.bin
I/ApkAssets(31756): open apk asset:assets/hw/snapshot_blob_32.bin, return {196, 6533012, 48349}
I/ApkAssets(31756): prepare to openNonAssetFd:assets/hw/snapshot_blob_64.bin
I/ApkAssets(31756): open apk asset:assets/hw/snapshot_blob_64.bin, return {186, 6581428, 49413}
I/AwSettings(31756): getAdBlockEnabled:false
I/hwschromium-4598(31756): [INFO:hw_plugin_config.cc(122)] LoadConfig(0, null)
V/AudioManager(31756): isWiredHeadsetOn...
I/hwschromium-4598(31756): [INFO:url_request_context_builder.cc(661)] Builder updates quic third party tracking enabled 1
I/hwschromium-4598(31756): [INFO:url_request_context_builder.cc(670)] Builder set quic stk expire days 0
I/hwschromium-4598(31756): [INFO:network_service.cc(401)] Register network context and set network timeout 0 second(s)
W/hwbr_engine_media(31756): Requires BLUETOOTH permission
I/hwbr_engine_ChildProcLauncher(31756): on connect callback, pid=31905
I/hwbr_engine_a(31756): connectionTypeChanged connectionType = 2, connectionSubType = 0
I/hwschromium-4598(31756): [INFO:render_frame_host_manager.cc(2080)] HWBFCACHE: should_swap_result = 1
I/hwschromium-4598(31756): [INFO:render_frame_host_manager.cc(1035)] HWBFCACHE: GetSiteInstanceForNavigationRequest reason=DetermineSiteInstanceForURL => current_instance_impl
I/hwschromium-4598(31756): [INFO:adaptive_relayout_impl.cc(27)] enter ShouldDoAdaptiveRelayout
I/hwschromium-4598(31756): [INFO:adaptive_relayout_impl.cc(37)] exit ShouldDoAdaptiveRelayout, should[0]
W/hwschromium-4598(31756): [WARNING:browser_context.cc(611)] CloudControl BrowserContext::GetControlConfigByUrl cloud control config is empty or unenable
I/flutter (31756): Caught platform exception on init: PlatformException(FL_INIT_FAILED, com.google.android.recaptcha.RecaptchaException: Key type invalid, null, null)
I/hwschromium-4598(31756): [INFO:network_service_network_delegate.cc(161)] INFO: resource : https//*** error code: 404
[✓] Flutter (Channel master, 3.12.0-3.0.pre.81, on macOS 13.3 22E252 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.12.0-3.0.pre.81 on channel master at /Users/btcc/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5f8000aa75 (82 minutes ago), 2023-06-12 21:51:08 -0400
    • Engine revision d02b15ef34
    • Dart version 3.1.0 (build 3.1.0-201.0.dev)
    • DevTools version 2.24.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/btcc/Library/Android/sdk
    • Platform android-33, build-tools 32.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] Connected device (3 available)
    • FNE AN00 (mobile) • AVKY022721030548 • android-arm64  • Android 12 (API 31)
    • macOS (desktop)   • macos            • darwin-x64     • macOS 13.3 22E252 darwin-x64
    • Chrome (web)      • chrome           • web-javascript • Google Chrome 114.0.5735.106

[✓] Network resources
    • All expected network resources are available.
mcorner commented 1 year ago

Ok, this problem is probably that you have to enable the option in your site key for use on "off play" applications (devices without the Play Store and GMSCore which are frequently found in China). I have adjusted the title of the error report and will improve our docs here: https://cloud.google.com/recaptcha-enterprise/docs/reference/android/com/google/android/recaptcha/RecaptchaErrorCode#INVALID_KEYTYPE

There are a lot of different things in this issue, so I am going to close it, but please open a new issue with a specific issue if there is another one.