Skip to content

Commit 1c6415c

Browse files
bazookondaadu
andauthored
build(android): fix build breaks with flutter v3.29.0 (#410)
* remove: v1 embeddings support * upgrade AGP --------- Co-authored-by: Harsh Bhikadia <[email protected]>
1 parent 57fbe87 commit 1c6415c

File tree

9 files changed

+84
-93
lines changed

9 files changed

+84
-93
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ linked_*.ds
3939
unlinked.ds
4040
unlinked_spec.ds
4141
**/pubspec.lock
42+
.fvm/
43+
.fvmrc
44+
.cxx/
4245

4346
# Coverage
4447
coverage/

packages/wifi_iot/android/src/main/java/com/alternadom/wifiiot/WifiIotPlugin.java

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@
4040
import io.flutter.plugin.common.MethodChannel;
4141
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
4242
import io.flutter.plugin.common.MethodChannel.Result;
43-
import io.flutter.plugin.common.PluginRegistry.Registrar;
44-
import io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener;
45-
import io.flutter.plugin.common.PluginRegistry.ViewDestroyListener;
46-
import io.flutter.view.FlutterNativeView;
43+
import io.flutter.plugin.common.PluginRegistry;
4744
import java.util.ArrayList;
4845
import java.util.List;
4946
import org.json.JSONArray;
@@ -56,7 +53,7 @@ public class WifiIotPlugin
5653
ActivityAware,
5754
MethodCallHandler,
5855
EventChannel.StreamHandler,
59-
RequestPermissionsResultListener {
56+
PluginRegistry.RequestPermissionsResultListener {
6057
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
6158
/// when the Flutter Engine is detached from the Activity
6259
private MethodChannel channel;
@@ -121,28 +118,6 @@ private void cleanup() {
121118
moWiFiAPManager = null;
122119
}
123120

124-
/** Plugin registration. This is used for registering with v1 Android embedding. */
125-
public static void registerWith(Registrar registrar) {
126-
final MethodChannel channel = new MethodChannel(registrar.messenger(), "wifi_iot");
127-
final EventChannel eventChannel =
128-
new EventChannel(registrar.messenger(), "plugins.wififlutter.io/wifi_scan");
129-
final WifiIotPlugin wifiIotPlugin = new WifiIotPlugin();
130-
wifiIotPlugin.initWithActivity(registrar.activity());
131-
wifiIotPlugin.initWithContext(registrar.activeContext());
132-
eventChannel.setStreamHandler(wifiIotPlugin);
133-
channel.setMethodCallHandler(wifiIotPlugin);
134-
135-
registrar.addViewDestroyListener(
136-
new ViewDestroyListener() {
137-
@Override
138-
public boolean onViewDestroy(FlutterNativeView view) {
139-
wifiIotPlugin.cleanup();
140-
return false;
141-
}
142-
});
143-
registrar.addRequestPermissionsResultListener(wifiIotPlugin);
144-
}
145-
146121
@Override
147122
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
148123
// initialize method and event channel and set handlers
Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "dev.flutter.flutter-gradle-plugin"
5+
}
6+
17
def localProperties = new Properties()
28
def localPropertiesFile = rootProject.file('local.properties')
39
if (localPropertiesFile.exists()) {
@@ -6,36 +12,42 @@ if (localPropertiesFile.exists()) {
612
}
713
}
814

9-
def flutterRoot = localProperties.getProperty('flutter.sdk')
10-
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
15+
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
16+
if (flutterVersionCode == null) {
17+
flutterVersionCode = '1'
1218
}
1319

14-
apply plugin: 'com.android.application'
15-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
20+
def flutterVersionName = localProperties.getProperty('flutter.versionName')
21+
if (flutterVersionName == null) {
22+
flutterVersionName = '1.0'
23+
}
1624

1725
android {
1826
namespace 'com.alternadom.wifiiotexample'
19-
20-
compileSdkVersion flutter.compileSdkVersion
27+
compileSdk flutter.compileSdkVersion
28+
ndkVersion flutter.ndkVersion
2129

2230
compileOptions {
2331
sourceCompatibility JavaVersion.VERSION_1_8
2432
targetCompatibility JavaVersion.VERSION_1_8
2533
}
2634

27-
lintOptions {
28-
disable 'InvalidPackage'
35+
kotlinOptions {
36+
jvmTarget = '1.8'
37+
}
38+
39+
sourceSets {
40+
main.java.srcDirs += 'src/main/kotlin'
2941
}
3042

3143
defaultConfig {
3244
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
3345
applicationId "com.alternadom.wifiiotexample"
3446
minSdkVersion flutter.minSdkVersion
3547
targetSdkVersion flutter.targetSdkVersion
36-
versionCode 1
37-
versionName "1.0"
38-
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
48+
targetSdkVersion flutter.targetSdkVersion
49+
versionCode flutterVersionCode.toInteger()
50+
versionName flutterVersionName
3951
}
4052

4153
buildTypes {
@@ -51,8 +63,12 @@ flutter {
5163
source '../..'
5264
}
5365

66+
67+
5468
dependencies {
5569
testImplementation 'junit:junit:4.12'
5670
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
5771
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
5872
}
73+
74+
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
buildscript {
2-
repositories {
3-
google()
4-
jcenter()
5-
}
6-
7-
dependencies {
8-
classpath 'com.android.tools.build:gradle:8.2.0'
9-
}
10-
}
11-
121
allprojects {
132
repositories {
143
google()
4+
mavenCentral()
155
jcenter()
166
}
177
}
@@ -26,4 +16,4 @@ subprojects {
2616

2717
tasks.register("clean", Delete) {
2818
delete rootProject.buildDir
29-
}
19+
}

packages/wifi_iot/example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
include ':app'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
29

3-
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
411

5-
def plugins = new Properties()
6-
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7-
if (pluginsFile.exists()) {
8-
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
917
}
1018

11-
plugins.each { name, path ->
12-
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13-
include ":$name"
14-
project(":$name").projectDir = pluginDirectory
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "8.2.0" apply false
22+
id "org.jetbrains.kotlin.android" version "1.8.10" apply false
1523
}
24+
25+
include ":app"

packages/wifi_scan/example/android/app/build.gradle

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "dev.flutter.flutter-gradle-plugin"
5+
}
6+
17
def localProperties = new Properties()
28
def localPropertiesFile = rootProject.file('local.properties')
39
if (localPropertiesFile.exists()) {
@@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
612
}
713
}
814

9-
def flutterRoot = localProperties.getProperty('flutter.sdk')
10-
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12-
}
13-
1415
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1516
if (flutterVersionCode == null) {
1617
flutterVersionCode = '1'
@@ -21,10 +22,6 @@ if (flutterVersionName == null) {
2122
flutterVersionName = '1.0'
2223
}
2324

24-
apply plugin: 'com.android.application'
25-
apply plugin: 'kotlin-android'
26-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27-
2825
android {
2926
namespace 'dev.flutternetwork.wifi.wifi_scan_example'
3027

@@ -66,5 +63,4 @@ flutter {
6663
}
6764

6865
dependencies {
69-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
7066
}

packages/wifi_scan/example/android/build.gradle

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
buildscript {
2-
ext.kotlin_version = '1.8.21'
3-
repositories {
4-
google()
5-
mavenCentral()
6-
}
7-
8-
dependencies {
9-
classpath 'com.android.tools.build:gradle:8.2.0'
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
}
12-
}
13-
141
allprojects {
152
repositories {
163
google()
Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
include ':app'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
29

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
511

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
818

9-
def flutterSdkPath = properties.getProperty("flutter.sdk")
10-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "8.2.0" apply false
22+
id "org.jetbrains.kotlin.android" version "1.8.21" apply false
23+
}
24+
25+
include ":app"

0 commit comments

Comments
 (0)