Mixing android plugins from gradle and gradle-experimental
Asked Answered
O

3

7

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.

Otherdirected answered 3/11, 2015 at 21:18 Comment(2)
FYI, to enable Data Binding in Gradle you need do this instead: dataBinding { enabled = true }Reformatory
@Otherdirected i know this question has an accepted answer but did you manage to use gradle-experimental plugin (for NDK support) and databinding support or those two features have to be in the separate modules?Arana
H
4

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.

Hornstein answered 3/11, 2015 at 21:36 Comment(4)
Thanks, seems that solution was just try each of beta versions until you find working one. :) It's also worth mentioning that plugins can be used only with com.android.(application|library). So at the end to mix experimental and stable gradle plugin we should have different modules (what in my case was the point).Otherdirected
I am trying to mix 0.6.0-alpha3 and 1.5.0 but AndroidStudio/gradle does not seem to like it. My project is composed of a native module (producing an aar), then used by an android Library, both used by a main app. It does not raise any project-related error when loading it but Android Studio (1.5.1) is going crazy (auto disabling plugin, not being able to save files, not loading the android facet,...). If you have any advice, i am interested!Bud
Using the latest version, 0.6.0-alpha5, the IDE cannot resolve the module, even with compile project(":jni-project"). Did you have those issues with latest version of gradle?Microbarograph
I used this post gist.github.com/ph0b/0575b30b67e04f2ec10f to try mix up the experimental plugin with the regular one on Android Studio 2.0 and it failed miserably with the error "Gradle project refresh failed Error:String index out of range: -1". Why is Android Studio such a joke of an IDE or am I missing something really obvious?Aqua
A
0

Haven't used experimental plugin yet, but I guess, you can divide your project into 2 Gradle modules and use standard Android Gradle Plugin for the application module and new experimental plugin in the NDK module.

Ampere answered 3/11, 2015 at 21:37 Comment(0)
S
0

@ph0b is right, I am just giving an update of that answer.

you will need in your gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

and in your project build.gradle

    dependencies {
    classpath 'com.android.tools.build:gradle:2.1.3'
    classpath "com.android.tools.build:gradle-experimental:0.7.3"
}
Speakeasy answered 25/10, 2016 at 7:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.