Gen*_*ain 9 android gradle android-studio flutter
我目前正在使用 Android studio 尝试运行我大约一年半前制作的旧 Flutter 项目。当我尝试运行它时,出现错误:
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.window:window-java:1.0.0-beta04.\
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.window:window:1.0.0-beta04.
Run Code Online (Sandbox Code Playgroud)
我知道有人提出并回答了类似的问题,但有一个关键的区别。这些问题的答案是强制 gradle 使用旧版本的包,但据我所知,1.0.0 是这些依赖项的最低版本。
我想我也许可以删除依赖项,但我不确定我是否需要它们或如何做到这一点,但我不能使用旧版本。
目前我的 minSdkVersion 是 21,我的 targetSdkVersion 以及compileSdkVersion 是 30。我尝试将这些数字提高到 31 和 32,但这带来了我无法解决的其他问题。
我在这里有什么选择?我可以以某种方式删除这些软件包吗?我应该以某种方式升级到 SDK 31 吗?
更新:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
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'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "com.example.r_app"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Run Code Online (Sandbox Code Playgroud)
我的 build.gradle 文件按照 @romtsn 的请求。
此外,我尝试在 Android Studio SDK 管理器中将我的 SDK 更改为一系列从 30 到 32 不等的不同选项,但无济于事。
替换此代码:
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "com.example.r_app"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
...........
dependencies {
implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Run Code Online (Sandbox Code Playgroud)
通过以下
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "com.example.r_app"
minSdkVersion 21
targetSdkVersion 31
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
.......and.......
dependencies {
implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.guava:guava:27.0.1-android'
}
Run Code Online (Sandbox Code Playgroud)
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"并在 project_file -> android -> build.gradle 中添加以下行:
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
......
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Run Code Online (Sandbox Code Playgroud)
之后open for editing in Android Studio在右上角..允许它构建。然后运行。如果需要 - flutter clean - pubspec.yaml 中的 pub_get。我认为这应该有效..因为我不确定您遇到了什么其他要求或错误。
| 归档时间: |
|
| 查看次数: |
21278 次 |
| 最近记录: |