Search code examples
androidgradleandroid-ndkgradle-experimental

Mixing android plugins from gradle and gradle-experimental


Is there any way or workarounds or just hints to make plugins from gradle and gradle-experimental working together?

For example to mix those two versions:

com.android.tools.build:gradle:1.3.1
com.android.tools.build:gradle-experimental:0.3.0-alpha4

I have an existing project which uses some external plugins (app/build.gradle):

apply plugin: 'com.android.model.application'
apply plugin: 'com.android.databinding'
apply plugin: 'com.jakewharton.hugo'

in my root build.gradle I have:

com.android.tools.build:gradle-experimental:0.3.0-alpha4

Issues which I have:

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.databinding']
   > java.lang.NullPointerException (no error message)

or

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.jakewharton.hugo']
   > 'android' or 'android-library' plugin required.

Without other plugins my project works fine (I have Android Library with some NDK code which is called from my main project. Problem occurs when I add mentioned plugins on any others.

And the question is - is it a gradle-experimental issue or issue of each plugin (hugo, databinding, apt, probably much more).

Or maybe you have any hints if there is any other way to have app with current stable gradle plugin and library (with NDK code) which uses gradle-experimental?

What I want to avoid is a dealing with *.mk files and (as full as possible) Android Studio support. Bigger picture is to prepare .aar library with NDK code (just simple computation) which will be able to plug in to existing projects.


Solution

  • I've been able to mix gradle stable and -experimental android plugins without any issues by using recent versions in my project.

    You should be able to define both dependencies inside your project's build.gradle file:

    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.3.0-alpha7'
        classpath 'com.android.tools.build:gradle:1.4.0-beta6'
    }
    

    and then either use apply com.android.(application|library) or com.android.model.(application|library) from your various module's build.gradle files.