1
0
mirror of https://github.com/flutter/samples.git synced 2026-04-20 05:52:21 +00:00

Upgrade android_splash_screen Gradle configuration (#2779)

I noticed that the `android_splash_screen` sample was outdated and was
not runnable due to gradle issues.

This commit fixes the Gradle setup for the `android_splash_screen`
sample.

Key changes include:
*   Upgrading Gradle wrapper from version 6.7 to 8.7.
* Migrating to the plugins block in `settings.gradle` and
`app/build.gradle` for applying Android, Kotlin, and Flutter Gradle
plugins.
* Removing the outdated `buildscript` block from the root
`build.gradle`.
*   Updating `compileSdkVersion` and `targetSdkVersion` to 34.
*   Setting `minSdkVersion` to `flutter.minSdkVersion`.
* Adding the `namespace` property as required by newer Android Gradle
Plugin versions.
*   Refactoring Kotlin constant declarations in `MainActivity.kt`.

@ericwindmill 

## Pre-launch Checklist

- [x] I read the [Flutter Style Guide] _recently_, and have followed its
advice.
- [x] I signed the [CLA].
- [x] I read the [Contributors Guide].
- [x] I have added sample code updates to the [changelog].
- [x] I updated/added relevant documentation (doc comments with `///`).

Co-authored-by: Eric Windmill <eric@ericwindmill.com>
This commit is contained in:
Niaz Sagor
2026-04-15 22:30:37 +06:00
committed by GitHub
parent 6957e4ad04
commit e3dd7cbd81
5 changed files with 52 additions and 37 deletions

View File

@@ -1,3 +1,10 @@
plugins {
id "com.android.application"
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
@@ -21,12 +28,9 @@ 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 {
compileSdkVersion 31
namespace "com.example.splash_screen_sample"
compileSdkVersion 34
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
@@ -35,12 +39,21 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.splash_screen_sample"
minSdkVersion 21
targetSdkVersion 30
minSdkVersion flutter.minSdkVersion
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
@@ -55,7 +68,6 @@ flutter {
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.core:core-splashscreen:1.0.0-alpha02"
implementation "androidx.core:core:1.5.0-alpha05"
implementation "androidx.core:core-ktx:1.6.0"

View File

@@ -203,9 +203,9 @@ class MainActivity : FlutterActivity() {
}
private companion object {
const val SPLASHSCREEN_ALPHA_ANIMATION_DURATION = 500 as Long
const val SPLASHSCREEN_TY_ANIMATION_DURATION = 500 as Long
const val SPLASHSCREEN_FINAL_ANIMATION_ALPHA_ANIMATION_DURATION = 250 as Long
const val WAIT_FOR_AVD_TO_FINISH = false
const val SPLASHSCREEN_ALPHA_ANIMATION_DURATION = 500L
const val SPLASHSCREEN_TY_ANIMATION_DURATION = 500L
const val SPLASHSCREEN_FINAL_ANIMATION_ALPHA_ANIMATION_DURATION = 250L
const val WAIT_FOR_AVD_TO_FINISH = false
}
}