Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## 0.5.2

* Support Android Gradle Plugin 9 and Flutter's built-in Kotlin mode while keeping
AGP 8 and Flutter's temporary `android.builtInKotlin=false` opt-out working.
* Stop declaring plugin-owned Android Gradle Plugin and Kotlin Gradle Plugin classpaths.
* Update the example Android app to Android Gradle Plugin 9.1.1.
* Tested example integration tests with:

| Flutter | AGP | Kotlin mode |
| --- | --- | --- |
| 3.44.4 stable | 9.1.1 | Flutter AGP 9 opt-out |
| 3.44.0 | 9.1.1 | Flutter AGP 9 opt-out |
| 3.41.9 | 8.13.2 | legacy KGP |
| 3.35.7 | 8.13.2 | legacy KGP |
| 3.32.8 | 8.13.2 | legacy KGP |

* Thanks to @raph5640, @amanvishwakarma96, and @Joschiller for reporting the AGP 9 build problem.

## 0.5.1

* Add integration tests to verify plugin functionality across Android API levels
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ try {

**Note:** `getId()` returns `null` on non-Android platforms (iOS, Web, etc.). On Android, it throws `MissingPluginException` if the plugin is not properly registered (see more [below](https://pub.dev/packages/android_id#troubleshooting)).

## Android build compatibility

`android_id` supports Android Gradle Plugin 9 and Flutter's built-in Kotlin mode.
It also keeps working with AGP 8 and Flutter's temporary
`android.builtInKotlin=false` opt-out.

The plugin no longer provides its own Android Gradle Plugin or Kotlin Gradle
Plugin classpaths. It only applies the Kotlin Gradle Plugin when the host build
still needs it. This fixes errors such as:

```text
The 'org.jetbrains.kotlin.android' plugin is no longer required for Kotlin
support since AGP 9.0.
```

Most Flutter apps should not need app-code changes.

## Important

Please note that on `Android 8` and above, the `Android ID` is not unique per device, but also per signing key the app was built with:
Expand Down
37 changes: 19 additions & 18 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
group = "dev.fluttercommunity.android_id"
version = "1.0-SNAPSHOT"

buildscript {
ext.kotlin_version = "2.1.0"
repositories {
google()
mavenCentral()
}

dependencies {
classpath("com.android.tools.build:gradle:8.7.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
}
}

allprojects {
repositories {
google()
Expand All @@ -22,7 +9,19 @@ allprojects {
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"

def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
boolean hasBuiltInKotlinSupport = agpMajor >= 9

def builtInKotlinProperty = findProperty('android.builtInKotlin')
boolean isBuiltInKotlinEnabled = builtInKotlinProperty == null ||
builtInKotlinProperty.toString().toBoolean()

boolean shouldApplyKotlinGradlePlugin = !hasBuiltInKotlinSupport || !isBuiltInKotlinEnabled

if (shouldApplyKotlinGradlePlugin) {
apply plugin: 'kotlin-android'
}

android {
if (project.android.hasProperty("namespace")) {
Expand All @@ -36,10 +35,6 @@ android {
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "17"
}

sourceSets {
main.java.srcDirs += "src/main/kotlin"
test.java.srcDirs += "src/test/kotlin"
Expand All @@ -66,3 +61,9 @@ android {
}
}
}

kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}
13 changes: 7 additions & 6 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id "com.android.application"
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
// The Flutter Gradle Plugin must be applied after the Android Gradle plugin.
id "dev.flutter.flutter-gradle-plugin"
}

Expand Down Expand Up @@ -33,10 +32,6 @@ android {
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "17"
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "dev.fluttercommunity.android_id_example"
Expand All @@ -60,3 +55,9 @@ android {
flutter {
source = "../.."
}

kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
3 changes: 1 addition & 2 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.7.2" apply false
id "org.jetbrains.kotlin.android" version "2.1.0" apply false
id "com.android.application" version "9.1.1" apply false
}

include ":app"
24 changes: 12 additions & 12 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.5.1"
version: "0.5.2"
async:
dependency: transitive
description:
Expand All @@ -28,10 +28,10 @@ packages:
dependency: transitive
description:
name: characters
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
url: "https://pub.dev"
source: hosted
version: "1.4.0"
version: "1.4.1"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -133,26 +133,26 @@ packages:
dependency: transitive
description:
name: matcher
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
url: "https://pub.dev"
source: hosted
version: "0.12.17"
version: "0.12.19"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
url: "https://pub.dev"
source: hosted
version: "0.11.1"
version: "0.13.0"
meta:
dependency: transitive
description:
name: meta
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349"
url: "https://pub.dev"
source: hosted
version: "1.16.0"
version: "1.18.0"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -234,10 +234,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e"
url: "https://pub.dev"
source: hosted
version: "0.7.6"
version: "0.7.11"
vector_math:
dependency: transitive
description:
Expand All @@ -263,5 +263,5 @@ packages:
source: hosted
version: "3.1.0"
sdks:
dart: ">=3.8.0 <4.0.0"
dart: ">=3.10.0-0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ topics:
- android
- native

version: 0.5.1
version: 0.5.2

environment:
sdk: '>=3.0.0 <4.0.0'
Expand Down
Loading