Android-related operations of existing projects introduced Flutter

Flutter official instructions (at this stage in the preview stage): https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps

Introducing specific steps:

First, in the same directory existing android project, use

flutter create -tmoduleflutter_module

Which is the module name flutter_module

After this operation, the module will generate to flutter_module android project under the same directory

Second, android engineering settings.gradle, the above reflection module configured as follows:

setBinding(new Binding([gradle:this]))

evaluate(new File(

settingsDir.parentFile,

'flutter_module/.android/include_flutter.groovy'

))

Click simultaneous engineering

And build.gradle file in android app, the introduction project above configuration,

Note: Minimum android version 16, using java 8     

compileOptions {

sourceCompatibility JavaVersion.VERSION_1_8

targetCompatibility JavaVersion.VERSION_1_8

}

implementation(project(':flutter'),{

excludegroup:'com.android.support'

})}

This completes the existing Android project introduced Flutter project.

Three, Flutter hot reload debugging

AS import Flutter project, modify the code to flutter in a new window.

In android window, run the app, executed in the terminal 

flutter attach

If there are multiple devices, the device needs to be specified, such as:

flutter attach -d 1888bed1

Wherein the device identification 1888bed1

After modifying the code flutter, just click on the 'R' key in the terminal is android Engineering hot reload

Guess you like

Origin blog.csdn.net/weixin_34257076/article/details/90778124