Use AndroidStudio 2.0 develop NDK project.

Datetime:2016-08-22 23:18:45          Topic: Android Studio           Share

Creat an android project at first, then follow these steps:

build.gradle (NDKDemo)

Replace classpath 'com.android.tools.build:gradle:2.0.0'
with classpath 'com.android.tools.build:gradle-experimental:0.7.2'

build.gradle (app, top level)

Replace section:

apply plugin: 'com.android.application'

android {
   compileSdkVersion 23
   buildToolsVersion "23.0.1"

   defaultConfig {
       applicationId "com.google.sample.helloandroidjni"
       minSdkVersion 22
       targetSdkVersion 23
       versionCode 1
       versionName "1.0"
   }
   buildTypes {
       release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
   }
}

with

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

model {
   android {
       compileSdkVersion 23
       buildToolsVersion "23.0.3"

       defaultConfig {
           applicationId "com.google.sample.helloandroidjni"
           minSdkVersion.apiLevel 22
           targetSdkVersion.apiLevel 23
           versionCode 1
           versionName "1.0"
       }
       buildTypes {
           release {
               minifyEnabled false
               proguardFiles.add(file('proguard-android.txt'))
           }
       }
   }
}

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

Error:(10, 18) error: base operand of ‘->’ has non-pointer type ‘JNIEnv {aka _JNIEnv}’

Key points:

minSdkVersion.apiLevel 10 and targetSdkVersion.apiLevel 23 append apiLevel property.

replace proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
with proguardFiles.add(file('proguard-android.txt'))





About List