Skip to content

Commit a50532e

Browse files
committed
版本跟flutter_ohos版本保持一致
1 parent 2f69d03 commit a50532e

File tree

4 files changed

+67
-48
lines changed

4 files changed

+67
-48
lines changed

example/android/app/build.gradle

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,59 @@
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"
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+
}
67
}
78

8-
android {
9-
namespace "io.openinstall.openinstall_flutter_plugin_example"
10-
compileSdk = flutter.compileSdkVersion
11-
ndkVersion = flutter.ndkVersion
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+
}
1213

13-
lintOptions {
14-
disable 'InvalidPackage'
15-
}
14+
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15+
if (flutterVersionCode == null) {
16+
flutterVersionCode = '1'
17+
}
1618

17-
kotlinOptions {
18-
jvmTarget = JavaVersion.VERSION_1_8
19-
}
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 plugin: 'kotlin-android'
26+
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27+
28+
android {
29+
compileSdkVersion flutter.compileSdkVersion
30+
ndkVersion flutter.ndkVersion
2031

2132
compileOptions {
2233
sourceCompatibility JavaVersion.VERSION_1_8
2334
targetCompatibility JavaVersion.VERSION_1_8
2435
}
2536

37+
kotlinOptions {
38+
jvmTarget = '1.8'
39+
}
40+
41+
sourceSets {
42+
main.java.srcDirs += 'src/main/kotlin'
43+
}
2644
defaultConfig {
2745
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
2846
applicationId "io.openinstall.openinstall_flutter_plugin_example"
29-
3047
// 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
48+
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
49+
minSdkVersion flutter.minSdkVersion
50+
targetSdkVersion flutter.targetSdkVersion
51+
versionCode flutterVersionCode.toInteger()
52+
versionName flutterVersionName
3653

3754
manifestPlaceholders = [
3855
OPENINSTALL_APPKEY : "ufp21n",
3956
]
40-
4157
}
4258

4359
buildTypes {
@@ -53,3 +69,8 @@ flutter {
5369
source '../..'
5470
}
5571

72+
dependencies {
73+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
74+
}
75+
76+

example/android/build.gradle

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1+
buildscript {
2+
ext.kotlin_version = '1.7.10'
3+
repositories {
4+
google()
5+
mavenCentral()
6+
}
7+
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:7.2.0'
10+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11+
}
12+
}
13+
114
allprojects {
215
repositories {
316
google()
417
mavenCentral()
518
}
619
}
720

8-
rootProject.buildDir = "../build"
21+
rootProject.buildDir = '../build'
922
subprojects {
1023
project.buildDir = "${rootProject.buildDir}/${project.name}"
1124
}
1225
subprojects {
13-
project.evaluationDependsOn(":app")
26+
project.evaluationDependsOn(':app')
1427
}
1528

1629
tasks.register("clean", Delete) {
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Fri Jun 23 08:50:38 CEST 2017
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
43
zipStoreBase=GRADLE_USER_HOME
54
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip

example/android/settings.gradle

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
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-
}()
1+
include ':app'
92

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

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

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
23-
}
24-
25-
include ":app"
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"

0 commit comments

Comments
 (0)