提交 7d147882 authored 作者: 史晓晨's avatar 史晓晨

feat:适配Flutter SDK 3.24.5,升级AGP 8.0+

上级 d665d252
......@@ -2,14 +2,14 @@ group 'com.clx.clx_flutter_message'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '1.8.20'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.android.tools.build:gradle:8.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
......@@ -25,19 +25,20 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
if (project.android.hasProperty("namespace")) {
namespace 'com.clx.clx_flutter_message'
}
namespace 'com.clx.clx_flutter_message'
compileSdkVersion 33
// 1. 升级 compileSdk 至 36(AGP 8.13 最佳兼容版本,替代 compileSdkVersion)
compileSdk 34
// 2. JDK 版本需升级至 17(AGP 8.13 强制要求)
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
// 3. Kotlin JVM 目标版本同步为 17
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}
sourceSets {
......@@ -46,23 +47,6 @@ android {
}
defaultConfig {
minSdkVersion 19
}
dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.mockito:mockito-core:5.0.0'
}
testOptions {
unitTests.all {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
minSdkVersion 21
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.clx.clx_flutter_message">
</manifest>
<manifest />
package com.clx.clx_flutter_message
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import kotlin.test.Test
import org.mockito.Mockito
/*
* This demonstrates a simple unit test of the Kotlin portion of this plugin's implementation.
*
* Once you have built the plugin's example app, you can run these tests from the command
* line by running `./gradlew testDebugUnitTest` in the `example/android/` directory, or
* you can run them directly from IDEs that support JUnit such as Android Studio.
*/
internal class ClxFlutterMessagePluginTest {
@Test
fun onMethodCall_getPlatformVersion_returnsExpectedValue() {
val plugin = ClxFlutterMessagePlugin()
val call = MethodCall("getPlatformVersion", null)
val mockResult: MethodChannel.Result = Mockito.mock(MethodChannel.Result::class.java)
plugin.onMethodCall(call, mockResult)
Mockito.verify(mockResult).success("Android " + android.os.Build.VERSION.RELEASE)
}
}
......@@ -24,16 +24,20 @@ if (flutterVersionName == null) {
android {
namespace "com.clx.clx_flutter_message_example"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
// 1. 升级 compileSdk 至 36(AGP 8.13 最佳兼容版本,替代 compileSdkVersion)
compileSdk 34
// 2. JDK 版本需升级至 17(AGP 8.13 强制要求)
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
// 3. Kotlin JVM 目标版本同步为 17
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}
sourceSets {
......@@ -45,8 +49,8 @@ android {
applicationId "com.clx.clx_flutter_message_example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
minSdkVersion 21 // 支持最低版本可保留 21(AGP 8.13 兼容)
targetSdkVersion 31// 建议与 compileSdk 一致(原 31 过低,需升级)
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
......
buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '1.8.20'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.android.tools.build:gradle:8.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
......
......@@ -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-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
......@@ -13,16 +13,18 @@ dependencies:
flutter_web_plugins:
sdk: flutter
plugin_platform_interface: ^2.0.2
web_socket_channel: ^2.1.0
web_socket_channel: ^3.0.3
octo_image: ^2.0.0
cached_network_image: ^3.3.0
fluttertoast: 8.2.4
get: ^4.6.6
cached_network_image: ^3.4.1
fluttertoast: ^8.2.14
get: ^4.7.2
dio: ^5.9.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
dio: ^5.7.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论