Closed jkwiecien closed 9 years ago
Your code looks fine. I just ran a quick test of the same thing, and it seems to work.
I suspect the annotation processor is never running at compile time. What does your build config look like? Are you using any other annotation processing libraries in the same project?
Man, you're fast :) Yes, a dagger2 and a ButterKnife, what do you mean by build config?
You just caught me at the right time. An hour later and I'd be asleep :p
Are you using the APT plugin for those dependencies? Please share the contents of your build.gradle file if you don't mind that being public.
There:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "pl.aprilapps.mmm"
minSdkVersion 20
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), file('../proguard.txt')
signingConfig signingConfigs.releaseConfig
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('../proguard.txt'), file('../proguard-debug.txt')
signingConfig signingConfigs.releaseConfig
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(project(':android-shared'))
compile 'com.google.android.support:wearable:1.1.0'
compile 'com.google.android.gms:play-services-wearable:6.5.+'
compile 'com.pnikosis:materialish-progress:1.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.guava:guava:18.0'
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.github.jkwiecien:Switcher:1.0.3'
}
Can that be packaging options fault? I had to add this because it wouldn't compile otherwise.
P.S. I've added proguard configuration in case you wondering.
It's the APT plugin. It seems to take over all of the annotation processing for the compiler, so it's not being run for Courier. There should be a way to tell APT to run Courier's processor too. I'm trying a few things now. I'll post it here when I get something to work.
But can that exclude stay? Courier is conflicting with ButterKnife so I added that.
Yeah, the exclude should stay. It won't affect the annotation processing as that's done at compile time. The exclude relates to packaging the app into an apk file, which is done afterwards.
Ok I'll wait to hear from you. Thanks for the efforts, yo're da real MVP
I found this in the android-apt docs, which seems to contradict what we are seeing here. So I guess this is a bug in android-apt, though I suspect we should still be able to find a workaround.
For annotation processors that include the API and processor in one artifact,
there's no special setup. You just add the artifact to the compile configuration
like usual and everything will work like normal.
It looks like I will need to do some restructuring of the release build for Courier to get it to work with the android-apt
plugin (the compiler code needs to be separated from the api code). A lot of people use the apt plugin, so it's definitely something I want to do. I'll try to get this done tomorrow.
In the meantime you can try removing the android-apt
plugin from your configuration (removing the line apply plugin: 'com.neenbedankt.android-apt'
), though I'm not experienced enough with dagger
to know if it will work on its own.
You will have to change this:
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
to this:
provided 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
It's done!
All you need to do is update your dependency version to 1.0.2. Then it will work alongside the android-apt
plugin:
compile 'me.denley.courier:courier:1.0.2'
When I changed to 1.0.2 and resynced, Android Studio doesn't see Courier class. I did get back to 1.0.0 and resynced to check if gets back. It does.
It works fine for me. I also tried it on a different machine to make sure the jcenter repository version is working (my normal machine will have a cached version). I can't see any problems with it.
Weird, on a different project, different machine, without apt, it works fine...
Have you checked it with apt plugin? Because that seems still be the problem
Yes, I have.
If the Courier
class is not found then this is a build dependency problem rather than an annotation processing problem.
It works fine, when I removed apt from my project... but I lose dagger2 then.
I can't get Courier working inside wearable Fragment. Here is how I try to use it.
My app crashes at
Courier.startReceiving(this);
and I got this log:Courier not found for android.app.Fragment. Missing annotations?