[BUG] Execution failed for task ‘:app:kaptDebugKotlin‘.

488 阅读1分钟

我的场景:

1.Mac电脑,M1芯片 2.新工程项目,没有任何改动

报错信息

Execution failed for task ':app:kaptDebugKotlin'.

> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

e120df1eb1a94ebbb79c5837e02faadc.png

解决办法

  • (1)

在Google的IssueTracker里找到的
总结:room没有适配M1,需要对room引用进行修改


 
//解决:Mac M1也遇到了的问题。问题来自于对空间的使用:
//Execution failed for task ':app:kaptDebugKotlin'.
//> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
    
    
//追加这条
kapt "org.xerial:sqlite-jdbc:3.34.0"

kapt("androidx.room:room-compiler:2.3.0-beta01")


  • (2)
 def room_version = "2.3.0-alpha03"
    implementation("androidx.room:room-runtime:$room_version") {
        exclude(group:'org.xerial')
    }
    kapt("androidx.room:room-compiler:$room_version"){
        exclude(group:'org.xerial')
    }
    implementation("androidx.room:room-ktx:$room_version"){
        exclude(group:'org.xerial')
    }
    implementation 'org.xerial:sqlite-jdbc:3.34.0'


原因

  • 大佬们的给出的意见
1. Room uses https://github.com/xerial/sqlite-jdbc a JDBC library for SQLite, can you please file a bug in https://github.com/xerial/sqlite-jdbc asking to support the aarch64 architecture in the new Mac + M1 Chip?
(`Room` 使用https://github.com/xerial/sqlite-jdbc SQLite的JDBC库,你能在https://github.com/xerial/sqlite-jdbc中提交一个bug,要求在新的Mac + M1芯片中支持aarch64架构吗?)

2. I don’t have a M1 machine to try this out but my guess is they simply don’t have yet a compiled SQLite native lib for the aarch64.
(我没有一台M1机器来尝试这个,但我猜他们只是还没有为aarch64编译的SQLite本机库。)

3.By the way, I imagine you can workaround this using a JDK x86/x64 version + Rosetta that would make the JNI layer load the right native library.
(顺便说一下,我认为您可以使用JDK x86/x64版本+ Rosetta来解决这个问题,这将使JNI层加载正确的本机库。)


4.Yes, Apple Silicon is supported by this pull request https://github.com/xerial/sqlite-jdbc/pull/558, but not released yet.
(是的,这个pull request https://github.com/xerial/sqlite-jdbc/pull/558支持Apple Silicon,但尚未发布。)

Hope to be supported in the next version of Room. Thanks!
(希望在Room的下一个版本中得到支持。谢谢!)


核心解决办法


kapt("org.xerial:sqlite-jdbc:3.34.0") //追加这条
kapt("androidx.room:room-compiler:2.3.0-beta01")

使用这一种可以解决我的问题