Skip to content

Commit aa4ebfa

Browse files
authored
💥 Upgrade to Android V2 embedding (LinusU#87)
Migration guide: Make sure that you are running a recent version of Flutter before upgrading.
1 parent 7bc0cbc commit aa4ebfa

File tree

12 files changed

+43
-38
lines changed

12 files changed

+43
-38
lines changed

android/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@ group 'com.linusu.flutter_web_auth'
22
version '1.0-SNAPSHOT'
33

44
buildscript {
5-
ext.kotlin_version = '1.3.72'
5+
ext.kotlin_version = '1.5.31'
66
repositories {
77
google()
8-
jcenter()
8+
mavenCentral()
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:3.6.3'
12+
classpath 'com.android.tools.build:gradle:7.0.3'
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414
}
1515
}
1616

1717
rootProject.allprojects {
1818
repositories {
1919
google()
20-
jcenter()
20+
mavenCentral()
2121
}
2222
}
2323

2424
apply plugin: 'com.android.library'
2525
apply plugin: 'kotlin-android'
2626

2727
android {
28-
compileSdkVersion 28
28+
compileSdkVersion 31
2929

3030
sourceSets {
3131
main.java.srcDirs += 'src/main/kotlin'
@@ -39,7 +39,7 @@ android {
3939
}
4040

4141
dependencies {
42-
implementation 'androidx.browser:browser:1.0.0'
42+
implementation 'androidx.browser:browser:1.3.0'
4343
}
4444
}
4545

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

android/src/main/kotlin/com/linusu/flutter_web_auth/FlutterWebAuthPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class FlutterWebAuthPlugin(private var context: Context? = null, private var cha
5959
}
6060
intent.intent.putExtra("android.support.customtabs.extra.KEEP_ALIVE", keepAliveIntent)
6161

62-
intent.launchUrl(context, url)
62+
intent.launchUrl(context!!, url)
6363
}
6464
"cleanUpDanglingCalls" -> {
6565
callbacks.forEach{ (_, danglingResultCallback) ->

example/android/app/build.gradle

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 28
29+
compileSdkVersion 31
30+
31+
compileOptions {
32+
sourceCompatibility JavaVersion.VERSION_1_8
33+
targetCompatibility JavaVersion.VERSION_1_8
34+
}
3035

3136
sourceSets {
3237
main.java.srcDirs += 'src/main/kotlin'
@@ -40,7 +45,7 @@ android {
4045
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
4146
applicationId "com.linusu.flutter_web_auth_example"
4247
minSdkVersion 16
43-
targetSdkVersion 28
48+
targetSdkVersion 31
4449
versionCode flutterVersionCode.toInteger()
4550
versionName flutterVersionName
4651
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -61,7 +66,7 @@ flutter {
6166

6267
dependencies {
6368
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64-
testImplementation 'junit:junit:4.12'
65-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
66-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
69+
testImplementation 'junit:junit:4.13.2'
70+
androidTestImplementation 'androidx.test:runner:1.4.0'
71+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
6772
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
android:launchMode="singleTop"
1616
android:theme="@style/LaunchTheme"
1717
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
18+
android:exported="true"
1819
android:hardwareAccelerated="true"
1920
android:windowSoftInputMode="adjustResize">
2021
<!-- This keeps the window background of the activity showing
@@ -30,7 +31,9 @@
3031
</intent-filter>
3132
</activity>
3233

33-
<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" >
34+
<activity
35+
android:name="com.linusu.flutter_web_auth.CallbackActivity"
36+
android:exported="true">
3437
<intent-filter android:label="flutter_web_auth">
3538
<action android:name="android.intent.action.VIEW" />
3639
<category android:name="android.intent.category.DEFAULT" />
@@ -39,5 +42,10 @@
3942
</intent-filter>
4043
</activity>
4144

45+
<!-- Don't delete the meta-data below.
46+
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
47+
<meta-data
48+
android:name="flutterEmbedding"
49+
android:value="2" />
4250
</application>
4351
</manifest>
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
package com.linusu.flutter_web_auth_example
22

3-
import android.os.Bundle
4-
5-
import io.flutter.app.FlutterActivity
6-
import io.flutter.plugins.GeneratedPluginRegistrant
3+
import io.flutter.embedding.android.FlutterActivity
74

85
class MainActivity: FlutterActivity() {
9-
override fun onCreate(savedInstanceState: Bundle?) {
10-
super.onCreate(savedInstanceState)
11-
GeneratedPluginRegistrant.registerWith(this)
12-
}
136
}

example/android/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.72'
2+
ext.kotlin_version = '1.5.31'
33
repositories {
44
google()
5-
jcenter()
5+
mavenCentral()
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.6.3'
9+
classpath 'com.android.tools.build:gradle:7.0.3'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}
1313

1414
allprojects {
1515
repositories {
1616
google()
17-
jcenter()
17+
mavenCentral()
1818
}
1919
}
2020

example/android/gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
org.gradle.jvmargs=-Xmx1536M
22
android.useAndroidX=true
33
android.enableJetifier=true
4-
android.enableR8=true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

example/pubspec.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.6.1"
10+
version: "2.8.1"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
@@ -28,7 +28,7 @@ packages:
2828
name: charcode
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "1.2.0"
31+
version: "1.3.1"
3232
clock:
3333
dependency: transitive
3434
description:
@@ -49,7 +49,7 @@ packages:
4949
name: cupertino_icons
5050
url: "https://pub.dartlang.org"
5151
source: hosted
52-
version: "0.1.2"
52+
version: "1.0.3"
5353
fake_async:
5454
dependency: transitive
5555
description:
@@ -99,7 +99,7 @@ packages:
9999
name: meta
100100
url: "https://pub.dartlang.org"
101101
source: hosted
102-
version: "1.3.0"
102+
version: "1.7.0"
103103
path:
104104
dependency: transitive
105105
description:
@@ -153,7 +153,7 @@ packages:
153153
name: test_api
154154
url: "https://pub.dartlang.org"
155155
source: hosted
156-
version: "0.3.0"
156+
version: "0.4.2"
157157
typed_data:
158158
dependency: transitive
159159
description:

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111

1212
# The following adds the Cupertino Icons font to your application.
1313
# Use with the CupertinoIcons class for iOS style icons.
14-
cupertino_icons: ^0.1.2
14+
cupertino_icons: ^1.0.3
1515

1616
dev_dependencies:
1717
flutter_test:

pubspec.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.6.1"
10+
version: "2.8.1"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
@@ -28,7 +28,7 @@ packages:
2828
name: charcode
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "1.2.0"
31+
version: "1.3.1"
3232
clock:
3333
dependency: transitive
3434
description:
@@ -85,7 +85,7 @@ packages:
8585
name: meta
8686
url: "https://pub.dartlang.org"
8787
source: hosted
88-
version: "1.3.0"
88+
version: "1.7.0"
8989
path:
9090
dependency: transitive
9191
description:
@@ -139,7 +139,7 @@ packages:
139139
name: test_api
140140
url: "https://pub.dartlang.org"
141141
source: hosted
142-
version: "0.3.0"
142+
version: "0.4.2"
143143
typed_data:
144144
dependency: transitive
145145
description:

0 commit comments

Comments
 (0)