1

I've implemented the new experimental build tools (gradle-experimental:0.2.1) for an app with many modules, but the current api is pretty awful and incompatible with certain libraries.

I'm curious if it's possible to pull all ndk code into a module and only process the ndk module with the experimental build tool and use the official build tools for the rest of the app. It'd be great to segregate all the experimental headaches into a small module.

I've tried a few things, but always ended up with gradle sync errors. Couldn't find anything online regarding whether this was feasible.

Anthony
  • 7,638
  • 3
  • 38
  • 71

1 Answers1

0

Part of my problem was an issue in the upgrade to AS 2.0. After fixing that issue I was able to do a quick test with the Hello World template project. I added a module and modified it to use the experimental plugin.

build.gradle (ndk module)


buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle-experimental:0.4.0"
    }
}
dependencies {
    repositories {
        jcenter()
    }
}

apply plugin: 'com.android.model.library'
model {
    android {
        compileSdkVersion = 23
        buildToolsVersion = "23.0.2"

        defaultConfig.with {
            minSdkVersion.apiLevel = 11
            targetSdkVersion.apiLevel = 22
            versionCode = 1
            versionName = "1"
        }
    }
}

Summary Update

I managed to get it working with ndk in a much more complicated project. Here are the four primary requisites to get it working:

  1. plugin gradle-experimental:0.4.0+ in your ndk module build.gradle (also convert to the new DSL)
  2. plugin gradle:1.5.0 in your project build.gradle
  3. Gradle 2.8 (gradle:1.5.0 plugin requires it)
  4. Remove all jni from your main project (moved to module) since it's deprecated in 1.3.0+.

Without the combination of those versions of the gradle plugins I had lots of errors. Bit of a headache working out the kinks, but now I've segregated my ndk headaches to a simple module and I can integrate things like crashlytics that don't play well with gradle-experimental.

Anthony
  • 7,638
  • 3
  • 38
  • 71