前几天还可以正常运行,这两天打开项目,发现报错:
报错一:
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.7.10/bac80c520d0a9e3f3673bc2658c6ed02ef45a76a/kotlin-stdlib-common-1.7.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
e: /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (16, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (18, 21): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (24, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (25, 23): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (30, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (31, 23): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (38, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (40, 80): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (43, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (45, 24): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (47, 24): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (53, 21): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/app/src/main/kotlin/com/nolovr/vrtools/mobile/MainActivity.kt: (54, 21): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/wf/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 38s
[!] Your project requires a newer version of the Kotlin Gradle plugin.
Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/android/build.gradle:
ext.kotlin_version = '<latest-version>'
Exception: Gradle task assembleDebug failed with exit code 1
根据错误提示,升级Kotlin版本,在android->build.gradle 文件中,修改ext.kotlin_version
改完以后重新运行,以前那个错误没有了,但是又报出一个新的错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> More than one file was found with OS independent path 'META-INF/com.android.tools/proguard/coroutines.pro'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 14s
Exception: Gradle task assembleDebug failed with exit code 1
这时候在android->app->build.gradle 中添加以下内容即可:
packagingOptions {
exclude 'META-INF/com.android.tools/proguard/coroutines.pro'
}
报错二:
Error: ADB exited with exit code 1
Performing Streamed Install
adb: failed to install /Users/wf/Documents/workspace/project/flutter/nolovr-assistant/build/app/outputs/flutter-apk/app.apk: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1366387552.tmp/base.apk (at Binary XML file line #478): com.sina.weibo.sdk.share.ShareResultActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]
解决:
将targetSdkVersion
改成30 或者更低的版本,重新运行项目
最后项目正常运行。