I have an android library for which I created 2 linting rules. In the project there are 3 packages, the main one with a sample app, the lib package, and the linting package. The only link between the lib and the lint modules that I can find, is in the build.gradle of the lib
lintPublish(project(':app:linter_pkg'))
All is fine and well when I try the linting rules while the lib is brought in the sample like this
implementation project(path: ':app:myLib')
But as soon as I publish the library to github packages as a .aar, and I bring the lib in the sample app using the remote package, one of the linting rules stops working.
And this doesn't make any sense to me. When the library is brought with local linkage both rules work, so clearly the code works. It doesn't seem like I am publishing the linting rules wrongly, since one of the rules still works. So the aar gets downloaded and linked correctly.
I also inspected the build files and .class files of what I am published and comapred them with what Android Studio produces when I link the lint locally and they are identical.
Any idea what would cause this sort of behaviour, only half of the build to be broken?
I have to admit I am not an Android developer, so please forgive if my answer is not helpful or even wrong, but I have an idea of what went wrong here.
Looking at Google's example of custom lint rules, you will find that they have not nested their lint rules under the
appfolder, but into a separate folder namedcheckswith usingapply plugin: 'java-library'in itsbuild.gradleand noandroidsection. When you nest the lint rules intoapp, I assume that the build information of the app'sbuild.gradleis taken into account, which targets the Android runtime (which is not capable of the full Java API). However the lint rules are intended to be run under a real JVM/JDK, therefor it should have a completely independentbuild.gradle.Finally they publish the lint rules together with the lib as you did:
If my answer is wrong, you still might compare your project (and especially the
build.gradleof the lint rules) with the example and might find some crucial difference.