flutter create -t module --org com.example my_flutter
android {
//...
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
有两种方式
######(1)无需安装flutter sdk
Flutter库打包为由AAR和POM工件组成的通用本地Maven存储库,
######(2) 需要安装sdk
原生settings.gradle下添加
// Include the host app project.
include ':app' // assumed existing content
setBinding(new Binding([gradle: this])) // new
evaluate(new File( // new
settingsDir.parentFile, // new
'my_flutter/.android/include_flutter.groovy' // new
))
原生build.gradle下
dependencies {
implementation project(':flutter')
}
<activity
android:name="io.flutter.embedding.android.FlutterActivity"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
/>
@style/LaunchTheme 修改
package com.example.myapplication
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//setContentView(R.layout.activity_main)
FlutterActivity.createDefaultIntent(this)
startActivity(
FlutterActivity
.withNewEngine()
.initialRoute("/")
.build(this)
)
}
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。