Skip to content

Commit

Permalink
android: sdk 34, api level 21
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Jul 16, 2024
1 parent b50f17b commit 09d7aa2
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 46 deletions.
20 changes: 11 additions & 9 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
classpath 'com.android.tools.build:gradle:8.5.0' // for compileSdk 34. default ndk 26.1.10909125
}
}

Expand All @@ -22,14 +22,18 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
namespace 'com.mediadevkit.fvp'
compileSdk 33 // flutter.compileSdkVersion
if (project.android.hasProperty("namespace")) {
namespace 'com.mediadevkit.fvp'
}
// Bumping the plugin compileSdkVersion requires all clients of this plugin
// to bump the version in their app.
compileSdk 34

// Bumping the plugin ndkVersion requires all clients of this plugin to bump
// the version in their app and to download a newer version of the NDK.
//ndkVersion "25.2.9519653" // flutter.ndkVersion
// Use the NDK version
// declared in /android/app/build.gradle file of the Flutter project.
// Replace it with a version number if this plugin requires a specfic NDK version.
// (e.g. ndkVersion "23.1.7779620")
//ndkVersion '26.3.11579264' // android.ndkVersion

// Invoke the shared CMake build with the Android Gradle Plugin.
externalNativeBuild {
Expand All @@ -42,7 +46,6 @@ android {
// installed. You should not increase this version, as doing so will cause
// the plugin to fail to compile for some customers of the plugin.
// version "3.10.2"
//version "3.26.4"
}
}

Expand All @@ -52,8 +55,7 @@ android {
}

defaultConfig {
minSdkVersion 16
//targetSdkVersion 33
minSdkVersion 21 // lower version error in ndk 26

externalNativeBuild {
cmake {
Expand Down
27 changes: 17 additions & 10 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,20 +22,24 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace "com.mediadevkit.fvp_example"
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
//ndkVersion flutter.ndkVersion // too low version

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

sourceSets {
//main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.mediadevkit.fvp_example"
Expand All @@ -58,3 +63,5 @@ android {
flutter {
source '../..'
}

dependencies {}
2 changes: 1 addition & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
android:value="2" />
<meta-data
android:name="io.flutter.embedding.android.EnableImpeller"
android:value="true" />
android:value="false" />
</application>
<!--
Internet access permissions.
Expand Down
20 changes: 3 additions & 17 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
//mavenCentral()
maven{ url = "https://maven.aliyun.com/nexus/content/groups/public/" }
}

dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
//mavenCentral()
maven{ url = "https://maven.aliyun.com/nexus/content/groups/public/" }
mavenCentral()
//maven{ url = "https://maven.aliyun.com/nexus/content/groups/public/" }
}
}

Expand All @@ -30,4 +16,4 @@ subprojects {

tasks.register("clean", Delete) {
delete rootProject.buildDir
}
}
4 changes: 3 additions & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#Tue Jul 16 13:41:50 CST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
# 8.0 does not support compileSdk 34
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
30 changes: 22 additions & 8 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
repositories {
google()
mavenCentral()
//maven{ url = "https://maven.aliyun.com/nexus/content/groups/public/" }
gradlePluginPortal()
}
}

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version '8.5.0' apply false // compileSdk 34
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
include ":app"

0 comments on commit 09d7aa2

Please sign in to comment.