找不到io.flutter.facade颤动

时间:2019-12-17 04:27:14

标签: flutter

我通过调用

将颤动视图集成到现有android应用的片段中
  

Flutter.createView

但是在构建时会引发错误

  

io.flutter.facade软件包不存在

有人知道如何解决吗?谢谢

2 个答案:

答案 0 :(得分:0)

你好,@ Rocky我已经设法从常规活动中开始了扑扑活动。

MainActivity.kt(这是您的主机应用程序类)

 const val FLUTTER_ENGINE = "flutter_engine"

 class MainActivity : AppCompatActivity() {

lateinit var context: Context

private val flutterEngine: FlutterEngine by lazy {
    FlutterEngine(this.applicationContext)
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    init()
}

private fun init() {
    context = this

    flutterEngine.dartExecutor.executeDartEntrypoint(
        DartExecutor.DartEntrypoint.createDefault()
    )

    FlutterEngineCache.getInstance().put(FLUTTER_ENGINE, flutterEngine)


    btnSend.setOnClickListener {
        sendNumbersToFlutter()
    }

}

private fun sendNumbersToFlutter() {
    startActivity(
        FlutterActivity.withCachedEngine(FLUTTER_ENGINE).build(
            context
        )
    )
}

}

关键部分

将此行添加到主机清单中

<activity android:name="io.flutter.embedding.android.FlutterActivity" />

答案 1 :(得分:0)

因为从Flutter 1.12版本中删除了“ io.flutter.facade。*”

查看此处:

https://github.com/flutter/flutter/issues/34458

https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects