当前位置: 首页 > 知识库问答 >
问题:

无法访问ActivityCompatapi23-kotlin-androidx-dagger 2.17

元鸿波
2023-03-14

短错误日志:

> :presentation:transformDataBindingWithDataBindingMergeArtifactsForDebug
> e: E:\MVVM\presentation\build\tmp\kapt3\stubs\debug\com\example\mvvm\ui\base\BaseActivity.java:9: error: cannot access ActivityCompatApi23
public abstract class BaseActivity extends dagger.android.support.DaggerAppCompatActivity {
                ^
  class file for android.support.v4.app.ActivityCompatApi23 not found
e: java.lang.IllegalStateException: failed to analyze: java.lang.AssertionError: annotation tree hasn't been attributed yet: @kotlin.Metadata(mv = {1, 1, 11}, bv = {1, 0, 2}, k = 1, d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b&\u0018\u00002\u00020\u0001B\u0005\u00a2\u0006\u0002\u0010\u0002\u00a8\u0006\u0003"}, d2 = {"Lcom/example/mvvm/ui/base/BaseActivity;", "Ldagger/android/support/DaggerAppCompatActivity;", "()V", "presentation_debug"})

库的验证:

ext{
minSdkVersion = 14
targetSdkVersion = 28
androidCompileSdkVersion = 28
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
androidPluginVersion = '3.1.4'
kotlinVersion = '1.2.70'
supportVersion = '1.0.0-alpha1'
daggerVersion = '2.17'
roomVersion = '2.0.0-beta01'
lifecycleVersion = '2.0.0-beta01'
rxJavaVersion = '2.2.2'
rxAndroidVersion = '2.1.0'
supportTest = '1.1.0-alpha1'
multidexVersion = '2.0.0'
...
}

kotlin: "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}",
rxJava: "io.reactivex.rxjava2:rxjava:${rxJavaVersion}",
rxAndroid: "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion",
appCompat: "androidx.appcompat:appcompat:$supportVersion",
material: "com.google.android.material:material:$supportVersion",
supportv4: "androidx.legacy:legacy-support-v4:$supportVersion",
appcompatv7: "androidx.appcompat:appcompat:$supportVersion",
recyclerview: "androidx.recyclerview:recyclerview:$supportVersion",
cardview: "androidx.cardview:cardview:$supportVersion",
annotation: "androidx.annotation:annotation:$supportVersion",
javaxInject: "javax.inject:javax.inject:$javaxInjectVersion",
dagger: "com.google.dagger:dagger:${daggerVersion}",
daggerAndroid: "com.google.dagger:dagger-android:${daggerVersion}",
daggerAndroidSupport: "com.google.dagger:dagger-android-support:${daggerVersion}",
daggerAndroidProcessor: "com.google.dagger:dagger-android-    processor:${daggerVersion}",
daggerCompiler: "com.google.dagger:dagger-compiler:${daggerVersion}",
room: "androidx.room:room-runtime:$roomVersion",
roomCompiler: "androidx.room:room-compiler:$roomVersion",
roomCommon: "androidx.room:room-common:$roomVersion",
constraintLayout: "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion",
multidex: "androidx.multidex:multidex:$multidexVersion",
lifecycleExtensions: "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion",
lifecycleCommon: "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
...
abstract class BaseActivity : DaggerAppCompatActivity()
class MyApplication : DaggerApplication() {

    override fun applicationInjector(): AndroidInjector<out DaggerApplication> {

        return DaggerAppComponent.builder().create(this)
    }
}
@Singleton
@Component(modules = [
    AndroidSupportInjectionModule::class,
    ViewModelBuilder::class,
    AppModule::class,
    BaseModule::class
])
interface AppComponent : AndroidInjector<MyApplication> {
    @Component.Builder
    abstract class Builder : AndroidInjector.Builder<MyApplication>()
}
@Module(includes = [NetModule::class, DbModule::class])
abstract class AppModule {

    @ApplicationContext
    @Binds
    abstract fun provideApplicationContext(myApplication: MyApplication): Context
}
:presentation:transformDataBindingWithDataBindingMergeArtifactsForDebug
> e: E:\MVVM\presentation\build\tmp\kapt3\stubs\debug\com\example\mvvm\ui\base\BaseActivity.java:9: error: cannot access ActivityCompatApi23
public abstract class BaseActivity extends dagger.android.support.DaggerAppCompatActivity {
                ^
  class file for android.support.v4.app.ActivityCompatApi23 not found
e: java.lang.IllegalStateException: failed to analyze: java.lang.AssertionError: annotation tree hasn't been attributed yet: @kotlin.Metadata(mv = {1, 1, 11}, bv = {1, 0, 2}, k = 1, d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b&\u0018\u00002\u00020\u0001B\u0005\u00a2\u0006\u0002\u0010\u0002\u00a8\u0006\u0003"}, d2 = {"Lcom/example/mvvm/ui/base/BaseActivity;", "Ldagger/android/support/DaggerAppCompatActivity;", "()V", "presentation_debug"})
    at org.jetbrains.kotlin.analyzer.AnalysisResult.throwIfError(AnalysisResult.kt:56)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:125)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:161)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:57)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:96)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:52)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:93)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:441)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:101)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:1020)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:101)
    at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:1062)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:1019)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:440)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
    at sun.rmi.transport.Transport$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    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: java.lang.AssertionError: annotation tree hasn't been attributed yet: @kotlin.Metadata(mv = {1, 1, 11}, bv = {1, 0, 2}, k = 1, d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b&\u0018\u00002\u00020\u0001B\u0005\u00a2\u0006\u0002\u0010\u0002\u00a8\u0006\u0003"}, d2 = {"Lcom/example/mvvm/ui/base/BaseActivity;", "Ldagger/android/support/DaggerAppCompatActivity;", "()V", "presentation_debug"})
    at com.sun.tools.javac.util.Assert.error(Assert.java:133)
    at com.sun.tools.javac.util.Assert.checkNonNull(Assert.java:118)
    at com.sun.tools.javac.comp.Check.validateTypeAnnotation(Check.java:2745)
    at com.sun.tools.javac.comp.Attr$TypeAnnotationsValidator.visitAnnotation(Attr.java:4484)
    at com.sun.tools.javac.tree.JCTree$JCAnnotation.accept(JCTree.java:2317)
    at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
    at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
    at com.sun.tools.javac.tree.TreeScanner.visitModifiers(TreeScanner.java:315)
    at com.sun.tools.javac.tree.JCTree$JCModifiers.accept(JCTree.java:2343)
    at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
    at com.sun.tools.javac.comp.Attr$TypeAnnotationsValidator.visitClassDef(Attr.java:4566)
    at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
    at com.sun.tools.javac.comp.Attr.validateTypeAnnotations(Attr.java:4473)
    at com.sun.tools.javac.code.TypeAnnotations$2.run(TypeAnnotations.java:142)
    at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:155)
    at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:129)
    at com.sun.tools.javac.comp.Enter.complete(Enter.java:512)
    at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
    at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
    at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:47)
    at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:27)
    at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:213)
    at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:178)
    at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:96)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:95)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:105)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:82)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:375)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:67)
    at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:366)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:120)
    ... 30 more

 > :presentation:kaptDebugKotlin FAILED

 > FAILURE: Build failed with an exception.

 > * What went wrong:
Execution failed for task ':presentation:kaptDebugKotlin'.
> Internal compiler error. See log for more details

我阅读了所有相关的问题,例如:

  • 无法访问ActivityCompatApi23类
  • 尝试使用FragmentActivity时无法访问ActivityCompatApi23
  • 错误:(59,8)错误:无法访问Android.support.v4.app.ActivityCompatApi23类文件
  • 无法访问ActivityCompatApi23类文件
  • 无法访问ActivityCompatApi23类文件,因为找不到ActivityCompatApi23
  • 错误:(59,8)错误:无法访问Android.support.v4.app.ActivityCompatApi23类文件
  • ...

他们都说支持库的版本不一样;或者compilesdkversion必须为28。

共有1个答案

萧晔
2023-03-14
android {    
...
compileOptions {
    targetCompatibility 1.8
    sourceCompatibility 1.8
}
override fun attachBaseContext(base: Context) {
    super.attachBaseContext(base)
    MultiDex.install(this)
}
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

来源:
https://github.com/google/dagger/issues/1245
Androidx和数据绑定
https://stackoverflow.com/A/41100670/421467
https://stackoverflow.com/A/48531191/421467
https://stackoverflow.com/A/49525685/421467
https://stackoverflow.com/studio/build/multidex
https://developer.android.com/topic/libraries/support-library/refactor

 类似资料:
  • 问题内容: 这是我的build.gradle 当我运行项目时,我会看到此错误 错误:(59、8)错误:无法访问android.support.v4.app.ActivityCompatApi23的ActivityCompatApi23类文件 和 错误:任务’:app:compileDebugJavaWithJavac’的执行失败。 编译失败;有关详细信息,请参见编译器错误输出。 我该如何解决这个问

  • 我不知道如何使用以下内容显示自定义片段: 类型不匹配:推断的类型是LoginFrament,但预期是片段

  • 我已经实现了RecycraView. ViewHolder子类如下: 现在,我正试图访问在它中声明的绑定属性,就像在回收站视图的子类中一样。适配器: 但编译器正在抱怨—— 以下是完整的实现: 如果我在这里错过了什么,有什么想法吗?请建议。

  • 我遇到toast错误它将进入我在清单中正确地授予了摄像头权限 这是我的kt代码。 帮忙解决这个问题?

  • 任何人都可以对此提供帮助: 我正在android Studio 3.5.2中编译一个android应用程序(sdk中的所有内容都是最新的)并获得以下链接到应用程序的错误:javaPreCompileDebug: 错误消息是 如果有人能破译,我在下面附加了一个完整的堆栈跟踪。使用Jetifier转换com.android.tools/common/26.4.2/71f8d5ea1ddb6bfe3fb

  • 问题内容: 我真的很想用Struts2来解决问题- 通过省略部分路径,我可以访问JSP页面。请注意该路径应该包括在内。关键是要看路径中的单词。 这是文件: 我可以通过: 和通过: 请注意,在两个URL中,我都可以删除,为什么? 来源:http: //www.mkyong.com/misc/how-to-use-mkyong- tutorial/ 有人可以看完上面的教程,告诉我怎么了吗? 问题答案: