【问题标题】:Flutter - Keyboard not showing up in android 12 devicesFlutter - 键盘未出现在 android 12 设备中
【发布时间】:2021-12-13 06:41:38
【问题描述】:

Android 12 设备未显示键盘,覆盖显示键盘已打开但未显示任何内容。它适用于较旧的 android 版本。

键盘在其他应用程序中运行良好,并且在具有 Android 12 以外的 android 版本的模拟器上也可以正常运行。在物理设备上也尝试过 Pixel 与 android 12 面临同样的问题。

flutter 医生代码 -

flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale en-IN)
    • Flutter version 2.2.3 at /Users/uable/Downloads/flutter
    • Framework revision f4abaa0735 (4 months ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/uable/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/uable/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/uable/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    • CocoaPods version 1.10.2

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

[✓] Android Studio (version 4.1)
    • 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 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (2 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 12 (API 31) (emulator)
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 95.0.4638.54

! Doctor found issues in 1 category.

下面是带有键盘的简单文本字段的图像,已尝试更改文本字段的所有属性。它是一个现有的应用程序,因此尝试测试现有的文本字段,即使在那些显示相同行为的文本字段中也是如此。

android gradle 设置

    minSdkVersion 24
    targetSdkVersion 30

【问题讨论】:

  • 嗨,Sharan,你修复了这个错误吗?我也面临同样的问题!
  • @Abdel 是的,你必须在 android 清单文件中设置 android:hardwareAccelerated="true"
  • 我有同样的问题,只是尝试添加 android:hardwareAccelerated="true" 但它似乎没有产生任何影响。在我的情况下,它是一个 Flutter webview 没有触发键盘显示。
  • 遇到与@theLastNightTrain 完全相同的问题:android:hardwareAccelerated="true" 标志设置正确,我的 web 视图没有显示它们的键盘...(不过,仅在 android 12 上,在物理设备上。 ..)
  • 所以在物理 android 12 设备上,在 web 视图中,为我解决的问题是使用 (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();。基本上,将 webview 置于混合组合模式(参见pub.dev/packages/webview_flutter

标签: android flutter keyboard


【解决方案1】:

我认为这个错误是因为这个模拟器错误与系统 UI,你可以擦除模拟器的数据然后再次运行

【讨论】:

    【解决方案2】:

    转到android模拟器-->工具--> AVD Manager-->选择你正在运行的设备和wipedata并再次运行。

    如果它不起作用,请选择其他设备并尝试。

    不确定,可能是simulator的问题。

    【讨论】:

    • 键盘在其他应用程序中运行良好,并且也适用于具有除 Android 12 以外的 android 版本的模拟器。尝试使用物理设备 Pixel 也遇到同样问题的 android 12。
    • @SharanSingh 你找到解决方案了吗?
    【解决方案3】:

    作为webview flutter的官方文档 放

    if (Platform.isAndroid) WebView.platform = AndroidWebView();
    

    在你的Main.dart

    enter image description here

    【讨论】:

      猜你喜欢
      • 2016-12-31
      • 2020-04-28
      • 2020-04-22
      • 2022-01-09
      • 2022-09-28
      • 2021-06-15
      • 1970-01-01
      • 2018-09-11
      • 1970-01-01
      相关资源
      最近更新 更多