gpt4 book ai didi

java - 为不同的架构生成 APK - FFmpegMediaMetadataRetriever

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:42:48 24 4
gpt4 key购买 nike

我正忙于将 FFmpegMediaMetadataRetriever 预构建 .aar 文件添加到我的项目中,以减少每个架构的 Apk 文件大小。

This post将以下内容添加到他的 Gradle 中:

android {
splits {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable true

// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86, armeabi-v7a, and mips.
reset()

// Specifies a list of ABIs that Gradle should create APKs for.
include "x86", "x86_64", "armeabi-v7a", "arm64-v8a"

// Specifies that we want to also generate a universal APK that includes all ABIs.
universalApk false
}
}
//...
}

FFmpegMediaMetadataRetriever 库提供以下.aar 文件:

image


我的问题:

  • 我应该将 .aar 文件原封不动地放在我的 libs 文件夹中(无需为每个架构创建文件夹),还是应该将它添加到一个文件夹中?
  • 我应该使用以上哪些 .aar 文件来支持所有架构?
  • 在帖子中他还谈到了版本控制,这是否有必要(我的应用程序是实时的,我不想搞乱版本控制 - 我当前的版本是 21)?

他是这样实现版本控制的:

// Map for the version code that gives each ABI a value.
def abiCodes = ['x86':1, 'x86_64':2, 'armeabi-v7a':3, 'arm64-v8a':4]

// APKs for the same app that all have the same version information.
android.applicationVariants.all { variant ->
// Assigns a different version code for each output APK.
variant.outputs.each {
output ->
def abiName = output.getFilter(OutputFile.ABI)
output.versionCodeOverride = abiCodes.get(abiName, 0) * 100000 + variant.versionCode
}
}

我正在寻找可能使用过 FFmpegMediaMetadataRetriever.aar 文件的人,他们可以指导我如何正确实现它。

编辑1

学习后more关于不同的架构/ABI,我认为可以肯定地说,如果我只包含 armeabi-v7a 那么大多数设备都会被“覆盖”? (我的最小 sdk 是 16)。

这是否意味着我不必拆分 APK,也不必担心版本控制?

然后我可以像往常一样导入 .aar - armv7-fmmr.aar 吗?

最佳答案

您可以使用指定所需目标 ABI 的产品风格生成不同的 APK。然后,您可以根据每种产品风格指定要使用的 FMMR gradle 依赖项或独立 AAR 文件。请参阅此 build.gradle 文件以供引用:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.wseemann.example"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

flavorDimensions "version"
productFlavors {
fat {
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips", "x86_64", "arm64-v8a"
}
}

armeabi {
ndk {
abiFilter "armeabi"
}
}

armeabi_v7a {
ndk {
abiFilter "armeabi-v7a"
}
}

x86 {
ndk {
abiFilter "x86"
}
}

mips {
ndk {
abiFilter "mips"
}
}

x86_64 {
ndk {
abiFilter "x86_64"
}
}

arm64_v8a {
ndk {
abiFilter "arm64-v8a"
}
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

// Product flavor, ABI specific dependencies
fatImplementation 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'
armeabiImplementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-armeabi:1.0.14'
armeabi_v7aImplementation'com.github.wseemann:FFmpegMediaMetadataRetriever-armeabi-v7a:1.0.14'
x86Implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-x86:1.0.14'
mipsImplementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-mips:1.0.14'
x86_64Implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-x86_64:1.0.14'
arm64_v8aImplementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-arm64-v8a:1.0.14'
}

关于java - 为不同的架构生成 APK - FFmpegMediaMetadataRetriever,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52253127/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com