您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
androidStudio4.1.2關於ndk配置自定義目錄的變遷
发布时间:2021-06-20 21:39:02编辑:雪饮阅读()
首先在於安卓中配置ndk以前是這樣的,在于app/build.gradle:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.penguinvideoedit"
minSdkVersion 25
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
packagingOptions {//加上这写代码
//pickFirst 'jquery/jszip-utils/dist/jszip-utils.js'
//pickFirst 'jquery/jquery-ui.js'
//pickFirst 'package-search-index.js'
//pickFirst 'jquery/jquery-ui.structure.min.css'
//pickFirst 'index.html'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
/*
sourceSets {
main {
jniLibs.srcDirs = ["libs"]
}
}
*/
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
//ndkVersion '21.4.7075529'
//android.ndkPath 'D\\:\\\\ndk\\\\android-ndk-r21e'
ndkPath "D:\\ndk\\android-ndk-r21e"
/*
android {
ndkPath "/Users/ndkPath/ndk21" // pointing to your own NDK
}
*/
}
dependencies {
//implementation(name:'ffmpeg-kit-full-4.4.LTS', ext:'aar')
//implementation 'com.arthenica:ffmpeg-kit-full:4.4.LTS'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation project(path: ':ffmpeg-kit-full-4.4.LTS')
implementation fileTree(dir: 'D:\\AndroidStudioProjects\\penguinvideoedit\\com.arthenica\\smart-exception-java\\0.1.0', include: ['*.aar', '*.jar'], exclude: [])
implementation fileTree(dir: 'D:\\AndroidStudioProjects\\penguinvideoedit\\com.arthenica\\smart-exception-common\\0.1.0', include: ['*.aar', '*.jar'], exclude: [])
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.bumptech.glide:glide:4.0.0'
}
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.penguinvideoedit"
minSdkVersion 25
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
packagingOptions {//加上这写代码
//pickFirst 'jquery/jszip-utils/dist/jszip-utils.js'
//pickFirst 'jquery/jquery-ui.js'
//pickFirst 'package-search-index.js'
//pickFirst 'jquery/jquery-ui.structure.min.css'
//pickFirst 'index.html'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
/*
sourceSets {
main {
jniLibs.srcDirs = ["libs"]
}
}
*/
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
//ndkVersion '21.4.7075529'
//android.ndkPath 'D\\:\\\\ndk\\\\android-ndk-r21e'
ndkPath "D:\\ndk\\android-ndk-r21e"
/*
android {
ndkPath "/Users/ndkPath/ndk21" // pointing to your own NDK
}
*/
}
dependencies {
//implementation(name:'ffmpeg-kit-full-4.4.LTS', ext:'aar')
//implementation 'com.arthenica:ffmpeg-kit-full:4.4.LTS'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation project(path: ':ffmpeg-kit-full-4.4.LTS')
implementation fileTree(dir: 'D:\\AndroidStudioProjects\\penguinvideoedit\\com.arthenica\\smart-exception-java\\0.1.0', include: ['*.aar', '*.jar'], exclude: [])
implementation fileTree(dir: 'D:\\AndroidStudioProjects\\penguinvideoedit\\com.arthenica\\smart-exception-common\\0.1.0', include: ['*.aar', '*.jar'], exclude: [])
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.bumptech.glide:glide:4.0.0'
}
這裏的關鍵就是ndkVersion '21.4.7075529'
然後在local.properties中配置ndk路徑:
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Fri Apr 02 20:59:44 CST 2021
#ndk.dir=D\:\\ndk\\android-ndk-r21e
sdk.dir=C\:\\Program Files (x86)\\Android\\android-sdk
實則對於ndk.dir其實是對於自定義路徑來實現的,若不是自己另外單獨下載ndk,進行加載,則可以不必用,當然這個是我個人的見解了,沒有實操過。
至於版本號呢,其實你下載ndk包的時候就可以看到了
當然,也有其它方式也能獲取,自己發散思維靠直覺唄。
對於ndk的路徑,那麽圖形化的也可以在這裏進行配置
不過ndk.dir這種自定義配置單獨ndk路徑的方式于local.properties已經被官方認爲不推薦的方式了。
對於新的自定義ndk目錄的配置,官方將其和版本號的配置整合在了一起都位於app/build.gradle中,這樣也更方便了,個人覺得。那麽具體配置如app/build.gradle:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.penguinvideoedit"
minSdkVersion 25
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
packagingOptions {//加上这写代码
//pickFirst 'jquery/jszip-utils/dist/jszip-utils.js'
//pickFirst 'jquery/jquery-ui.js'
//pickFirst 'package-search-index.js'
//pickFirst 'jquery/jquery-ui.structure.min.css'
//pickFirst 'index.html'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
/*
sourceSets {
main {
jniLibs.srcDirs = ["libs"]
}
}
*/
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
//ndkVersion '21.4.7075529'
//android.ndkPath 'D\\:\\\\ndk\\\\android-ndk-r21e'
ndkPath "D:\\ndk\\android-ndk-r21e"
/*
android {
ndkPath "/Users/ndkPath/ndk21" // pointing to your own NDK
}
*/
}
dependencies {
//implementation(name:'ffmpeg-kit-full-4.4.LTS', ext:'aar')
//implementation 'com.arthenica:ffmpeg-kit-full:4.4.LTS'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation project(path: ':ffmpeg-kit-full-4.4.LTS')
implementation fileTree(dir: 'D:\\AndroidStudioProjects\\penguinvideoedit\\com.arthenica\\smart-exception-java\\0.1.0', include: ['*.aar', '*.jar'], exclude: [])
implementation fileTree(dir: 'D:\\AndroidStudioProjects\\penguinvideoedit\\com.arthenica\\smart-exception-common\\0.1.0', include: ['*.aar', '*.jar'], exclude: [])
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.bumptech.glide:glide:4.0.0'
}
沒錯就是這個android節點中的ndkPath "D:\\ndk\\android-ndk-r21e"
可以發現這裏如果有盤符則盤符後面不用加反斜杠了,反觀之前在local.properties中配置:
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Fri Apr 02 20:59:44 CST 2021
#ndk.dir=D\:\\ndk\\android-ndk-r21e
sdk.dir=C\:\\Program Files (x86)\\Android\\android-sdk
其實就只是盤符後面是否加反斜杠而已。
关键字词:androidStudio4.1.2,androidStudio,ndk,ndk目錄