我在构建我的 apk 时遇到此错误:
C:/Users/Hao/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.9.10/dafaf2c27f 27c09220cee312df10917d9a5d97ce/kotlin-stdlib-common-1.9.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module:模块是使用不兼容的 Kotlin 版本编译的。其元数据的二进制版本是1.9.0,预期版本是1.6.0。
还有一些其他元数据的二进制版本是 1.8.0 或 1.9.9999,预计也是 1.6.0。
我尝试用
ext.kotlin_version
中的 android\build.gradle
解决,但没有任何改变。./gradlew build
,我得到:无法确定任务 ':google_mobile_ads:test' 的依赖关系。
无法创建任务“:google_mobile_ads:testProfileUnitTest”。 此文件和基本文件具有不同的根:E:\Projects\project uild\google_mobile_ads 和 C:\Users\Hao\AppData\Local\Pub\Cache\hosted\pub.dev\google_mobile_ads-5.2.0 ndroid。
自从出现错误以来我已经修复的内容:
设置.gradle:
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")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.1" apply false //downgraded and upgraded
id "org.jetbrains.kotlin.android" version "1.9.10" apply false //changed to 1.6.x / 1.7.x / 1.8.x
id 'com.google.gms.google-services' version '4.4.2' apply false //changed to 4.3.15 for another error
}
include ":app"
android uild.gradle:
buildscript {
ext.kotlin_version = '1.9.10' //comment in, out
repositories {
google()
mavenCentral()
// maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
classpath("com.google.gms:google-services:4.4.2") //changed with the one in settings.gradle
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") // comment in, out with ext.kotlin_version
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
应用程序uild.gradle:
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"
id "com.google.gms.google-services"
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:33.5.1')
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
implementation('com.google.firebase:firebase-auth:23.1.0')
implementation('com.google.firebase:firebase-firestore:25.1.1')
implementation('com.google.android.gms:play-services-base:18.5.0')
implementation("com.google.android.gms:play-services-ads:23.5.0")
implementation("com.google.firebase:firebase-ads:23.5.0")
// implementation("androidx.core:core-ktx:1.9.0")
// implementation('com.google.android.gms:play-services-security:18.0.0')
// implementation('androidx.appcompat:appcompat:1.7.0')
// implementation('androidx.legacy:legacy-support-v4:1.0.0')
// implementation('androidx.annotation:annotation:1.9.1')
// configurations.all {
// resolutionStrategy {
// force "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// force "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
// force "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
// }
// }
}
//apply plugins('com.google.gms.google-services')
def localProperties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader("UTF-8") { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
flutterVersionCode = "1"
}
def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
flutterVersionName = "1.0"
}
android {
namespace = "com.example.tictactoe_rebuild"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.tictactoe_rebuild"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdk = 23/*flutter.minSdkVersion*/
targetSdk = flutter.targetSdkVersion
versionCode = flutterVersionCode.toInteger()
versionName = flutterVersionName
}
kotlinOptions {
jvmTarget = "17"
}
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 = "../.."
}
我需要修复这些问题才能投放广告。
这不是错误,它显示为红色,但应用程序继续正常工作