How to build an NDK module using gradle experimental plugin?

I am trying to build a project with a module that uses NDK. But Gradle build gives an error.

this is my build.gradle (Main project)

buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' // classpath 'com.android.tools.build:gradle-experimental:0.1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } 

when I try to use this gradle: 1.5.0, it gives the error 'Error: (17, 0) Plugin with id' com.android.model.application 'was not found. ''

On the other hand, if I use gradle -experimental: 0.1.0, it gives the error 'Error: (17, 0) Plugin with id' com.android.application 'was not found. ''

How can I solve this error? I have several modules in my project. How to install Gradle with all modules running?

EDITED:

build.gradle (Main project)

 buildscript { repositories { jcenter() } dependencies { // classpath 'com.android.tools.build:gradle:1.5.0' classpath 'com.android.tools.build:gradle-experimental:0.4.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } def isReleaseBuild() { return isTag() && !isSnapshot() } def isSnapshot() { return version.contains("SNAPSHOT") } boolean isTravis() { return System.getenv('TRAVIS_BUILD_NUMBER') ? true : false } boolean isTag() { def tag = System.getenv('TRAVIS_TAG') return !(tag == null || tag.isEmpty()) } def buildNumber() { return System.getenv('TRAVIS_BUILD_NUMBER') ?: "0" } 

build.gradle (application)

 apply plugin: 'com.android.model.application' repositories { maven { url "https://oss.sonatype.org/content/repositories/snapshots" } maven { url "https://oss.sonatype.org/content/repositories/releases" } maven { url "https://oss.sonatype.org/content/repositories/staging" } } model { android { compileSdkVersion = 22 buildToolsVersion = "22.0.1" defaultConfig.with { applicationId = "com.ToxicBakery.viewpager.transforms" minSdkVersion.apiLevel = 16 targetSdkVersion.apiLevel = 22 versionCode = 1 versionName = "1.0" } } android.buildTypes { release { minifyEnabled = false proguardFiles += file('proguard-rules.txt') } } android.lintOptions { checkReleaseBuilds = false } } dependencies { compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.android.support:cardview-v7:22.0.0' compile 'info.hoang8f:fbutton:1.0.5' compile project(':contextMenu') compile project(':library') compile project(':library2') compile project(':titanic') compile files('libs/universal-image-loader-1.9.4.jar') compile project(':staggeredview') compile project(':min3d') } 

build.gradle (ContextMenu)

 apply plugin: 'com.android.model.library' model { android { compileSdkVersion = 21 buildToolsVersion = "21.1.2" defaultConfig.with { minSdkVersion.apiLevel = 11 targetSdkVersion.apiLevel = 21 } } android.lintOptions { checkReleaseBuilds = false } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.nineoldandroids:library:2.4.0' } 

build.gradle (library)

 apply plugin: 'com.android.model.library' apply plugin: 'signing' model { android { compileSdkVersion = 22 buildToolsVersion = "22.0.1" defaultConfig.with { minSdkVersion.apiLevel = 13 targetSdkVersion.apiLevel = 22 versionCode = 1 versionName = "1.0" } } android.buildTypes { release { minifyEnabled = false proguardFiles += file('proguard-rules.txt') } } android.lintOptions { checkReleaseBuilds = false } } dependencies { compile 'com.android.support:support-v13:22.1.1' } apply from: '../maven_push.gradle' 

build.gradle (library2)

 apply plugin: 'com.android.model.library' model { android { compileSdkVersion = 22 buildToolsVersion = "22.0.1" defaultConfig.with { minSdkVersion.apiLevel = 15 targetSdkVersion.apiLevel = 22 versionCode = 1 versionName = "1.0" } } android.buildTypes { release { minifyEnabled = false proguardFiles += file('proguard-rules.txt') } } android.lintOptions { checkReleaseBuilds = false } } dependencies { } 

build.gradle (min3d)

 apply plugin: 'com.android.model.library' model { android { compileSdkVersion = 15 buildToolsVersion = "21.0.2" defaultConfig.with { minSdkVersion.apiLevel = 15 targetSdkVersion.apiLevel = 22 versionCode = 1 versionName = "1.0" } } android.buildTypes { debug { } release { minifyEnabled = false proguardFiles += file('proguard-rules.txt') } } android.productFlavors { } android.lintOptions { checkReleaseBuilds = false } } dependencies { compile 'com.android.support:appcompat-v7:20.0.0' compile fileTree(dir: 'libs', include: ['*.jar', '*.aar']) } 

build.gradle (staggerdview)

 apply plugin: 'com.android.model.library' dependencies { compile 'com.android.support:support-v4:19.1.+' } model { android { compileSdkVersion = 22 buildToolsVersion = "22.0.1" defaultConfig.with { minSdkVersion.apiLevel = 15 targetSdkVersion.apiLevel = 22 versionCode = 1 versionName = "1.0" } } android.buildTypes { release { minifyEnabled = false proguardFiles += file('proguard-rules.txt') } } android.lintOptions { checkReleaseBuilds = false } } 

build.gradle (titanic)

 apply plugin: 'com.android.model.library' model { android { compileSdkVersion = 22 buildToolsVersion = '22.0.1' defaultConfig.with { minSdkVersion.apiLevel = 11 targetSdkVersion.apiLevel = 19 versionCode = 1 versionName = "1.0" } } android.buildTypes{ release { minifyEnabled = false proguardFiles += file('proguard-rules.txt') } } android.lintOptions { checkReleaseBuilds = false } } dependencies { compile 'com.android.support:appcompat-v7:20.+' compile fileTree(dir: 'libs', include: ['*.jar']) } 
+5
source share
1 answer

You should use an experimental plugin for the purpose of NDK:

So your build.gradle (Main project) will look like this:

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

and build.gradle (app) will look like this:

 apply plugin: 'com.android.model.application' model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.2" defaultConfig.with { applicationId = "com.sample.codecator" minSdkVersion.apiLevel = 19 targetSdkVersion.apiLevel = 19 } } } 

If you use any library module, then its build.gradle will look like this:

 apply plugin: 'com.android.model.library' model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.2" defaultConfig.with { minSdkVersion.apiLevel = 19 targetSdkVersion.apiLevel = 19 } } } 

You should do the following from the android{...} block android{...} :

 android.buildTypes android.sources android.productFlavors 

Like:

 model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.2" defaultConfig.with { minSdkVersion.apiLevel = 19 targetSdkVersion.apiLevel = 19 } android.buildTypes { release { minifyEnabled = false proguardFiles.add(file("proguard-rules.pro")) } } android.productFlavors { // } android.sources { // } } 

Remember to set ndk.dir=ndk_path in your local.properties file.

UPDATE

Update android.buildTypes code in your files as follows:

 android.buildTypes { release { minifyEnabled = false proguardFiles.add(file("proguard-rules.pro")) } } 
+5
source

Source: https://habr.com/ru/post/1240141/


All Articles