Allow flavors and custom build types in host app (#36805)

Fixes these issues:
#30916
#34089
#36479
#29648
This commit is contained in:
Emmanuel Garcia
2019-07-29 09:26:41 -07:00
committed by GitHub
parent ef146f63bb
commit 9f39cad4ed
11 changed files with 375 additions and 18 deletions

View File

@@ -0,0 +1,8 @@
# Android host app
Android host app for a Flutter module created using
```
$ flutter create -t module hello
```
and placed in a sibling folder to (a clone of) the host app.
Used by the `module_host_with_custom_build_test.dart` device lab test.

View File

@@ -0,0 +1,43 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
defaultConfig {
applicationId "io.flutter.addtoapp"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
// Test build types.
buildTypes {
staging {
initWith debug
// This is required because the `:flutter` project doesn't define this custom build type.
// Without the fallback, the Android plugin will make Gradle exit with the following error:
// `Unable to find a matching variant of project :flutter`
matchingFallbacks = ['debug']
}
prod {
initWith release
matchingFallbacks = ['release']
}
}
// Test flavors.
flavorDimensions "version"
productFlavors {
demo {
dimension "version"
}
}
}
dependencies {
implementation project(':flutter')
implementation 'com.android.support:appcompat-v7:27.1.1'
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="io.flutter.addtoapp">
<application android:allowBackup="false"
tools:ignore="GoogleAppIndexingWarning,MissingApplicationIcon">
<activity android:name=".MainActivity" />
</application>
</manifest>

View File

@@ -0,0 +1,14 @@
package io.flutter.addtoapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import io.flutter.facade.Flutter;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(Flutter.createView(this, getLifecycle(), "route1"));
}
}

View File

@@ -0,0 +1,20 @@
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx1536m

View File

@@ -0,0 +1,6 @@
#Mon Jun 25 14:13:36 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

View File

@@ -0,0 +1,3 @@
include ':app'
setBinding(new Binding([gradle: this]))
evaluate(new File(settingsDir.parentFile, 'hello/.android/include_flutter.groovy'))