Android Studio NDK Development configuration

Source: Internet
Author: User
Tags jcenter

One: Use Gradle experimental plugin

First of all, we can not use the Android studio default Gradle plugin, we need to change the Android Studio plugin Gradle Experimental plugin, this plugin is developed by Google, the URL here:

Http://tools.android.com/tech-docs/new-build-system/gradle-experimental


Gradle Experimental plugin is a new compiled plugin for Android studio that improves the compiler performance of the program. In addition, it supports the NDK, which compiles JNI applications. Currently (May 2016) The latest version is 0.7.0

II: Software Preparation:
    • Gradle 2.10
    • Android NDK r10e
    • Android SDK Build Tools version 23.0.3
Three: Changes in the directory structure

The following red is required to modify the configuration, there are three main:

├──app/

│├──app.iml

│├── build.gradle----------> Module compilation configuration File

│└──src/

├── build.gradle ----------> Engineering Compilation configuration file

├──gradle/

│└──wrapper/

│├──gradle-wrapper.jar

│└── gradle-wrapper.properties ----------> Gradle version configuration file

├──gradle.properties

├──gradlew*

├──gradlew.bat

├──local.properties

├──myapplication.iml

└──settings.gradle


./gradle/wrapper/gradle-wrapper.properties :

#Wed Apr 15:27:10 PDT
Distributionbase=gradle_user_home
distributionpath=wrapper/dists
Zipstorebase=gradle_user_home
zipstorepath=wrapper/dists
distributionurl=https\://services.gradle.org/distributions/gradle-2.10-all.zip


./build.gradle :


    repositories {
        jcenter ()
Span style= "font-family: ' Courier New '; letter-spacing:0;font-size:14px;" >   }
   dependencies  {

    //classpath ' com.android.tools.build:gradle:2.1.0 '
Classpath"Com.android.tools.build:gradle-experimental:0.7.0"
   }
}

allprojects {
Repositories {
Jcenter ()
   }
}

./app/build.gradle

Apply plugin: "Com.androi d. Model . A pplication "

Model {

Android {

Compilesdkversion 23

Buildtoolsversion "23.0.3"

NDK {

ModuleName "Hellojni"

Ldlibs.add ("log")//native code with Android Logcat log

}

Defaultconfig {

ApplicationID "Cn.itcast.testjni"

Minsdkversion.apilevel 19

Targetsdkversion.apilevel 22

Versioncode 1

Versionname "1.0"

}

}

}

dependencies {

Compile Filetree (dir: "Libs", include: ["*.jar"])

}


Reference Links:

Https://codelabs.developers.google.com/codelabs/android-studio-jni/index.html

Android Studio NDK Development configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.