Example that builds a Flutter Android app using Gradle

This commit is contained in:
Jason Simmons
2016-03-11 16:30:56 -08:00
parent bedd8e9131
commit d9f66d9e14
13 changed files with 262 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/widgets.dart';
void main() => runApp(new Center(child: new Text('Hello from Flutter!')));

View File

@@ -0,0 +1,4 @@
name: gradle
dependencies:
flutter:
path: ../../../../../packages/flutter

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutter"
android:versionCode="1"
android:versionName="1.0.0" >
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET"/>
<application android:name="org.domokit.sky.shell.SkyApplication" android:label="@string/app_name" >
<activity
android:name=".FlutterActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,39 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package com.example.flutter;
import android.app.Activity;
import android.os.Bundle;
import org.chromium.base.PathUtils;
import org.domokit.sky.shell.SkyApplication;
import org.domokit.sky.shell.SkyMain;
import org.domokit.sky.shell.PlatformViewAndroid;
import java.io.File;
public class FlutterActivity extends Activity {
private PlatformViewAndroid flutterView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SkyMain.ensureInitialized(getApplicationContext(), null);
setContentView(R.layout.flutter_layout);
flutterView = (PlatformViewAndroid) findViewById(R.id.flutter_view);
File appBundle = new File(PathUtils.getDataDirectory(this), SkyApplication.APP_BUNDLE);
flutterView.runFromBundle(appBundle.getPath(), null);
}
@Override
protected void onDestroy() {
if (flutterView != null) {
flutterView.destroy();
}
super.onDestroy();
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/text_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/title"
/>
<org.domokit.sky.shell.PlatformViewAndroid
android:id="@+id/flutter_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Flutter App</string>
<string name="title">Flutter Application</string>
</resources>