NDK files not syncing with Gradle Android - android

I am doing a project on Beaglebone Black and i have ported Android KitKat on it. Now i need an android app that could help me access those gpios on beaglebone for a project.
So i am using android studio 1.3.1 to create my application for my project and so to access the hardware pins via android i have to use NDK for it. Now when i am trying to sync gradle 2.2.1 with my NDK files it prints an error that i should set android.useDeprecatedNdk=true. Now when i do that it again shows the error that DeprecatedNdk() is not defined.
Although i have downloaded the latest version of NDK i.e. android-ndk-r10e from android developers website but the error still persists.
Following is the build.gradle file from the module.
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.packt.gpio"
minSdkVersion 19
targetSdkVersion 19
ndk {
moduleName "packtHAL"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.+'
}
Also the error that it is showing is:
Error:(14, 0) Error: NDK integration is deprecated in the current plugin.
Consider trying the new experimental plugin. For details, see http://tools.android.com/tech-docs/new-build-system/gradle-experimental.
Set "android.useDeprecatedNdk=true" in gradle.properties to continue using the current NDK integration.
And if i add the property to the file then it shows the following error:
Error:(6, 0) Gradle DSL method not found: 'useDeprecatedNdk()'
Possible causes:The project 'gpio' may be using a version of Gradle that does not contain the method.
The build file may be missing a Gradle plugin.
If anyone has any idea as to what should be done regarding this. Please share your ideas.
Thank you

Please check the new documentation: http://tools.android.com/tech-docs/android-ndk-preview
Here are the latest project setup instructions: http://tools.android.com/tech-docs/new-build-system/gradle-experimental
This just popped up too: http://ph0b.com/new-android-studio-ndk-support/

Related

Android studio 2.1.1 doesn't recognise stdio.h but runs it fine

There are similar questions on the site, but most of them are from before Android Studio 2.1 and apparently that seems to have fixed it for everyone else except me.
I'm using Android Studio 2.1.1, JDK 1.8, NDK 1.2 rc1, gradle-experimental 0.7.0 alpha4 plugin, but I'm still having problems with Android Studio refusing to recognise any C library functions like stdio.h, jni.h, and so forth.
The problem is that header declarations like #include <stdio.h> all have the header's name in the error colours, and when I mouse over, the only explanation it offers is "cannot find stdio.h" for example. Then of course stuff like printf and system all show up in error colours
However, it runs perfectly fine with the C code. It's not like the greatest impediment, but I would love to actually use Android Studio's features rather than having to guess if I'm writing the correct code.
It turns out that in my app's build.gradle file, I had the NDK settings in the defaultConfig object instead of directly under android.ndk, which caused the issue. So do doublecheck your build.gradle files!
For reference, the fixed build.gradle file:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "meow"
}
buildTypes {
release {
minifyEnabled false
proguardFiles.add(file('proguard-rules.pro'))
}
}
ndk {
moduleName "mao"
ldLibs.add("log")
}
}
}

Gradle DSL method not found 'android()' error?

I am new at developing android.I use Android Studio.I am getting an error Gradle DSL method not found:'android()'.Then I googled the error.Someone says that Android Studio incorrectly adds the android() method in the top-level build.gradle file. and delete the method.After I deleted android() from build.gradle.I am getting a new error Install Build Tools 23.0.0 rc2 and sync project.I am so tired with.
How can I overcome it.
I can see you don't have the right Android plugin in your gradle file, it should be:
apply plugin: 'com.android.application'
Besides, you need the android extension to be something like:
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.your.package.id"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.5"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Also, I think you are not editing the right Gradle file. You have a "general" build.gradle, which you should not edit generally, and your module build.gradle (typically in your app folder), where all these things need to be.
This is very similar to what you obtain by default when you create a new Android project.
After upgrading android studio, I always clean it by manually removing the build/ and app/build/ folders, and by building the project again.
Also: File -> Invalidate Caches / Restart -> Invalidate and Restart

Android Test Module (Gradle Plugin 1.3) doesn't work: "debug-classes not found"

I'm attempting to set up a unit test module as described in the android studio blog post. However, doing a gradle build fails telling me "Configuration with name 'debug-classes' not found". Debug is the name of the targetVariant it's trying to build, but I don't understand what is going wrong here.
Here's my test module's gradle file.
apply plugin: 'com.android.test'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
targetProjectPath ':app'
targetVariant 'debug'
}
This is the blogpost describing the new test module functionality.
http://android-developers.blogspot.com/2015/07/get-your-hands-on-android-studio-13.html
I'm using the Gradle plugin v1.3.0
I was also curious about separating app code and test code and i had hard time to figure it out. I look at the stack trace and found the DependencyManager (line 238) having a TODO to fix that in gradle.
1) You are right about the build flavors.You have to enter the correct variant
targetVariant '<flavor>Debug'
e.g.
targetVariant 'flavor1Debug'
2) You also need to change you targetProjectPath's module build.gradle. Add the following snippet:
android {
// ...
publishNonDefault true
// ...
}
which publishes all build variants! It its disabled by default due to some limitations of gradle.
Here is a sample app that works https://github.com/googlesamples/android-testing-templates/tree/master/AndroidTestingBlueprint
You must use
buildToolsVersion = '23.0.0rc3'
And of course
publishNonDefault true

Android Studio 1.3 test module (com.android.test) [duplicate]

I'm attempting to set up a unit test module as described in the android studio blog post. However, doing a gradle build fails telling me "Configuration with name 'debug-classes' not found". Debug is the name of the targetVariant it's trying to build, but I don't understand what is going wrong here.
Here's my test module's gradle file.
apply plugin: 'com.android.test'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
targetProjectPath ':app'
targetVariant 'debug'
}
This is the blogpost describing the new test module functionality.
http://android-developers.blogspot.com/2015/07/get-your-hands-on-android-studio-13.html
I'm using the Gradle plugin v1.3.0
I was also curious about separating app code and test code and i had hard time to figure it out. I look at the stack trace and found the DependencyManager (line 238) having a TODO to fix that in gradle.
1) You are right about the build flavors.You have to enter the correct variant
targetVariant '<flavor>Debug'
e.g.
targetVariant 'flavor1Debug'
2) You also need to change you targetProjectPath's module build.gradle. Add the following snippet:
android {
// ...
publishNonDefault true
// ...
}
which publishes all build variants! It its disabled by default due to some limitations of gradle.
Here is a sample app that works https://github.com/googlesamples/android-testing-templates/tree/master/AndroidTestingBlueprint
You must use
buildToolsVersion = '23.0.0rc3'
And of course
publishNonDefault true

Android Studio: Failed to find: 'com.android.support:support-v4:19.1.0'

I want to build an app in Android Studio with the support library but I get the following error when adding the dependency for the support library:
Error:Failed to find: com.android.support:support-v4:19.1.0
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '20'
defaultConfig {
applicationId "sample.myapplication"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:19.1.0'
}
I have downloaded the support library via the sdk manager.
Ok, found the problem. The Android support repository was missing. After installing and restarting Android Studio it worked.
If you are using Android Studio, then as an addition to changing the build.gradle file manually, you can also lookup the dependency via the library dependencies under the Project Structure menu item.
Double clicking that dependency will generate this line in build.gradle:
dependencies {
compile 'com.android.support:support-v13:+'
}
And also, if you are wondering what this library is about, it's described at the developer pages at developer.android.com; Support Library.
My Android Studio version is 1.1. I select tools->Android->SDK Manager, check the Android Support Library then click Install packages, solved this issue.
In my case the solution was as simple as running Build:Make Project. No amount of gradle syncing or clearing caches would do it. Of course, that required getting my project into a state where it would build successfully.
In my case I needed to add Google Maven repository.
It shows as part of the error in Android Studio and only needed to click on it to add itself.
Then Gradle built the project on its own.
Following the instruction here helped me. For whatever reason when I had to reinstall the latest version of android studio the initial download of the extras section android support library failed. I simply retried it. Followed the steps mentioned and verified it was added to the build.gradle file and did a rebuild project and good to go.
http://developer.android.com/tools/support-library/setup.html

Categories

Resources