Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Gradle Plugin 1.1.0 - getNdkFolder() not found anymore, any replacement?

I just updated android Gradle plugin to 1.1.0 from 1.0.0, and I got this error:

No signature of method: com.android.build.gradle.LibraryPlugin.getNdkFolder() is applicable for argument types: () values: []

I tried to find diff of gradle plugin 1.0.0 to 1.1.0 but couldn't find anywhere online.

Seems like getNdkFolder method has been either changed or removed.

Is there a replacement ? Or any other way to get NdkFolder ?

I'm using that method like this,

def ndkDir = project.plugins.findPlugin ( 'com.android.library' ).getNdkFolder ()

I have also filed an issue against tools team in Android issue tracker: https://code.google.com/p/android/issues/detail?id=152810

Thank you !

like image 473
Jigar Avatar asked Feb 19 '15 19:02

Jigar


Video Answer


2 Answers

You can get it like this:

plugins.getPlugin('com.android.library').sdkHandler.getNdkFolder()
like image 105
Michael Pardo Avatar answered Oct 05 '22 07:10

Michael Pardo


The correct way - android.ndkDirectory

The change from android.plugin.ndkFolder to android.ndkDirectory was documented in the technical doc Migrating Gradle Projects to version 1.0.0. In addition you should update your android plugin to 2.3.0.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
    }
}

The sdkFolder is internal and will likely stop working just like ndkFolder stopped working.

Regarding experimental branches

Search around, the plugin is mature enough you'll have trouble finding reasons to use experimental branches with the NDK.

There is some discussion about an Experimental version of the plugin breaking ndkDirectory which is the documented way to access this value after 1.1. If that changes in a released version I'll update my answer, in the mean time if running experimental plugins is your thing you can hack your way around this bug/feature using @Alex Cohn's answer.

like image 29
Cameron Lowell Palmer Avatar answered Oct 05 '22 09:10

Cameron Lowell Palmer