我有一个错误在我的应用程序,每次我看到我建立的项目它出现,我认为这是与房间的关系,但我不能解决它
日志:
Task :app:kaptDebugKotlin FAILED
C:\Users\matheus.correa_est\Desktop\Pokedex-
master\app\build\tmp\kapt3\stubs\debug\com\example\pokedex\MyApplication.java:13: error: cannot find
symbol
public final AppDataBase getDataBase() {
^
symbol: class AppDataBase
location: class MyApplication
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2s
24 actionable tasks: 1 executed, 23 up-to-date
MyApplication.java
package com.example.pokedex;
import java.lang.System;
d2 = {"Lcom/example/pokedex/MyApplication;", "Landroid/app/Application;", "()V", "dataBase",
"LAppDataBase;", "getDataBase", "()LAppDataBase;", "dataBase$delegate", "Lkotlin/Lazy;",
"repository", "Lcom/example/pokedex/repository/PokedexRepository;", "getRepository", "
()Lcom/example/pokedex/repository/PokedexRepository;", "repository$delegate", "app_debug"})
public class MyApplication extends android.app.Application {
@org.jetbrains.annotations.NotNull()
private final kotlin.Lazy dataBase$delegate = null;
@org.jetbrains.annotations.NotNull()
private final kotlin.Lazy repository$delegate = null;
@org.jetbrains.annotations.NotNull()
public final AppDataBase getDataBase() { // line where the error is being shown in the log
return null;
}
@org.jetbrains.annotations.NotNull()
public final com.example.pokedex.repository.PokedexRepository getRepository() {
return null;
}
public MyApplication() {
super();
}
}
类AppDatabase
@Database(entities = [PokemonItem::class], version = 1, exportSchema = false)
abstract class AppDataBase: RoomDatabase() {
abstract fun pokemonDAO(): PokemonDAO
companion object {
@Volatile
private var INSTANCE: AppDataBase? = null
fun getDataBase(context: Context): AppDataBase {
return INSTANCE ?: synchronized(this) {
val instance = Room.databaseBuilder(
context.applicationContext,
AppDataBase::class.java,
"pokemon-db"
)
.build()
INSTANCE = instance
instance
}
}
}
}
这个错误是在我使用AppDatabase进行数据持久化时开始发生的,我以为问题已经出现了,但从我看到的情况来看,我无法通过它的版本来修复它
看起来很不对劲。只需跟随google文档:
https://developer.android.com/training/data-storage/room
我如何解决这个问题?我没有添加任何新的库,也没有以任何方式修改这两个梯度,我只是在我的应用程序中添加了一些kotlin类,这些类是领域对象,然后运行应用程序,这个错误弹出,谢谢你的帮助! 误差
错误:任务执行失败 ': app:使用合并Java Res For Debug转换资源'。 com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException: APK META-INF/LICENSE File1中复制的重复文件: C:\用户Jithin-P
当我尝试构建项目时,Gradle build消息会报告以下消息: 失败:构建失败,但有一个异常。 > Gradle文件
我刚开始使用Kotlin,并尝试使用Dagger2进行设置,我见过一些示例,但它们似乎都不适合我。 我一直收到这个 错误:任务执行失败:应用程序:kaptDebugKotlin。 内部编译器错误。有关更多详细信息,请参阅日志 我有我的身材。gradle(模块:应用程序)
Build.Gradle: 当获取:
我多次清理和构建该项目,但没有工作。有什么问题?