Skip to content

fix(android): support AGP built-in Kotlin - #249

Open
HsukqiLee wants to merge 1 commit into
talsec:masterfrom
ClosedHarmony:fix/android-built-in-kotlin
Open

HsukqiLee wants to merge 1 commit into
talsec:masterfrom
ClosedHarmony:fix/android-built-in-kotlin

Conversation

@HsukqiLee

@HsukqiLee HsukqiLee commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #218.

AGP 9 supplies Kotlin support by default. Applying kotlin-android again fails during project configuration with Cannot add extension with name 'kotlin', as there is an extension already registered with that name.

Apply the external Kotlin Android plugin only when the Android library plugin has not registered the Kotlin extension. This retains the existing AGP 8 path and supports AGP 9 with built-in Kotlin either enabled or disabled. Move the JVM 17 target from android.kotlinOptions to kotlin.compilerOptions, which both implementations support. The existing KGP 2.1.0 dependency, SDK requirements, Talsec security plugin and SDK configuration are preserved.

Validation

Executed on Windows with JDK 17 and the checked-out native sources:

Build configuration Result
AGP 8.8.1 / Gradle 8.12.1 / external Kotlin Debug and release AAR builds passed
AGP 9.0.1 / Gradle 9.6.0 / built-in Kotlin (default) Debug and release AAR builds passed
AGP 9.0.1 / Gradle 9.6.0 / android.builtInKotlin=false, android.newDsl=false Debug and release AAR builds passed
Flutter 3.51 development SDK / AGP 9.3.1 / Gradle 9.6.0 / built-in Kotlin Debug and release arm64 APK builds passed in a fresh consuming Flutter application using this checkout as a path dependency

The AAR builds used an isolated Gradle host with Flutter embedding and the real Flutter lifecycle plugin. app.talsec.plugin 1.1.0 and SDK 20.0.1 remained enabled. The library-only host reports that license-token generation is skipped because it has no :app; the APK builds used a real host application. These are build checks, not device threat-detection/callback validation.

Commands:

gradle :freerasp:assembleDebug :freerasp:assembleRelease
flutter build apk --debug --target-platform android-arm64
flutter build apk --release --target-platform android-arm64
flutter test
dart analyze lib test
git diff --check

All 91 existing tests passed; dart analyze lib test reported no issues. Full flutter analyze --no-pub reports five existing deprecation infos for the example's package:flutter/material.dart imports under this development SDK. AGP 8.8.1 also reports its existing compileSdk 36 support warning.

As a negative control, restoring only the unconditional Kotlin plugin application reproduces the duplicate-extension configuration failure on AGP 9.0.1; restoring the fix passes.

Checklist

  • Build configuration change
  • Existing tests pass
  • Changelog updated
  • AGP 8 external Kotlin and AGP 9 built-in Kotlin builds verified
  • Device runtime/callback verification

AI assistance: OpenCode (anyrouter-copy/gpt-6.1-sol) for implementation, validation and PR drafting. The validation commands were executed by the agent.

Apply the external Kotlin plugin only when AGP has not provided Kotlin support, and use compilerOptions for the Java 17 target.

Assisted-by: OpenCode:anyrouter-copy/gpt-6.1-sol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrates to built-in Kotlin

1 participant