Using 'model.android.ndk' command in build.gradle - android

I'm using gradle 4.4 and I can't the 'ndk' command is not found. This is my build.gradle of the application:
apply plugin: 'com.android.application'
apply plugin: 'cpp'
android {
System.setProperty('SYS', 'android')
compileSdkVersion 23
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "xxx"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
model {
android.ndk {
moduleName "native-lib"
}
}
I don't know what the problem is but i get the error:
The following model rules could not be applied due to unbound inputs
and/or subjects:
android.ndk { ... } # app\build.gradle line 27, column 5
subject:
- android.ndk Object [*]
[*] - indicates that a model item could not be found for the path or
type.
which refers to the line of the 'ndk' command.
Thanks!

Google essentially discontinued the experimental NDK plugin. Please follow their official guide to migrate to the stable plugin: Migrate to Stable Gradle for NDK Support using CMake and ndk-build.
If you have problems with this tutorial, and you need more guidance, please don't hesitate to ask here.

Related

Gradle finished with non-zero exit value 2?

I am trying to integrate Google Sign-in into my app
Google developer.
As mentioned I have also added to build.gradle files as follows:
dependency to project's top-level build.gradle:
classpath 'com.google.gms:google-services:1.4.0-beta3'
plugin to app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
when I start syncing,it downloads some stuff.
But after running it shows error that Gradle finished with non-zero exit value 2.
Currently I am using Android Studio v1.4
The most probable cause of this would be, you have a lot of libraries and thus lots of methods. Try enable multiDex in your app's build.gradle like below
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "in.alphawolf.wallmax"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true // Like this
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
and you will be able to build your project!

Gradle build Error:Cause: org.gradle.api.internal.ExtensibleDynamicObject

I am trying to import 'https://code.google.com/p/android-serialport-api/'into Android Studio. Since this project involves ndk, I followed the instructions to build NDK from the following link: http://tools.android.com/tech-docs/new-build-system/gradle-experimental
But after building, I get this error:
Gradle Project refresh Failed
Error:Cause: org.gradle.api.internal.ExtensibleDynamicObject
EDIT: I have 2.5 gradle version installed
Here's my build.gradle
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig.with {
applicationId = "android_serialport_api.sample"
minSdkVersion.apiLevel = 17
targetSdkVersion.apiLevel = 22
android.ndk {
moduleName = "serial_port"
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.productFlavors {
create("all")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
}
Can you try change
compileSdkVersion 22
buildToolsVersion "22.0.1"
to
compileSdkVersion = 22
buildToolsVersion = "22.0.1"
and
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
to
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
I've got the same error and this works for me.
Unfortunately the NDK preview implementation to support native code development in Android Studio is a moving target. Even if you use an older, developers.android.com stated, "supported" combination of the experimental Android Gradle plugin (from tools.android.com) and Gradle version (from gradle.org), good luck in getting the build to work. Instead, always use the latest released combination with the latest indicated module build.gradle language syntax, according to developers.android.com.
In your case, your mixing the use of assignment operators, "=" and "+=". Depending on the supported combo of gradle plugin and gradle version you're using, it's either use the assignment operators everywhere in module build.gradle file or nowhere - you have to be consistent, all or nothing. For "+=" use the method ".add(...)" instead.
And remember, the gradle scripting language is compiled to the Java runtime so when you see a build error that looks like a Java error, it's the gradle scripting that is likely the problem.
I got this error when I had a parameter not correctly moved from old gradle syntax to new one
(had cFlags "..." rather than CFlags += "...")
Have a look e.g. at http://tools.android.com/tech-docs/new-build-system/gradle-experimental

Android studio importing in gradle issue

I am new to Android Studio and was just trying to import my eclipse project. i am trying to resolve this issue for quite a while now but unable to.
I have a mainactivity project which uses mmany other libraries staggeredgridview, devsmart, google maps and appcompactv7. I am getting following 2 errors.
Note: mainactivity project is the one which i am working on and uses other external libraries.
Error:(7, 5) uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library B:\Android Studio Projects\mainActivity\build\intermediates\exploded-aar\com.google.android.gms\play-services\6.5.87\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.google.android.gms" to force usage
:mainActivity:processDebugManifest FAILED
Error:Execution failed for task ':mainActivity:processDebugManifest'.
Manifest merger failed with multiple errors, see logs
build.gradle of mainactivity
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.staggeredgridviewdemo"
minSdkVersion 8
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':devsmartAndroid')
compile project(':staggeredGridViewmaster')
compile 'com.google.guava:guava:16.0.1'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:19.1.0'
compile files('libs/commons-codec-1.6.jar')
}
build.grade for devsmart
apply plugin: 'com.android.library'
android {
compileSdkVersion 14
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 4
targetSdkVersion 4
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/CWAC-SackOfViewsAdapter.jar')
compile('com.android.support:appcompat-v7:19.1.0') {
// really use 19.1.0 even if something else resolves higher
force = true
}
}
build.gradle for sttageredgridview
apply plugin: 'com.android.library'
android {
compileSdkVersion 17
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile('com.android.support:appcompat-v7:19.1.0') {
// really use 19.1.0 even if something else resolves higher
force = true
}
}
Just edit minsdk of your build.gradle of mainactivity to 9 :
defaultConfig {
applicationId "com.example.staggeredgridviewdemo"
minSdkVersion 9 // changed line
targetSdkVersion 16
}
Note : Also did the same for other libs if there minsdk is small then 9
Please open your manifest file and write the bellow code it will work
<uses-sdk tools:overrideLibrary="com.google.android.gms"/>
and add the list of libraries for uses-skd separated by comma
Go to all the manifest files or build.gradle files of all the projects and make the minSDKversions the same.8 for instance.

Getting Android Studio, Gradle and Android Annotations working together

now that i've decided to use Android Annotations with Android Studio i wanted to implement it through Gradle. After some thoughtful research i've found out that there are older and newer ways of implementing Android Annotations through Gradle depending on which version android studio, gradle or android annotations have. i came to this useful tutorial -> http://www.jayway.com/2014/02/21/androidannotations-setup-in-android-studio/ , and tried to implement this , at first, with the new 'android-L' as target SDK like
targetSDKversion "android-L" + compileSdkVersion 20 + buildToolsVersion "20.0.0"
until i tried it with
targetSDKversion 20 + compileSdkVersion 20 + buildToolsVersion "20.0.0"
and also
targetSDKversion 19 + compileSdkVersion 19 + buildToolsVersion "19.1.0".
Everytime i was getting 2 warnings that my java classes dont seem to get precompiled. even though it seems that it pre-creates the build/generated/source/apt directory. but without my pre-processed class from my MainActivity -> MainActivity_
I always do get following Warnings:
Note: Resolve log file to D:\AndroidProjects\GradleTest\app\build\generated\source\apt\androidannotations.log
Note: Initialize AndroidAnnotations 3.0.1 with options >{androidManifestFile=D:\AndroidProjects\GradleTest\app\build\intermediates\manifests\debug\AndroidManifest.xml, resourcePackageName=at.gradle.defuex.gradletest}
warning: Unclosed files for the types '[dummy1407928544078]'; these types will not undergo annotation processing
warning: The following options were not recognized by any processor: '[androidManifestFile, resourcePackageName]'
My build.gradle file looks like this:
buildscript{
repositories{
mavenCentral()
}
dependencies{
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.3'
}
}
repositories{
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "at.gradle.defuex.gradletest"
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
signingConfigs{
releaseConfig{
storeFile file("gradlekeystore.jks");
storePassword ("*************");
keyAlias "keyAlias";
keyPassword "*************";
}
}
buildTypes {
release {
runProguard false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseConfig
}
debug {
debuggable true
applicationIdSuffix ".debug"
}
}
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName "at.gradle.defuex.gradletest"
}
}
dependencies {
apt "org.androidannotations:androidannotations:3.0+"
compile "org.androidannotations:androidannotations-api:3.0+"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
Im using following Versions:
Android Studio version 0.8.2
Gradle version 0.12.2
android-apt version 1.3
android annotations version 3.0.1 (as seen in the build.gradle file)
If there should be a solution to this problem please tell me, because im confused now.
If there should be a better annotations framework or a way of using cool annotations, please tell me that too.
And if it should not be a common way anymore to use annotations for android projects anyway, please pleeeeease tell me that too.
,but i would prefer a solution to my problem :)
Cheers!
Try to run gradlew clean build from project root.
Then try to make project (button with a green arrow with 0 and 1) before running on a device. Should be fine.

error: package xxx does not exist . how do include packages in the build correctly?

I'm trying to use the project android-wheel from https://code.google.com/p/android-wheel/
with Android Studio.
I imported them as modules and put the dependency for 'wheel' into the build.gradle of 'wheeldemo'.
when building it with gradle it shows errors, that packages do not exist, even though the imports in the java file don't show any errors:
I'm not sure, what I'm missing here. Might be something obvious, since I'm not to familiar with android programming, yet.
edit: here is the build.gradle of the wheeldemo module:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId 'kankan.wheel.demo'
minSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile project(':wheel')
}
Make sure the build.gradle of "wheel" has correct plugin type. It should be 'android-library' instead of 'com.android.application'.

Categories

Resources