Flutter 应用程序在调用 Android 本机代码时生成:Error inflateing class com.google.android.material.appbar.AppBarLayout

问题描述 投票:0回答:0

我正在尝试在我的 App Flutter 上实现 ZenDesk。


import android.os.Bundle
import androidx.annotation.NonNull
import androidx.core.view.WindowCompat
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import zendesk.support.request.RequestActivity;
import zendesk.core.Zendesk;
import zendesk.support.Support;


class MainActivity: FlutterActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        WindowCompat.setDecorFitsSystemWindows(getWindow(), false)
    }

    override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
      super.configureFlutterEngine(flutterEngine)
      MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "zen_desk_channel").setMethodCallHandler {
        call, result ->
          if (call.method == "openZenDeskChat") {
            initZenDesk()
          } else {
            result.notImplemented()
          }
      }
    }
    

    private fun initZenDesk() {
      Zendesk.INSTANCE.init(this, "url",
        "app_id",
        "o_auth_client_id")
      Support.INSTANCE.init(Zendesk.INSTANCE)
      openZenDeskChat()
    }

    private fun openZenDeskChat() {
       RequestActivity.builder().show(context);
    }

    
}

dependencies {
    def appcompat_version = "1.6.1"
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "androidx.appcompat:appcompat:$appcompat_version"
    // For loading and tinting drawables on older versions of the platform
    implementation "androidx.appcompat:appcompat-resources:$appcompat_version"
    implementation group: 'com.zendesk', name: 'support', version: '5.1.2'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.zendesk.belvedere2:belvedere:3.0.5'
}

这是我的 Flutter 和 Android 版本

[✓] Flutter (Channel stable, 3.10.6, on macOS 13.3.1 22E261 darwin-arm64, locale en-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.80.1)
     java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.flowing/zendesk.support.request.RequestActivity}: android.view.InflateException: Binary XML file line #13 in br.com.flowing:layout/zs_activity_request: Binary XML file line #13 in br.com.flowing:layout/zs_activity_request: Error inflating class com.google.android.material.appbar.AppBarLayout

我已经按照建议降级了材质,我插入了android 12的stylesv31文件,但是它无法识别Material的这个AppBarLayout

flutter kotlin dart channel
© www.soinside.com 2019 - 2024. All rights reserved.