File tree Expand file tree Collapse file tree 13 files changed +262
-0
lines changed
resources/META-INF/gradle-plugins Expand file tree Collapse file tree 13 files changed +262
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Example of building a Flutter app for Android using Gradle
2
+
3
+ This project demonstrates how to embed Flutter within an Android application
4
+ and build the Android and Flutter components with Gradle.
5
+
6
+ To build this project:
7
+
8
+ * Create a ` local.properties ` file with these entries:
9
+ * ` sdk.dir=[path to the Android SDK] `
10
+ * ` flutter.sdk=[path to the Flutter SDK] `
11
+ * ` flutter.jar=[path to the flutter.jar file in your build of the Flutter engine] `
12
+
13
+ Then run:
14
+
15
+ * ` gradle wrapper `
16
+ * ` ./gradlew build `
Original file line number Diff line number Diff line change
1
+ apply plugin : ' com.android.application'
2
+ apply plugin : ' flutter'
3
+
4
+ android {
5
+ compileSdkVersion 22
6
+ buildToolsVersion ' 22.0.1'
7
+
8
+ lintOptions {
9
+ disable ' InvalidPackage'
10
+ }
11
+ }
12
+
13
+ flutter {
14
+ source ' src/flutter'
15
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2016 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import 'package:flutter/widgets.dart' ;
6
+
7
+ void main () => runApp (new Center (child: new Text ('Hello from Flutter!' )));
Original file line number Diff line number Diff line change
1
+ name : gradle
2
+ dependencies :
3
+ flutter :
4
+ path : ../../../../../packages/flutter
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <manifest xmlns : android =" http://schemas.android.com/apk/res/android"
3
+ package =" com.example.flutter"
4
+ android : versionCode =" 1"
5
+ android : versionName =" 1.0.0" >
6
+
7
+ <uses-sdk android : minSdkVersion =" 16" android : targetSdkVersion =" 21" />
8
+ <uses-permission android : name =" android.permission.INTERNET" />
9
+
10
+ <application android : name =" org.domokit.sky.shell.SkyApplication" android : label =" @string/app_name" >
11
+ <activity
12
+ android : name =" .FlutterActivity"
13
+ android : label =" @string/app_name"
14
+ android : configChanges =" orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
15
+ android : launchMode =" singleTask"
16
+ android : theme =" @android:style/Theme.Black.NoTitleBar"
17
+ android : windowSoftInputMode =" adjustResize" >
18
+ <intent-filter >
19
+ <action android : name =" android.intent.action.MAIN" />
20
+ <category android : name =" android.intent.category.LAUNCHER" />
21
+ </intent-filter >
22
+ </activity >
23
+ </application >
24
+
25
+ </manifest >
Original file line number Diff line number Diff line change
1
+ // Copyright 2016 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ package com .example .flutter ;
6
+
7
+ import android .app .Activity ;
8
+ import android .os .Bundle ;
9
+
10
+ import org .chromium .base .PathUtils ;
11
+ import org .domokit .sky .shell .SkyApplication ;
12
+ import org .domokit .sky .shell .SkyMain ;
13
+ import org .domokit .sky .shell .PlatformViewAndroid ;
14
+
15
+ import java .io .File ;
16
+
17
+ public class FlutterActivity extends Activity {
18
+ private PlatformViewAndroid flutterView ;
19
+
20
+ @ Override
21
+ public void onCreate (Bundle savedInstanceState ) {
22
+ super .onCreate (savedInstanceState );
23
+
24
+ SkyMain .ensureInitialized (getApplicationContext (), null );
25
+ setContentView (R .layout .flutter_layout );
26
+
27
+ flutterView = (PlatformViewAndroid ) findViewById (R .id .flutter_view );
28
+ File appBundle = new File (PathUtils .getDataDirectory (this ), SkyApplication .APP_BUNDLE );
29
+ flutterView .runFromBundle (appBundle .getPath (), null );
30
+ }
31
+
32
+ @ Override
33
+ protected void onDestroy () {
34
+ if (flutterView != null ) {
35
+ flutterView .destroy ();
36
+ }
37
+ super .onDestroy ();
38
+ }
39
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <LinearLayout xmlns : android =" http://schemas.android.com/apk/res/android"
3
+ android : orientation =" vertical"
4
+ android : layout_width =" fill_parent"
5
+ android : layout_height =" fill_parent"
6
+ >
7
+ <TextView
8
+ android : id =" @+id/text_view"
9
+ android : layout_width =" fill_parent"
10
+ android : layout_height =" wrap_content"
11
+ android : text =" @string/title"
12
+ />
13
+ <org .domokit.sky.shell.PlatformViewAndroid
14
+ android : id =" @+id/flutter_view"
15
+ android : layout_width =" fill_parent"
16
+ android : layout_height =" fill_parent"
17
+ />
18
+ </LinearLayout >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <resources >
3
+ <string name =" app_name" >Flutter App</string >
4
+ <string name =" title" >Flutter Application</string >
5
+ </resources >
Original file line number Diff line number Diff line change
1
+ buildscript {
2
+ repositories {
3
+ jcenter()
4
+ }
5
+
6
+ dependencies {
7
+ classpath ' com.android.tools.build:gradle:1.5.0'
8
+ }
9
+ }
10
+
11
+ task clean (type : Delete ) {
12
+ delete rootProject. buildDir
13
+ }
14
+
15
+ task wrapper (type : Wrapper ) {
16
+ gradleVersion = ' 2.8'
17
+ }
Original file line number Diff line number Diff line change
1
+ repositories {
2
+ jcenter()
3
+ }
4
+
5
+ dependencies {
6
+ compile " com.android.tools.build:gradle:1.5.0"
7
+ }
You can’t perform that action at this time.
0 commit comments