Skip to content

Commit a7c26a5

Browse files
committed
🚀 适配最新版 Flutter 3.24.0
1 parent d516e8a commit a7c26a5

File tree

5 files changed

+54
-57
lines changed

5 files changed

+54
-57
lines changed

example/android/app/build.gradle

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,33 @@
1-
def localProperties = new Properties()
2-
def localPropertiesFile = rootProject.file('local.properties')
3-
if (localPropertiesFile.exists()) {
4-
localPropertiesFile.withReader('UTF-8') { reader ->
5-
localProperties.load(reader)
6-
}
7-
}
8-
9-
def flutterRoot = localProperties.getProperty('flutter.sdk')
10-
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "dev.flutter.flutter-gradle-plugin"
125
}
136

14-
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15-
if (flutterVersionCode == null) {
16-
flutterVersionCode = '1'
17-
}
18-
19-
def flutterVersionName = localProperties.getProperty('flutter.versionName')
20-
if (flutterVersionName == null) {
21-
flutterVersionName = '1.0'
22-
}
23-
24-
apply plugin: 'com.android.application'
25-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26-
277
android {
28-
compileSdkVersion 31
29-
ndkVersion "21.4.7075529"
8+
namespace = "com.zero.flutter_gromore_ads_example"
9+
compileSdk = flutter.compileSdkVersion
10+
ndkVersion = flutter.ndkVersion
11+
3012
compileOptions {
31-
sourceCompatibility JavaVersion.VERSION_1_8
32-
targetCompatibility JavaVersion.VERSION_1_8
13+
sourceCompatibility = JavaVersion.VERSION_1_8
14+
targetCompatibility = JavaVersion.VERSION_1_8
15+
}
16+
17+
kotlinOptions {
18+
jvmTarget = JavaVersion.VERSION_1_8
3319
}
3420

3521
defaultConfig {
3622
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
3723
applicationId "com.flutterads.app"
38-
minSdkVersion flutter.minSdkVersion
39-
targetSdkVersion 30
40-
versionCode flutterVersionCode.toInteger()
41-
versionName flutterVersionName
42-
multiDexEnabled true
24+
// You can update the following values to match your application needs.
25+
// For more information, see: https://flutter.dev/to/review-gradle-config.
26+
minSdk = flutter.minSdkVersion
27+
targetSdk = flutter.targetSdkVersion
28+
versionCode = flutter.versionCode
29+
versionName = flutter.versionName
30+
multiDexEnabled = true
4331
}
4432

4533
buildTypes {
@@ -57,7 +45,7 @@ android {
5745
}
5846

5947
flutter {
60-
source '../..'
48+
source = "../.."
6149
}
6250

6351
dependencies {

example/android/app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
android:theme="@style/LaunchTheme"
3131
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
3232
android:hardwareAccelerated="true"
33+
android:exported="true"
3334
android:windowSoftInputMode="adjustResize">
3435
<!-- Specifies an Android theme to apply to this Activity as soon as
3536
the Android process has started. This theme is visible to the user
@@ -92,11 +93,13 @@
9293
<activity
9394
android:name="com.qq.e.ads.PortraitADActivity"
9495
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
96+
android:exported="false"
9597
android:screenOrientation="portrait" />
9698
<activity
9799
android:name="com.qq.e.ads.LandscapeADActivity"
98100
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
99101
android:screenOrientation="landscape"
102+
android:exported="false"
100103
tools:replace="android:screenOrientation" />
101104

102105
<!-- 声明SDK所需要的组件 -->
@@ -107,7 +110,8 @@
107110

108111
<activity
109112
android:name="com.qq.e.ads.ADActivity"
110-
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" />
113+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
114+
android:exported="false" />
111115
<!-- GDT end================== -->
112116

113117
</application>

example/android/build.gradle

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
1-
buildscript {
2-
repositories {
3-
google()
4-
mavenCentral()
5-
}
6-
7-
dependencies {
8-
classpath 'com.android.tools.build:gradle:7.3.0'
9-
}
10-
}
11-
121
allprojects {
132
repositories {
143
google()
154
mavenCentral()
165
}
176
}
187

19-
rootProject.buildDir = '../build'
8+
rootProject.buildDir = "../build"
209
subprojects {
2110
project.buildDir = "${rootProject.buildDir}/${project.name}"
22-
project.evaluationDependsOn(':app')
11+
}
12+
subprojects {
13+
project.evaluationDependsOn(":app")
2314
}
2415

2516
tasks.register("clean", Delete) {

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip

example/android/settings.gradle

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
include ':app'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
29

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
511

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
818

9-
def flutterSdkPath = properties.getProperty("flutter.sdk")
10-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "7.3.0" apply false
22+
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
23+
}
24+
25+
include ":app"

0 commit comments

Comments
 (0)