Skip to content Skip to sidebar Skip to footer

Can't Import Aar Library With @intdef Annotations

I have the following code in my library: @Documented @IntDef({OpacityAnimationType.NONE, OpacityAnimationType.BLINKING, OpacityAnimationType.SHINY, OpacityA

Solution 1:

So finally I've been able to overcome this issue!

It looks like in case of custom annotations custom annotation processor is also required. For now I've decided to skip creating custom annotation processor and not use custom annotations for enumerations with @IntDef.

But anyways, if your library uses existing annotations and you publish it on mavenCentral or jCenter or other repository and use it in other projects, that you'll need to add some magic to javadoc task.

It starts here: https://github.com/vulko/AnimatedArcProgressView/blob/master/library/build.gradle with

    configurations {
        javadocDeps
    }
    dependencies {
        // ...compile("com.android.support:support-annotations:$supportLibraryVersion") {
            transitive false;
        }   
        javadocDeps "com.android.support:support-annotations:$supportLibraryVersion"
    }

and then continues in publishing gradle script here: https://github.com/vulko/AnimatedArcProgressView/blob/master/gradle/publish-library.gradle with:

task androidJavadocs(type: Javadoc) {
    source = android.sourceSets.main.java.source// this is the magic
    classpath += configurations.javadocDeps

    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

Anyways, all the code can be found here: https://github.com/vulko/AnimatedArcProgressView/

Solution 2:

Been googling this issue and looks like if there are any annotations in library, library needs an annotations project which will contain those. Not sure about the processor though, hopefully it wouldn't be needed, otherwise I'll have to switch from custom annotations to @IntDef with some static final int's instead.

There's also some gradle magic that is required to do this, and so far no good tutorials, but a bunch of code on github with processors and annotations. I'd like to avoid using custom processor, cause I simply don't need it.

Any ways, I'll try to keep this thread updated when I finally manage to solve this issue.

Solution 3:

Now the story continues. I had to create a annotations submodule in library project for annotations, and I had to move @IntDef's out of it, otherwise it wouldn't be able to import any of android annotations to submodule. So I've moved @IntDef's to library, and they use custom annotations from submodule now.

Even though I'm able to build and deploy it, the library artifact can't be imported, cause:

Error:Could not find com.kvolkov.animatedprogressviews:annotations:unspecified. Searched in the following locations: Required by: project : > com.kvolkov.animatedprogressviews:library:1.0-RC5

I assume this happens because I need to deploy annotations submodule as a separate artifact now, which I can't do, since I wasn't able to match code from some tutorial for .gradle of annotations module with the plugins for bintray to deploy it there from studio...

Well, this is still not the end. If any1 is interested or willing to help, you might take a look at current code of library here: https://github.com/vulko/AnimatedArcProgressView

I'd be glad to recieve some help or advice, cause all info regarding this uses apt instead of annotation processor.

Post a Comment for "Can't Import Aar Library With @intdef Annotations"