Anyone was successfully able to use dagger in proj...
# android
v
Anyone was successfully able to use dagger in project which uses both java and kotlin? I'm not able to inject in kotlin classes
r
vivekneel: kindly post error log
r
I managed, running with all the stable versions.
v
@radityagumay My bad, Just figured it out that I forgot to remove
apply plugin: 'com.neenbedankt.android-apt
Now it’s working fine. Thanks guys.
r
Good. If you use AS 3 Canary 4 you should not use apt or kapt again
👍 1
w
So that means it should work without
apt libraries.daggerCompiler
?
@radityagumay I removed the apt and kapt both. I am using Kotlin only in tests for now. I changed every compile to implementation and provided to compileOnly etc. But Dagger related classes are not generated in tests though. In normal java code Dagger generated classes are available. Any idea what I need to do more to have my previous setup back? I have this as annotation processor now:
testAnnotationProcessor libraries.daggerCompiler
annotationProcessor libraries.daggerCompiler
Kotlin version is
1.1.2-5
dagger and dagger compiler version is
2.10
.
r
Have you clean and rebuild? Sound weird, that should work.
w
@radityagumay I was able to fix this by updating the kotlin plugin again from plugins menu
r
Well done. Great!
w
On rechecking again even though it was installed android studio shows the current version to 4 again 🤔 , trying it one more time..
r
If you can't, I think this bug from AS 3 Canary 4. 😂
😞 1
Did you put code somewhere for dagger compiler?
So I can check it
w
@radityagumay this is the gist of important parts. Also I shouldn't need a separate testAnnotationProcessor as this used to be kaptAndroidTest before but now same processor should work 🤔 ? https://pastebin.com/M6CJdHtn
Copy code
0.31 KB
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
 
 
 
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    implementation libraries.dagger
    compileOnly libraries.appcompat
    annotationProcessor libraries.daggerCompiler
    testAnnotationProcessor libraries.daggerCompiler
}
BTW I am using
org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-5
v
Have you also added generateStub?
@waqas ^
w
@vivekneel No I had it before, but after removing kapt I removed that too.
@vivekneel do I need to add it?
v
Dagger classes are generated after adding stub. Try adding and see in your /app/build.gradle
w
But as both apt/kpat are removed in new implementation, how it's recognized? I get this
Error:(35, 0) Could not set unknown property 'generateStubs' for object of type com.android.build.gradle.LibraryExtension.
v
Pls post your build.gradle
w
v
@waqas try adding
Copy code
kapt {
        generateStubs = true
    }
under android {}
w
okay..
@vivekneel nope, still no dagger classes in test sources