2

Short error log:

> :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"})

Libraries' verions:

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"
...

Android Studio version: 3.1.4

BaseActivity:

abstract class BaseActivity : DaggerAppCompatActivity()

MyApplication:

class MyApplication : DaggerApplication() {

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

        return DaggerAppComponent.builder().create(this)
    }
}

AppComponent:

@Singleton
@Component(modules = [
    AndroidSupportInjectionModule::class,
    ViewModelBuilder::class,
    AppModule::class,
    BaseModule::class
])
interface AppComponent : AndroidInjector<MyApplication> {
    @Component.Builder
    abstract class Builder : AndroidInjector.Builder<MyApplication>()
}

AppModule:

@Module(includes = [NetModule::class, DbModule::class])
abstract class AppModule {

    @ApplicationContext
    @Binds
    abstract fun provideApplicationContext(myApplication: MyApplication): Context
}

Full error log:

: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

I've read all of related questions such as:

All of them say that the support libraries' versions are not the same; Or the compileSdkVersion have to be 28.

I've considered all of these but the error still exists!

I think there is something wrong/missed with using androidx, kotlin, and dagger; But I'm not sure what it is.

2

1 Answer 1

2
  • First, set databinding to false, to see is there any resources/layout errors or not. (Which in my case, it was for the first error. Yes, there came other errors which I didn't paste it in the question anymore).

  • Set multiDexEnabled true in your app module's build.gradle, inside of defaultConfig scope (Or in data and presentation modules' build.gradle files if you're following a Clean Architecture, like me).

  • Add below snippet code to data and presentation's build.gradle files:

    android {    
    ...
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
    
  • Don't forget to set databinding to true again.

  • Change Build Gradle Tools version to classpath 'com.android.tools.build:gradle:3.3.0-alpha11'
  • Adding this line to your local.properties file: org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m; Of course, according to your hardware config.
  • Use Gradle distributation version upper than 4.4. Like: distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip. (Inside gradle-wrapper.properties file).
  • Add below snippet code to your CustomMyApplication:

    override fun attachBaseContext(base: Context) {
        super.attachBaseContext(base)
        MultiDex.install(this)
    }
    
  • Add below lines to your gradle.properties file:

    android.useAndroidX=true
    # Automatically convert third-party libraries to use AndroidX
    android.enableJetifier=true
    
  • Change supportVersion key to supportVersion = '1.0.0-rc02'//'1.0.0-alpha1'
  • Change daggerVersion key to daggerVersion = '2.16'//2.17
  • Change roomVersion key to roomVersion = '2.0.0-alpha1'//'2.0.0-beta01'

Sources:
https://github.com/google/dagger/issues/1245
Androidx and databinding
https://stackoverflow.com/a/41100670/421467
https://stackoverflow.com/a/48531191/421467
https://stackoverflow.com/a/49525685/421467
https://developer.android.com/studio/build/multidex
https://developer.android.com/topic/libraries/support-library/refactor
https://developer.android.com/topic/libraries/architecture/adding-components
https://developer.android.com/jetpack/docs/release-notes#july_2_2018
https://github.com/JakeWharton/butterknife/issues/1270#issuecomment-388449463

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.