Skip to content
  • Sponsor Baseflow/flutter-google-api-availability

  • Notifications You must be signed in to change notification settings
  • Fork 34

Android version 1.1.0 Flutter 3.29.0 update, added example project #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/google_api_availability_android.yaml
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ jobs:

env:
source-directory: ./google_api_availability_android
example-directory: ./google_api_availability/example
example-directory: ./google_api_availability_android/example

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
5 changes: 5 additions & 0 deletions google_api_availability_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.0

* Fixes compile errors for Flutter 3.29.0 (and above)
* Updates compileSDKversion to 35

## 1.0.1

* Adds support for the namespace property to support Android Gradle Plugin (AGP) 8.
13 changes: 1 addition & 12 deletions google_api_availability_android/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
group 'com.baseflow.googleapiavailability'
version '1.0-SNAPSHOT'

buildscript {
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}

rootProject.allprojects {
repositories {
google()
@@ -27,7 +16,7 @@ android {
namespace 'com.baseflow.googleapiavailability'
}

compileSdkVersion 31
compileSdkVersion 35

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
25 changes: 24 additions & 1 deletion google_api_availability_android/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
rootProject.name = 'google_api_availability'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.0" apply false
}

include ":app"
Original file line number Diff line number Diff line change
@@ -8,9 +8,6 @@
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.PluginRegistry.Registrar;
import io.flutter.plugin.common.PluginRegistry.ViewDestroyListener;
import io.flutter.view.FlutterNativeView;

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

@Override
public void onAttachedToActivity(ActivityPluginBinding binding) {
methodCallHandler.setActivity(binding.getActivity());
}
public void onAttachedToActivity(ActivityPluginBinding binding) {
if (methodCallHandler != null) {
methodCallHandler.setActivity(binding.getActivity());
}
}

@Override
public void onDetachedFromActivity() {
methodCallHandler.setActivity(null);
}
@Override
public void onDetachedFromActivity() {
if (methodCallHandler != null) {
methodCallHandler.setActivity(null);
}
}

@Override
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
methodCallHandler.setActivity(binding.getActivity());
}
@Override
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
if (methodCallHandler != null) {
methodCallHandler.setActivity(binding.getActivity());
}
}

@Override
public void onDetachedFromActivityForConfigChanges() {
methodCallHandler.setActivity(null);
}
@Override
public void onDetachedFromActivityForConfigChanges() {
if (methodCallHandler != null) {
methodCallHandler.setActivity(null);
}
}

@Override
public void onAttachedToEngine(FlutterPluginBinding binding) {
registerPlugin(binding.getApplicationContext(), binding.getBinaryMessenger());
}
@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
registerPlugin(binding.getApplicationContext(), binding.getBinaryMessenger());
}

@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
unregisterPlugin();
}

public static void registerWith(Registrar registrar) {
final GoogleApiAvailabilityPlugin plugin = new GoogleApiAvailabilityPlugin();
plugin.registerPlugin(registrar.context(), registrar.messenger());
plugin.methodCallHandler.setActivity(registrar.activity());

registrar.addViewDestroyListener(new ViewDestroyListener() {
@Override
public boolean onViewDestroy(FlutterNativeView view) {
plugin.unregisterPlugin();
return false;
}
});
}

private void registerPlugin(Context context, BinaryMessenger messenger) {
methodCallHandler = new MethodCallHandlerImpl(context, googleApiAvailabilityManager);
channel = new MethodChannel(messenger, "flutter.baseflow.com/google_api_availability_android/methods");
channel.setMethodCallHandler(methodCallHandler);
}

private void unregisterPlugin() {
channel.setMethodCallHandler(null);
channel = null;
if (channel != null) {
channel.setMethodCallHandler(null);
channel = null;
}
}
}
70 changes: 70 additions & 0 deletions google_api_availability_android/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Visual Studio Code related
.vscode/

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.packages
.pub-cache/
.pub/
/build/

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
10 changes: 10 additions & 0 deletions google_api_availability_android/example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 035e0765cc575c3b455689c2402cce073d564fce
channel: master

project_type: app
16 changes: 16 additions & 0 deletions google_api_availability_android/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# google_api_availability_example

Demonstrates how to use the google_api_availability plugin.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.io/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
10 changes: 10 additions & 0 deletions google_api_availability_android/example/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.iml
*.class
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
GeneratedPluginRegistrant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1
64 changes: 64 additions & 0 deletions google_api_availability_android/example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
plugins {
id "com.android.application"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

android {
namespace 'com.baseflow.googleapiavailabilityexample'
compileSdkVersion flutter.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.baseflow.googleapiavailabilityexample"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}

flutter {
source '../..'
}

dependencies {
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Loading