diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index f0a7f28b7d..f6d8cfdcc4 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -372,6 +372,7 @@ class AndroidDevice extends Device { BuildInfo buildInfo = debuggingOptions.buildInfo; if (buildInfo.targetPlatform == null && devicePlatform == TargetPlatform.android_arm64) buildInfo = buildInfo.withTargetPlatform(TargetPlatform.android_arm64); + if (!prebuiltApplication) { printTrace('Building APK'); final FlutterProject project = await FlutterProject.current(); diff --git a/packages/flutter_tools/lib/src/android/gradle.dart b/packages/flutter_tools/lib/src/android/gradle.dart index 5875731ec9..8842503497 100644 --- a/packages/flutter_tools/lib/src/android/gradle.dart +++ b/packages/flutter_tools/lib/src/android/gradle.dart @@ -44,6 +44,7 @@ final RegExp ndkMessageFilter = new RegExp(r'^(?!NDK is missing a ".*" directory r'|If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to .*)'); + FlutterPluginVersion getFlutterPluginVersion(AndroidProject project) { final File plugin = project.directory.childFile( fs.path.join('buildSrc', 'src', 'main', 'groovy', 'FlutterPlugin.groovy')); @@ -61,9 +62,6 @@ FlutterPluginVersion getFlutterPluginVersion(AndroidProject project) { if (line.contains(new RegExp(r'apply from: .*/flutter.gradle'))) { return FlutterPluginVersion.managed; } - if (line.contains("def flutterPluginVersion = 'managed'")) { - return FlutterPluginVersion.managed; - } } } return FlutterPluginVersion.none; diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart index 196924c13a..41b1592743 100644 --- a/packages/flutter_tools/lib/src/project.dart +++ b/packages/flutter_tools/lib/src/project.dart @@ -76,12 +76,7 @@ class FlutterProject { IosProject get ios => new IosProject(directory.childDirectory('ios')); /// The Android sub project of this project. - AndroidProject get android { - if (manifest.isModule) { - return new AndroidProject(directory.childDirectory('.android')); - } - return new AndroidProject(directory.childDirectory('android')); - } + AndroidProject get android => new AndroidProject(directory.childDirectory('android')); /// The generated AndroidModule sub project of this module project. AndroidModuleProject get androidModule => new AndroidModuleProject(directory.childDirectory('.android')); diff --git a/packages/flutter_tools/templates/module/android/Flutter.tmpl/build.gradle.tmpl b/packages/flutter_tools/templates/module/android/Flutter.tmpl/build.gradle.tmpl index 7d97120a1b..0db90f22c0 100644 --- a/packages/flutter_tools/templates/module/android/Flutter.tmpl/build.gradle.tmpl +++ b/packages/flutter_tools/templates/module/android/Flutter.tmpl/build.gradle.tmpl @@ -23,8 +23,6 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -buildDir = new File(rootProject.projectDir, "../build/flutter") - apply plugin: 'com.android.library' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" diff --git a/packages/flutter_tools/templates/module/android/app.tmpl/build.gradle.tmpl b/packages/flutter_tools/templates/module/android/app.tmpl/build.gradle.tmpl deleted file mode 100644 index 3eb860c4cd..0000000000 --- a/packages/flutter_tools/templates/module/android/app.tmpl/build.gradle.tmpl +++ /dev/null @@ -1,35 +0,0 @@ -def flutterPluginVersion = 'managed' - -apply plugin: 'com.android.application' - -android { - compileSdkVersion 27 - defaultConfig { - applicationId "{{androidIdentifier}}.host" - minSdkVersion 16 - targetSdkVersion 27 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug - } - } - -} -buildDir = new File(rootProject.projectDir, "../build/host") -dependencies { - implementation project(':flutter') - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support.constraint:constraint-layout:1.1.2' - implementation 'com.android.support:design:27.1.1' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' -} diff --git a/packages/flutter_tools/templates/module/android/app.tmpl/src/main/AndroidManifest.xml.tmpl b/packages/flutter_tools/templates/module/android/app.tmpl/src/main/AndroidManifest.xml.tmpl deleted file mode 100644 index e9f4d8ed2d..0000000000 --- a/packages/flutter_tools/templates/module/android/app.tmpl/src/main/AndroidManifest.xml.tmpl +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/packages/flutter_tools/templates/module/android/app.tmpl/src/main/java/androidIdentifier/host/MainActivity.java.tmpl b/packages/flutter_tools/templates/module/android/app.tmpl/src/main/java/androidIdentifier/host/MainActivity.java.tmpl deleted file mode 100644 index 3441c3ad9a..0000000000 --- a/packages/flutter_tools/templates/module/android/app.tmpl/src/main/java/androidIdentifier/host/MainActivity.java.tmpl +++ /dev/null @@ -1,13 +0,0 @@ -package {{androidIdentifier}}.host; - -import android.os.Bundle; -import io.flutter.app.FlutterActivity; -import io.flutter.plugins.GeneratedPluginRegistrant; - -public class MainActivity extends FlutterActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - GeneratedPluginRegistrant.registerWith(this); - } -} diff --git a/packages/flutter_tools/templates/module/android/app.tmpl/src/main/res/drawable/launch_background.xml b/packages/flutter_tools/templates/module/android/app.tmpl/src/main/res/drawable/launch_background.xml deleted file mode 100644 index 304732f884..0000000000 --- a/packages/flutter_tools/templates/module/android/app.tmpl/src/main/res/drawable/launch_background.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/packages/flutter_tools/templates/module/android/app.tmpl/src/main/res/mipmap-hdpi/ic_launcher.png b/packages/flutter_tools/templates/module/android/app.tmpl/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index db77bb4b7b..0000000000 Binary files a/packages/flutter_tools/templates/module/android/app.tmpl/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/packages/flutter_tools/templates/module/android/app.tmpl/src/main/res/values/styles.xml b/packages/flutter_tools/templates/module/android/app.tmpl/src/main/res/values/styles.xml deleted file mode 100644 index 00fa4417cf..0000000000 --- a/packages/flutter_tools/templates/module/android/app.tmpl/src/main/res/values/styles.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - diff --git a/packages/flutter_tools/templates/module/android/settings.gradle.tmpl b/packages/flutter_tools/templates/module/android/settings.gradle.tmpl index 0605586ecb..49eb997449 100644 --- a/packages/flutter_tools/templates/module/android/settings.gradle.tmpl +++ b/packages/flutter_tools/templates/module/android/settings.gradle.tmpl @@ -1,5 +1,4 @@ // Generated file. Do not edit. -include ':app' rootProject.name = 'android_generated' setBinding(new Binding([gradle: this])) diff --git a/packages/flutter_tools/templates/module/common/lib/main.dart.tmpl b/packages/flutter_tools/templates/module/common/lib/main.dart.tmpl index ce3660df8d..1b325f60c0 100644 --- a/packages/flutter_tools/templates/module/common/lib/main.dart.tmpl +++ b/packages/flutter_tools/templates/module/common/lib/main.dart.tmpl @@ -1,180 +1,38 @@ -import 'package:flutter/material.dart'; -{{#withDriverTest}} -import 'package:flutter_driver/driver_extension.dart'; -{{/withDriverTest}} -{{#withPluginHook}} import 'dart:async'; +import 'dart:ui'; -import 'package:flutter/services.dart'; -import 'package:{{pluginProjectName}}/{{pluginProjectName}}.dart'; -{{/withPluginHook}} +import 'package:flutter/material.dart'; +import 'package:package_info/package_info.dart'; -{{^withDriverTest}} -void main() => runApp(new MyApp()); -{{/withDriverTest}} -{{#withDriverTest}} -void main() { - // Enable integration testing with the Flutter Driver extension. - // See https://flutter.io/testing/ for more info. - enableFlutterDriverExtension(); - runApp(new MyApp()); -} -{{/withDriverTest}} - -{{^withPluginHook}} -class MyApp extends StatelessWidget { - // This widget is the root of your application. - @override - Widget build(BuildContext context) { - return new MaterialApp( - title: 'Flutter Demo', - theme: new ThemeData( - // This is the theme of your application. - // - // Try running your application with "flutter run". You'll see the - // application has a blue toolbar. Then, without quitting the app, try - // changing the primarySwatch below to Colors.green and then invoke - // "hot reload" (press "r" in the console where you ran "flutter run", - // or press Run > Flutter Hot Reload in IntelliJ). Notice that the - // counter didn't reset back to zero; the application is not restarted. - primarySwatch: Colors.blue, - ), - home: new MyHomePage(title: 'Flutter Demo Home Page'), - ); - } +Future main() async { + final PackageInfo packageInfo = await PackageInfo.fromPlatform(); + runApp(Directionality(textDirection: TextDirection.ltr, child: Router(packageInfo))); } -class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); +class Router extends StatelessWidget { + Router(this.packageInfo); - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - - final String title; - - @override - _MyHomePageState createState() => new _MyHomePageState(); -} - -class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } + final PackageInfo packageInfo; @override Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. - return new Scaffold( - appBar: new AppBar( - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: new Text(widget.title), - ), - body: new Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: new Column( - // Column is also layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Invoke "debug paint" (press "p" in the console where you ran - // "flutter run", or select "Toggle Debug Paint" from the Flutter tool - // window in IntelliJ) to see the wireframe for each widget. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - mainAxisAlignment: MainAxisAlignment.center, - children: [ - new Text( - 'You have pushed the button this many times:', - ), - new Text( - '$_counter', - style: Theme.of(context).textTheme.display1, - ), - ], - ), - ), - floatingActionButton: new FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: new Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. - ); - } -} -{{/withPluginHook}} -{{#withPluginHook}} -class MyApp extends StatefulWidget { - @override - _MyAppState createState() => new _MyAppState(); -} - -class _MyAppState extends State { - String _platformVersion = 'Unknown'; - - @override - void initState() { - super.initState(); - initPlatformState(); - } - - // Platform messages are asynchronous, so we initialize in an async method. - Future initPlatformState() async { - String platformVersion; - // Platform messages may fail, so we use a try/catch PlatformException. - try { - platformVersion = await {{pluginDartClass}}.platformVersion; - } on PlatformException { - platformVersion = 'Failed to get platform version.'; + final String route = window.defaultRouteName; + switch (route) { + case 'route1': + return Container( + child: Center(child: Text('Route 1\n${packageInfo.appName}')), + color: Colors.green, + ); + case 'route2': + return Container( + child: Center(child: Text('Route 2\n${packageInfo.packageName}')), + color: Colors.blue, + ); + default: + return Container( + child: Center(child: Text('Unknown route: $route')), + color: Colors.red, + ); } - - // If the widget was removed from the tree while the asynchronous platform - // message was in flight, we want to discard the reply rather than calling - // setState to update our non-existent appearance. - if (!mounted) return; - - setState(() { - _platformVersion = platformVersion; - }); - } - - @override - Widget build(BuildContext context) { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar( - title: const Text('Plugin example app'), - ), - body: new Center( - child: new Text('Running on: $_platformVersion\n'), - ), - ), - ); } } -{{/withPluginHook}} diff --git a/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl b/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl index 7a8edcf344..dc6bb57fb9 100644 --- a/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl @@ -3,6 +3,7 @@ description: {{description}} version: 1.0.0+1 dependencies: + package_info: flutter: sdk: flutter