java gradle execution_java-使用@Query Room Persistence Library时的org.gradle.execution.MultipleBuildFail...

温成济
2023-12-01

在Dao类(房间持久性库)中使用@Query时出现生成错误

我在项目中同时使用java和kotlin,因此可能存在依赖关系问题,我尝试了不同的实现和kapt,但没有运气.

我的依赖项(有关房间持久性库的更多信息,请参见)

dependencies {

implementation fileTree(include: ['*.jar'],dir: 'libs')

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

//noinspection GradleCompatible

implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'

implementation 'com.google.android.material:material:1.1.0-alpha05'

implementation "org.jetbrains.anko:anko:$anko_version"

implementation "org.jetbrains.anko:anko-commons:$anko_version"

implementation 'com.google.code.gson:gson:2.8.5'

implementation 'com.google.dagger:dagger:2.19'

implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'

implementation 'com.google.firebase:firebase-database:16.1.0'

annotationProcessor 'com.google.dagger:dagger-compiler:2.19'

kapt 'com.google.dagger:dagger-android-processor:2.19'

kapt 'com.google.dagger:dagger-compiler:2.19'

implementation 'com.squareup.retrofit2:retrofit:2.4.0'

implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'

implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'

implementation 'com.google.code.findbugs:jsr305:3.0.2'

testImplementation 'junit:junit:4.12'

androidTestImplementation 'androidx.test:runner:1.1.1'

androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

implementation 'androidx.cardview:cardview:1.0.0'

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

//BUTTER KNIFE

implementation 'com.jakewharton:butterknife:10.1.0'

kapt 'com.jakewharton:butterknife-compiler:10.1.0'

implementation 'androidx.recyclerview:recyclerview:1.0.0'

//crashlytics

implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'

// Update your firebase-core version,if it's lower than v11.4.2

implementation 'com.google.firebase:firebase-core:16.0.8'

implementation 'com.crashlytics.sdk.android:crashlytics-ndk:2.0.5'

//firebase messaging

implementation 'com.google.firebase:firebase-messaging:17.5.0'

//sms retrival

implementation 'com.google.android.gms:play-services-base:16.1.0'

implementation 'com.google.android.gms:play-services-identity:16.0.0'

implementation 'com.google.android.gms:play-services-auth:16.0.1'

implementation 'com.google.android.gms:play-services-auth-api-phone:16.0.0'

implementation project(':library')

//for intro

implementation 'com.github.AppIntro:AppIntro:5.1.0'

//picaso

implementation 'com.squareup.picasso:picasso:2.71828'

//room

def room_version = "1.1.1"

implementation "android.arch.persistence.room:runtime:$room_version"

kapt "android.arch.persistence.room:compiler:$room_version"

我的实体班

@Entity(tableName = "product")

public class Product

{

@PrimaryKey

@ColumnInfo(name = "id")

public Integer id;

@ColumnInfo(name = "category")

public String category;

@ColumnInfo(name = "name")

public String name;

@ColumnInfo(name = "price")

public Double price;

@ColumnInfo(name = "desc")

public String desc;

@ColumnInfo(name = "img_url")

public String img_url;

public Product(Integer id,String category,String name,Double price,String desc,String img_url) {

this.id = id;

this.category = category;

this.name = name;

this.price = price;

this.desc = desc;

this.img_url = img_url;

}

}

我的Dao类在不使用@Query时构建良好,

但是使用@Query时,会导致构建错误.

@Dao

public interface CartDao

{

@Query("SELECT * FROM product")

ArrayList getAllProduct();

@Delete

void delete(Product cart);

}

构建错误

org.gradle.execution.MultipleBuildFailures: Build completed with 1 failures..

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

Caused by: org.gradle.api.tasks.TaskExecutionException: Execution Failed for task ‘:app:kaptPureshDebugKotlin’…6 more

Caused by: org.gradle.api.GradleException: Compilation error. See log for more details

at org.jetbrains.kotlin.gradle.tasks.TasksUtilsKt.throwGradleExceptionIfError(tasksUtils.kt:14)

at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:135)

at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runCompilerAsync(GradleKotlinCompilerRunner.kt:152)

at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runCompilerAsync(GradleKotlinCompilerRunner.kt:147)

at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompilerAsync(GradleKotlinCompilerRunner.kt:87)

at org.jetbrains.kotlin.gradle.internal.KaptWithKotlincTask.compile(KaptWithKotlincTask.kt:72)..34 more

 类似资料: