Skip to content

Commit d1a83c8

Browse files
Android version 1.1.0 Flutter 3.29.0 update, added example project (#58)
* Android version 1.0.2 update * updated changelog * Added an example project within the Android package to eliminate the need for an external dependency * updated build file
1 parent 35468d7 commit d1a83c8

File tree

30 files changed

+582
-55
lines changed

30 files changed

+582
-55
lines changed

.github/workflows/google_api_availability_android.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
env:
2525
source-directory: ./google_api_availability_android
26-
example-directory: ./google_api_availability/example
26+
example-directory: ./google_api_availability_android/example
2727

2828
# Steps represent a sequence of tasks that will be executed as part of the job
2929
steps:

google_api_availability_android/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.1.0
2+
3+
* Fixes compile errors for Flutter 3.29.0 (and above)
4+
* Updates compileSDKversion to 35
5+
16
## 1.0.1
27

38
* Adds support for the namespace property to support Android Gradle Plugin (AGP) 8.

google_api_availability_android/android/build.gradle

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
group 'com.baseflow.googleapiavailability'
22
version '1.0-SNAPSHOT'
33

4-
buildscript {
5-
repositories {
6-
google()
7-
mavenCentral()
8-
}
9-
10-
dependencies {
11-
classpath 'com.android.tools.build:gradle:4.1.0'
12-
}
13-
}
14-
154
rootProject.allprojects {
165
repositories {
176
google()
@@ -27,7 +16,7 @@ android {
2716
namespace 'com.baseflow.googleapiavailability'
2817
}
2918

30-
compileSdkVersion 31
19+
compileSdkVersion 35
3120

3221
compileOptions {
3322
sourceCompatibility JavaVersion.VERSION_1_8
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-7.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
rootProject.name = 'google_api_availability'
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+
}()
9+
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
11+
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
18+
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "8.1.0" apply false
22+
}
23+
24+
include ":app"

google_api_availability_android/android/src/main/java/com/baseflow/googleapiavailability/GoogleApiAvailabilityPlugin.java

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
99
import io.flutter.plugin.common.BinaryMessenger;
1010
import io.flutter.plugin.common.MethodChannel;
11-
import io.flutter.plugin.common.PluginRegistry.Registrar;
12-
import io.flutter.plugin.common.PluginRegistry.ViewDestroyListener;
13-
import io.flutter.view.FlutterNativeView;
1411

1512
/**
1613
* GoogleApiAvailabilityPlugin
@@ -26,57 +23,53 @@ public GoogleApiAvailabilityPlugin() {
2623
}
2724

2825
@Override
29-
public void onAttachedToActivity(ActivityPluginBinding binding) {
30-
methodCallHandler.setActivity(binding.getActivity());
31-
}
26+
public void onAttachedToActivity(ActivityPluginBinding binding) {
27+
if (methodCallHandler != null) {
28+
methodCallHandler.setActivity(binding.getActivity());
29+
}
30+
}
3231

33-
@Override
34-
public void onDetachedFromActivity() {
35-
methodCallHandler.setActivity(null);
36-
}
32+
@Override
33+
public void onDetachedFromActivity() {
34+
if (methodCallHandler != null) {
35+
methodCallHandler.setActivity(null);
36+
}
37+
}
3738

38-
@Override
39-
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
40-
methodCallHandler.setActivity(binding.getActivity());
41-
}
39+
@Override
40+
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
41+
if (methodCallHandler != null) {
42+
methodCallHandler.setActivity(binding.getActivity());
43+
}
44+
}
4245

43-
@Override
44-
public void onDetachedFromActivityForConfigChanges() {
45-
methodCallHandler.setActivity(null);
46-
}
46+
@Override
47+
public void onDetachedFromActivityForConfigChanges() {
48+
if (methodCallHandler != null) {
49+
methodCallHandler.setActivity(null);
50+
}
51+
}
4752

48-
@Override
49-
public void onAttachedToEngine(FlutterPluginBinding binding) {
50-
registerPlugin(binding.getApplicationContext(), binding.getBinaryMessenger());
51-
}
53+
@Override
54+
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
55+
registerPlugin(binding.getApplicationContext(), binding.getBinaryMessenger());
56+
}
5257

5358
@Override
5459
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
5560
unregisterPlugin();
5661
}
5762

58-
public static void registerWith(Registrar registrar) {
59-
final GoogleApiAvailabilityPlugin plugin = new GoogleApiAvailabilityPlugin();
60-
plugin.registerPlugin(registrar.context(), registrar.messenger());
61-
plugin.methodCallHandler.setActivity(registrar.activity());
62-
63-
registrar.addViewDestroyListener(new ViewDestroyListener() {
64-
@Override
65-
public boolean onViewDestroy(FlutterNativeView view) {
66-
plugin.unregisterPlugin();
67-
return false;
68-
}
69-
});
70-
}
71-
7263
private void registerPlugin(Context context, BinaryMessenger messenger) {
7364
methodCallHandler = new MethodCallHandlerImpl(context, googleApiAvailabilityManager);
7465
channel = new MethodChannel(messenger, "flutter.baseflow.com/google_api_availability_android/methods");
7566
channel.setMethodCallHandler(methodCallHandler);
7667
}
7768

7869
private void unregisterPlugin() {
79-
channel.setMethodCallHandler(null);
80-
channel = null;
70+
if (channel != null) {
71+
channel.setMethodCallHandler(null);
72+
channel = null;
73+
}
8174
}
8275
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# Visual Studio Code related
19+
.vscode/
20+
21+
# Flutter/Dart/Pub related
22+
**/doc/api/
23+
.dart_tool/
24+
.flutter-plugins
25+
.packages
26+
.pub-cache/
27+
.pub/
28+
/build/
29+
30+
# Android related
31+
**/android/**/gradle-wrapper.jar
32+
**/android/.gradle
33+
**/android/captures/
34+
**/android/gradlew
35+
**/android/gradlew.bat
36+
**/android/local.properties
37+
**/android/**/GeneratedPluginRegistrant.java
38+
39+
# iOS/XCode related
40+
**/ios/**/*.mode1v3
41+
**/ios/**/*.mode2v3
42+
**/ios/**/*.moved-aside
43+
**/ios/**/*.pbxuser
44+
**/ios/**/*.perspectivev3
45+
**/ios/**/*sync/
46+
**/ios/**/.sconsign.dblite
47+
**/ios/**/.tags*
48+
**/ios/**/.vagrant/
49+
**/ios/**/DerivedData/
50+
**/ios/**/Icon?
51+
**/ios/**/Pods/
52+
**/ios/**/.symlinks/
53+
**/ios/**/profile
54+
**/ios/**/xcuserdata
55+
**/ios/.generated/
56+
**/ios/Flutter/App.framework
57+
**/ios/Flutter/Flutter.framework
58+
**/ios/Flutter/Generated.xcconfig
59+
**/ios/Flutter/app.flx
60+
**/ios/Flutter/app.zip
61+
**/ios/Flutter/flutter_assets/
62+
**/ios/ServiceDefinitions.json
63+
**/ios/Runner/GeneratedPluginRegistrant.*
64+
65+
# Exceptions to above rules.
66+
!**/ios/**/default.mode1v3
67+
!**/ios/**/default.mode2v3
68+
!**/ios/**/default.pbxuser
69+
!**/ios/**/default.perspectivev3
70+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 035e0765cc575c3b455689c2402cce073d564fce
8+
channel: master
9+
10+
project_type: app
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# google_api_availability_example
2+
3+
Demonstrates how to use the google_api_availability plugin.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook)
13+
14+
For help getting started with Flutter, view our
15+
[online documentation](https://flutter.io/docs), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.iml
2+
*.class
3+
.gradle
4+
/local.properties
5+
/.idea/workspace.xml
6+
/.idea/libraries
7+
.DS_Store
8+
/build
9+
/captures
10+
GeneratedPluginRegistrant.java
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
arguments=
2+
auto.sync=false
3+
build.scans.enabled=false
4+
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
5+
connection.project.dir=
6+
eclipse.preferences.version=1
7+
gradle.user.home=
8+
java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
9+
jvm.arguments=
10+
offline.mode=false
11+
override.workspace.settings=true
12+
show.console.view=true
13+
show.executions.view=true
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
4+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5+
<classpathentry kind="output" path="bin/default"/>
6+
</classpath>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
connection.project.dir=..
2+
eclipse.preferences.version=1
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
plugins {
2+
id "com.android.application"
3+
id "dev.flutter.flutter-gradle-plugin"
4+
}
5+
6+
def localProperties = new Properties()
7+
def localPropertiesFile = rootProject.file('local.properties')
8+
if (localPropertiesFile.exists()) {
9+
localPropertiesFile.withReader('UTF-8') { reader ->
10+
localProperties.load(reader)
11+
}
12+
}
13+
14+
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15+
if (flutterVersionCode == null) {
16+
flutterVersionCode = '1'
17+
}
18+
19+
def flutterVersionName = localProperties.getProperty('flutter.versionName')
20+
if (flutterVersionName == null) {
21+
flutterVersionName = '1.0'
22+
}
23+
24+
android {
25+
namespace 'com.baseflow.googleapiavailabilityexample'
26+
compileSdkVersion flutter.compileSdkVersion
27+
28+
compileOptions {
29+
sourceCompatibility JavaVersion.VERSION_1_8
30+
targetCompatibility JavaVersion.VERSION_1_8
31+
}
32+
33+
lintOptions {
34+
disable 'InvalidPackage'
35+
}
36+
37+
defaultConfig {
38+
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
39+
applicationId "com.baseflow.googleapiavailabilityexample"
40+
minSdkVersion flutter.minSdkVersion
41+
targetSdkVersion flutter.targetSdkVersion
42+
versionCode flutterVersionCode.toInteger()
43+
versionName flutterVersionName
44+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
45+
}
46+
47+
buildTypes {
48+
release {
49+
// TODO: Add your own signing config for the release build.
50+
// Signing with the debug keys for now, so `flutter run --release` works.
51+
signingConfig signingConfigs.debug
52+
}
53+
}
54+
}
55+
56+
flutter {
57+
source '../..'
58+
}
59+
60+
dependencies {
61+
androidTestImplementation 'androidx.test:runner:1.2.0'
62+
androidTestImplementation 'androidx.test:rules:1.2.0'
63+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
64+
}

0 commit comments

Comments
 (0)