Skip to content

Commit

Permalink
适配AGP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
simplezhli committed Nov 24, 2024
1 parent 1e09534 commit e3ee1a3
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 61 deletions.
30 changes: 13 additions & 17 deletions 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,12 +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 @@ -22,21 +22,13 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

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

def keystorePropertiesFile = rootProject.file("app/key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
compileSdkVersion 34

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
applicationId "com.weilu.deer"
minSdkVersion 21
Expand Down Expand Up @@ -73,8 +65,12 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
namespace 'com.weilu.deer'
lint {
disable 'InvalidPackage'
}
}

Expand All @@ -83,5 +79,5 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.20"
}
3 changes: 1 addition & 2 deletions android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.weilu.deer">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
3 changes: 1 addition & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.weilu.deer">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<uses-permission android:name="android.permission.INTERNET"/>
Expand Down
3 changes: 1 addition & 2 deletions android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.weilu.deer">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
18 changes: 0 additions & 18 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
buildscript {
ext.kotlin_version = '1.7.0'
repositories {
maven { url 'https://maven.aliyun.com/repository/public' }//jcenter
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }//gradle-plugin
maven { url 'https://maven.aliyun.com/repository/central' }//central
maven { url 'https://maven.aliyun.com/repository/google' }//google
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}

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

allprojects {
repositories {
maven { url 'https://maven.aliyun.com/repository/public' }
Expand Down
5 changes: 4 additions & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ kotlin.incremental=true
kotlin.incremental.java=true
kotlin.incremental.js=true
kotlin.caching.enabled=true
kotlin.parallel.tasks.in.project=true
kotlin.parallel.tasks.in.project=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Sep 13 21:08:20 CST 2020
#Sat Nov 23 15:18:48 CST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
30 changes: 20 additions & 10 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +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
}()

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.3.1" apply false
id "org.jetbrains.kotlin.android" version "1.8.20" apply false
}

include ":app"
14 changes: 7 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,30 @@ dependencies:
# 状态管理 https://github.com/rrousselGit/provider
provider: ^6.1.2
# 扫码 https://github.com/juliuscanute/qr_code_scanner
qr_code_scanner: 1.0.0
# git:
# url: https://github.com/xeinebiu/qr_code_scanner.git
# ref: fix_break_changes_platform
qr_code_scanner:
git:
url: 'https://github.com/NeverOvO/qr_code_scanner.git'
ref: '3fe7b88'
# App Shortcuts https://github.com/flutter/packages/tree/main/packages/quick_actions
quick_actions: 1.0.7
# 振动 https://github.com/benjamindean/flutter_vibration
vibration: 2.0.0
vibration_web: 1.6.8
# 获取当前设备信息 https://github.com/fluttercommunity/plus_plugins/tree/main/packages/device_info_plus
device_info_plus: 10.0.1
device_info_plus: 11.1.1
# 桌面应用调整窗口的大小和位置 https://github.com/leanflutter/window_manager
window_manager: 0.4.0
# 高德2D地图插件(支持Web) https://github.com/simplezhli/flutter_2d_amap
flutter_2d_amap:
git:
ref: '3850a4dc'
ref: '0105ceae'
url: 'https://github.com/simplezhli/flutter_2d_amap.git'
# demo 用到的库
# 刮刮卡 https://github.com/vintage/scratcher
scratcher: ^2.5.0
# 动画效果 https://github.com/xvrh/lottie-flutter
lottie: ^3.1.2
win32: 5.5.1
win32: 5.5.3

# https://github.com/simplezhli/flutter_deer/issues/187
dependency_overrides:
Expand Down

0 comments on commit e3ee1a3

Please sign in to comment.