提交 4e0db27b authored 作者: 史晓晨's avatar 史晓晨

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

上级 640f5027
......@@ -2,14 +2,14 @@ group 'com.clx.feedback_complaint_plug'
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,40 +25,29 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 31
// 1. 升级 compileSdk 至 36(AGP 8.13 最佳兼容版本,替代 compileSdkVersion)
compileSdk 35
// 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 {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
}
defaultConfig {
minSdkVersion 16
}
// 4. AGP 8.0+ 要求显式声明 namespace(替代 AndroidManifest.xml 中的 package)
namespace "com.clx.feedback_complaint_plug"
dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.mockito:mockito-core:5.0.0'
defaultConfig {
minSdkVersion 21 // 支持最低版本可保留 21(AGP 8.13 兼容)
}
testOptions {
unitTests.all {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.clx.feedback_complaint_plug">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!--用于访问网络,网络定位需要上网-->
<uses-permission android:name="android.permission.INTERNET" />
......
package com.clx.feedback_complaint_plug
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 FeedbackComplaintPlugPluginTest {
@Test
fun onMethodCall_getPlatformVersion_returnsExpectedValue() {
val plugin = FeedbackComplaintPlugPlugin()
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)
}
}
......@@ -27,16 +27,20 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.clx.feedback_complaint_plug_example"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
// 1. 升级 compileSdk 至 36(AGP 8.13 最佳兼容版本,替代 compileSdkVersion)
compileSdk 35
// 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 {
......@@ -48,8 +52,8 @@ android {
applicationId "com.clx.feedback_complaint_plug_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 21
targetSdkVersion flutter.targetSdkVersion
minSdkVersion 21 // 支持最低版本可保留 21(AGP 8.13 兼容)
targetSdkVersion 31// 建议与 compileSdk 一致(原 31 过低,需升级)
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
......@@ -68,5 +72,5 @@ flutter {
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
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-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
\ No newline at end of file
......@@ -12,18 +12,18 @@ dependencies:
sdk: flutter
plugin_platform_interface: ^2.0.2
# webview https://pub.dev/packages/webview_flutter
webview_flutter: ^4.0.5
webview_flutter: ^4.10.0
# 文件选择
file_picker: ^5.2.9
file_picker: 10.3.2
# 权限 https://pub.dev/packages/permission_handler
permission_handler: ^9.2.0
permission_handler: ^12.0.1
# toast https://pub.dev/packages/fluttertoast
fluttertoast: ^8.2.1
fluttertoast: ^8.2.14
# https://pub.dev/packages/image_picker
image_picker: ^0.8.6
image_picker: ^1.1.2
#https://pub.dev/packages/path_provider/install
path_provider: ^2.0.5
image: ^4.1.3
path_provider: ^2.1.5
image: ^4.5.4
dev_dependencies:
flutter_test:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论