您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
AndroidStudio如何使用(導入).aar包(第三方依賴如何本地化)
发布时间:2021-06-20 16:58:35编辑:雪饮阅读()
在使用第三方開源項目https://github.com/tanersener/ffmpeg-kit/tree/main/android時候
//artifacts.add("default", file('ffmpeg-kit-full-4.4.LTS.aar'))
artifacts.add("default", file('ffmpeg-kit.aar'))
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'
}
這裏可以看到我有注釋:
packagingOptions這裏雖然能解決,但是這個doc包中有好多文件,我處理一個,則又有下一個,再處理一個又有下一個報錯,因爲上面兩個目錄中都包含了這doc包,我感覺只要刪除一個目錄中的即可,當時並不知道是doc包中的,只是感覺這不對勁,這明明是web端的文件,然後這些問題又好像都是出現在我添加jar前後大概才出現的問題,所以就從這幾個目錄中的文件以及自己的直覺等才發現出現的幾個問題中提及的文件正好是這doc包中的。 可以看到這裏就是這兩個最核心:
這裏面會發現大意應該不僅僅是jar,應該還有aar,爲了嚴謹考量我覺得這裏aar的我們應該手動給它去除比較好。不過這裏我偷個懶,就沒有處理。
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'
}
implementation fileTree(dir: 'D:\\AndroidStudioProjects\\penguinvideoedit\\com.arthenica\\smart-exception-common\\0.1.0', include: ['*.aar', '*.jar'], exclude: [])
关键字词:AndroidStudio,aar,第三方依賴,本地化
上一篇:linux下安卓環境(安卓sdk)安裝配置(ubuntu-18.04.5-desktop-amd64)
下一篇:ubuntu-18.04.5-desktop-amd64與ndk(r21e)交叉編譯ffmpeg4.3.2(包含libx264)