One: Create an android project.
Two: create flutter_libary
Three: Configure flutter
1. The build.gradle maven corresponding to the project
uses the aliyun image to prevent some problems that cannot be found.
allprojects {
repositories {
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://storage.googleapis.com//download.flutter.io'}
}
}
2. The setting.gradle corresponding to the project
setBinding(new Binding([gradle:this]))
//flutter目录
evaluate(new File(
settingsDir.parentFile,
'flutter_library/.android/include_flutter.groovy'
))
new Binding ([gradle:this]) If there is an error, identify the corresponding jar [package groovy.lang.Binding;]
groovy-all-1.3-2.5.12.jar
The gradle version I use is: 7.2-bin, corresponding The file directory, there is no such file
c\Users\user\.gradle\wrapper\dists\gradle-7.2-bin\2dnblmf4td7x66yl1d74lt32g\gradle-7.2\lib\
user --> Corresponding own account name
processing scheme: focus on other versions find. Find this file in ..\gradle-6.7\lib\groovy-all-1.3-2.5.12.jar, copy to gradle-7.2\lib\groovy-all-1.3-2.5.12.jar and you need to
restart android studio.
3. The build.gradle in the app directory is added
implementation project(':flutter')
dependencies {
...
implementation project(':flutter')
}
4.创建 activity : FlutterActivity【Java extends】
import io.flutter.embedding.android.FlutterActivity
class FlutterActivityTest : FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
Real machine operation