Skip to content

Commit 2f69d03

Browse files
committed
升级android gradle版本
1 parent fc4d975 commit 2f69d03

File tree

6 files changed

+50
-63
lines changed

6 files changed

+50
-63
lines changed

example/android/app/build.gradle

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,38 @@
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.")
12-
}
13-
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'
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
5+
id "dev.flutter.flutter-gradle-plugin"
226
}
237

24-
apply plugin: 'com.android.application'
25-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26-
278
android {
28-
compileSdkVersion 33
9+
namespace "io.openinstall.openinstall_flutter_plugin_example"
10+
compileSdk = flutter.compileSdkVersion
11+
ndkVersion = flutter.ndkVersion
2912

3013
lintOptions {
3114
disable 'InvalidPackage'
3215
}
3316

17+
kotlinOptions {
18+
jvmTarget = JavaVersion.VERSION_1_8
19+
}
20+
21+
compileOptions {
22+
sourceCompatibility JavaVersion.VERSION_1_8
23+
targetCompatibility JavaVersion.VERSION_1_8
24+
}
25+
3426
defaultConfig {
3527
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
3628
applicationId "io.openinstall.openinstall_flutter_plugin_example"
37-
minSdkVersion flutter.minSdkVersion
38-
targetSdkVersion 33
39-
versionCode flutterVersionCode.toInteger()
40-
versionName flutterVersionName
41-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
4229

30+
// You can update the following values to match your application needs.
31+
// For more information, see: https://flutter.dev/to/review-gradle-config.
32+
minSdk = flutter.minSdkVersion
33+
targetSdk = flutter.targetSdkVersion
34+
versionCode = flutter.versionCode
35+
versionName = flutter.versionName
4336

4437
manifestPlaceholders = [
4538
OPENINSTALL_APPKEY : "ufp21n",
@@ -60,9 +53,3 @@ flutter {
6053
source '../..'
6154
}
6255

63-
dependencies {
64-
testImplementation 'junit:junit:4.12'
65-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
66-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
67-
68-
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<activity
1616
android:name=".MainActivity"
1717
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
18+
android:exported="true"
1819
android:hardwareAccelerated="true"
1920
android:launchMode="singleTask"
2021
android:theme="@style/LaunchTheme"

example/android/build.gradle

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

19-
rootProject.buildDir = '../build'
8+
rootProject.buildDir = "../build"
209
subprojects {
2110
project.buildDir = "${rootProject.buildDir}/${project.name}"
2211
}
2312
subprojects {
24-
project.evaluationDependsOn(':app')
13+
project.evaluationDependsOn(":app")
2514
}
2615

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

example/android/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
org.gradle.jvmargs=-Xmx1536M
2-
3-
android.useAndroidX=true
2+
android.useAndroidX=true
3+
android.enableJetifier=true

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-6.5-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip

example/android/settings.gradle

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +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 flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
411

5-
def plugins = new Properties()
6-
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7-
if (pluginsFile.exists()) {
8-
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
917
}
1018

11-
plugins.each { name, path ->
12-
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13-
include ":$name"
14-
project(":$name").projectDir = pluginDirectory
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "8.1.0" apply false
22+
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
1523
}
24+
25+
include ":app"

0 commit comments

Comments
 (0)