Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 8f12e1f

Browse files
authored
[device_info] Update Android embedding to match latest Flutter stable release (#2590)
* Update V2 plugin migration to match current flutter stable * Bump AGP to 3.6.1
1 parent ee9685f commit 8f12e1f

File tree

11 files changed

+31
-86
lines changed

11 files changed

+31
-86
lines changed

packages/device_info/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.4.2+1
2+
3+
* Bump the minimum Flutter version to 1.12.13+hotfix.5.
4+
* Remove deprecated API usage warning in AndroidIntentPlugin.java.
5+
* Migrates the Android example to V2 embedding.
6+
* Bumps AGP to 3.6.1.
7+
18
## 0.4.2
29

310
* Add systemFeatures to AndroidDeviceInfo.

packages/device_info/android/build.gradle

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.3.0'
11+
classpath 'com.android.tools.build:gradle:3.6.1'
1212
}
1313
}
1414

@@ -32,29 +32,3 @@ android {
3232
disable 'InvalidPackage'
3333
}
3434
}
35-
36-
// TODO(cyanglaz): Remove this hack once androidx.lifecycle is included on stable. https://github.com/flutter/flutter/issues/42348
37-
afterEvaluate {
38-
def containsEmbeddingDependencies = false
39-
for (def configuration : configurations.all) {
40-
for (def dependency : configuration.dependencies) {
41-
if (dependency.group == 'io.flutter' &&
42-
dependency.name.startsWith('flutter_embedding') &&
43-
dependency.isTransitive())
44-
{
45-
containsEmbeddingDependencies = true
46-
break
47-
}
48-
}
49-
}
50-
if (!containsEmbeddingDependencies) {
51-
android {
52-
dependencies {
53-
def lifecycle_version = "1.1.1"
54-
compileOnly "android.arch.lifecycle:runtime:$lifecycle_version"
55-
compileOnly "android.arch.lifecycle:common:$lifecycle_version"
56-
compileOnly "android.arch.lifecycle:common-java8:$lifecycle_version"
57-
}
58-
}
59-
}
60-
}

packages/device_info/android/src/main/java/io/flutter/plugins/deviceinfo/DeviceInfoPlugin.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public static void registerWith(Registrar registrar) {
2323

2424
@Override
2525
public void onAttachedToEngine(FlutterPlugin.FlutterPluginBinding binding) {
26-
setupMethodChannel(
27-
binding.getFlutterEngine().getDartExecutor(), binding.getApplicationContext());
26+
setupMethodChannel(binding.getBinaryMessenger(), binding.getApplicationContext());
2827
}
2928

3029
@Override

packages/device_info/example/android/app/src/main/AndroidManifest.xml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@
1212
android:exported="true"
1313
android:windowSoftInputMode="adjustResize">
1414
</activity>
15-
<activity android:name=".MainActivity"
16-
android:theme="@android:style/Theme.Black.NoTitleBar"
17-
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
18-
android:hardwareAccelerated="true"
19-
android:windowSoftInputMode="adjustResize">
20-
<intent-filter>
21-
<action android:name="android.intent.action.MAIN"/>
22-
<category android:name="android.intent.category.LAUNCHER"/>
23-
</intent-filter>
24-
</activity>
15+
16+
<activity android:name="io.flutter.embedding.android.FlutterActivity"
17+
android:theme="@android:style/Theme.Black.NoTitleBar"
18+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
19+
android:hardwareAccelerated="true"
20+
android:windowSoftInputMode="adjustResize">
21+
<meta-data
22+
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
23+
android:value="true" />
24+
<intent-filter>
25+
<action android:name="android.intent.action.MAIN"/>
26+
<category android:name="android.intent.category.LAUNCHER"/>
27+
</intent-filter>
28+
</activity>
29+
<meta-data android:name="flutterEmbedding" android:value="2"/>
2530
</application>
2631
</manifest>

packages/device_info/example/android/app/src/main/java/io/flutter/plugins/deviceinfoexample/EmbeddingV1Activity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
import android.os.Bundle;
88
import io.flutter.app.FlutterActivity;
9-
import io.flutter.plugins.GeneratedPluginRegistrant;
9+
import io.flutter.plugins.deviceinfo.DeviceInfoPlugin;
1010

1111
public class EmbeddingV1Activity extends FlutterActivity {
1212
@Override
1313
protected void onCreate(Bundle savedInstanceState) {
1414
super.onCreate(savedInstanceState);
15-
GeneratedPluginRegistrant.registerWith(this);
15+
DeviceInfoPlugin.registerWith(registrarFor("io.flutter.plugins.deviceinfo.DeviceInfoPlugin"));
1616
}
1717
}

packages/device_info/example/android/app/src/main/java/io/flutter/plugins/deviceinfoexample/MainActivity.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/device_info/example/android/app/src/main/java/io/flutter/plugins/deviceinfoexample/MainActivityTest.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/device_info/example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.3.0'
8+
classpath 'com.android.tools.build:gradle:3.6.1'
99
}
1010
}
1111

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Jun 23 08:50:38 CEST 2017
1+
#Mon Mar 09 11:05:13 GMT 2020
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

packages/device_info/example/pubspec.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,3 @@ dev_dependencies:
1515

1616
flutter:
1717
uses-material-design: true
18-
19-
environment:
20-
sdk: ">=2.0.0-dev.28.0 <3.0.0"
21-
flutter: ">=1.9.1+hotfix.2 <2.0.0"
22-

0 commit comments

Comments
 (0)