Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android NDK in Android studio >=1.4

I do not consider this question to be a duplicate of this and this questions since they are mainly answered by this link and that is not adaptable for later versions of AS.

I can find good information on how to integrate Android NDK with Eclipse, but that Eclipse and ADT is now considered deprecated by Google.

When following the instructions to setup a project for the experimental gradle plugin I get numerous errors in the editor of type cannot Resolve symbol for all the new additions as well as the error posted below after the build.

The build.gradle in project.

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And the build.gradle in app

apply plugin: 'com.android.model.application'

model{
    android {
         compileSdkVersion = 22
        buildToolsVersion = "23.0.1"

         defaultConfig.with {
             applicationId = "se.einarsundgren.gstreamandroiddemo"
             minSdkVersion.apiLevel = 22
            targetSdkVersion.apiLevel = 22
            versionCode = 1
            versionName = "1.0"

             buildConfigFields.with {
                 create() {
                     type = "int"
                     name = "VALUE"
                     value = "1"
                }
            }
        }

         android.buildTypes {
             release {
                 minifyEnabled = false
                 proguardFiles += file('proguard-rules.pro')
            }
        }

         android.productFlavors {
             create("flavor1") {
                 applicationId = 'com.app'
            }
        }

         android.sources{
             main {
                 java {

                   source {
                         srcDir 'src'
                      }
                  }
            }
        }

        android.ndk {
            moduleName = "native"
        }
 }
}

dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.2.0'
}

The error I get when cleaning and rebuilding the project:

Error:A problem occurred configuring root project 'GstreamAndroidDemo'.

Could not resolve all dependencies for configuration ':classpath'. Could not resolve com.android.tools.build:gradle-experimental:0.2.0. Required by: :GstreamAndroidDemo:unspecified Could not resolve com.android.tools.build:gradle-experimental:0.2.0. Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle-experimental/0.2.0/gradle-experimental-0.2.0.pom'. Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle-experimental/0.2.0/gradle-experimental-0.2.0.pom'. peer not authenticated

How do I integrate the NDK with a project in Android Studio? The previously linked questions have answers valid for an earlier version (pre 1.3) and the instructions are not adaptable for AS 1.4

like image 663
Einar Sundgren Avatar asked Oct 30 '15 22:10

Einar Sundgren


People also ask

What is the use of NDK in Android Studio?

The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android, and provides platform libraries you can use to manage native activities and access physical device components, such as sensors and touch input.

How do I know what version of NDK I have?

Go to Tools->SDK Manager (or Files->Settings->Appearance & Behavior->System Settings->Android SDK ). Then select the SDK Tools tab, and check the Show Package Details checkbox. You will see your NDK version.


2 Answers

Yes it is. The setting is there on Android Studio 1.5 preview 2 in Windows 10 as well.

NDK Location

like image 32
phxhawke Avatar answered Oct 23 '22 03:10

phxhawke


that this setting where you can point to the location of the NDK is not included in the later versions.

Yes, it is, at least on Android Studio 1.4.1 on Linux:

Project Structure Dialog, SDK Location Category

How do I integrate the NDK with a project in Android Studio?

As far as I am aware, you follow the instructions.


UPDATE: With regard to your gradle-experimental problems, 0.2.0 and newer versions certainly show up in jcenter when you view their Web site. Make sure that you have followed the rest of the instructions, such as using Gradle 2.5.

like image 116
CommonsWare Avatar answered Oct 23 '22 04:10

CommonsWare