APK NOT INSTALLED IN OREO - android

when i try to install from adb it gives me this error
Installation failed with message INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113
this will happen only in oreo OS.
i also add this in Build.gradle
splits {
abi {
enable true
reset()
include 'x86', 'armeabi-v7a'
universalApk true
}
}
but this is not work.

Try to find out which ABIS you were missing from your project.
And then include them as
include 'arm', 'arm-v7a', 'arm64', 'mips', 'x86', 'x86_64', 'armeabi-v7a'
Secondly, check if you really require universalApk, you can either use minsdkversion and targetsdkversion which will cover your whole range.

Related

Could not get unknown property 'arm64-v8a' for object of type com.android.build.gradle.internal.dsl.NdkOptions

I'm following the guide on Android ABIS doc and it said to use 'arm64-v8a' to meet with Play Store 64 bit requirements.
I added my so files under libs/arm64-v8a/ And then I added abiFilter as follows:
defaultConfig {
...
ndk {
abiFilters 'armeabi' 'arm64-v8a'
}
...
}
When I build the project, I keep getting error
Could not get unknown property 'arm64-v8a' for object of type com.android.build.gradle.internal.dsl.NdkOptions.
I'm using Android Studio 3.6 rc-03, Gradle version 5.6.4, with ndk version of 21.0.6113669.
Nevermind, I forgot to add "," between 'armeabi' and 'arm64-v8a'
This is working now
ndk {
abiFilters 'armeabi', 'arm64-v8a'
}

Building all ABIs but packaging only a subset

I am attempting to build all ABIs for my project but would only like to package a subset of them into my app. For example, I would like to build "x86", "x86_64", "armeabi-v7a" and "arm64-v8a" but only package "x86" (for example).
Reading this document (https://developer.android.com/studio/projects/gradle-external-native-builds.html#jniLibs) under section "Specify ABIs", it seems very possible using the snippet they provided as an example. However, this does not seem to be working for me.
My code snippet is as follows.
android {
defaultConfig {
ndk {
abiFilters 'armeabi-v7a'
}
externalNativeBuild {
cmake {
abiFilters 'armeabi-v7a', 'x86'
}
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
In the snippet above, from my understanding of the document, it should build both armeabi-v7a and x86, but only package armeabi-v7a in my APK. This is not working though.
I am using Android plugin 3.1.0 and NDK 16.1.4479499
what you are looking for, is controlled by splits.
splits {
abi {
enable true
reset()
include 'armeabi-v7a'
universalApk false //don't generate an additional APK that contains all the ABIs
}
}

Remove x86_64 package from Realm

I'm working with AS and I don't need the x86_64 package in realm. The x86_64 package cause some problems with other libs. How to remove the package?
abiFilters will be a good solution. The method will limit the abi and only add the specified abi when building the apk.
defaultConfig {
applicationId "com.example.app"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86"
}
// ...
}
This means only those specified arch-folders will be used and the rest can be deleted.
Well, you can remove any of the architecture folders, but keep in mind, that means the library in question (this case it's realm) will not work on those architectures that you remove.
To be frank, you can just simply remove it, but as I mentioned above, that is no good.
You can include/exclude different architectures from your build by a technique called splitting:
android {
// Rest of Gradle file
splits {
abi {
enable true
reset()
include 'armeabi', 'armeabi-v7a', 'arm64_v8a', 'mips', 'x86'
universalApk true
}
}
}
//Ensures architecture specific APKs have a higher version code
//(otherwise an x86 build would end up using the arm build, which x86 devices can run)
ext.versionCodes = [armeabi:1, 'armeabi-v7a':2, 'arm64-v8a':3, 'mips':4, x86:5]
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
int abiVersionCode = project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) ?: 0
output.versionCodeOverride = (abiVersionCode * 10000) + android.defaultConfig.versionCode
}
}

How to test if we are doing a release build in Gradle

I need to do some build operations only during release build to speed up the routine debug build. How to test, if I'm doing a release build in the build.gradle script?
splits {
abi {
enable /* CONDITION HERE -> */ true
reset()
include 'x86', 'armeabi-v7a', 'mips'
universalApk true
}
}
I found an example here, but I don't want to set build property, I prefer it to be automatic.
Please try:
splits {
abi {
if (project.gradle.startParameter.taskNames.any { it.toLowerCase().contains('release') }) {
enable true
reset()
include 'x86', 'armeabi-v7a', 'mips'
universalApk true
} else {
enable true
reset()
include 'armeabi-v7a'
universalApk false
}
}
}
However, mind the fact that this configuration doesn't take task dependencies into account.
What I mean is a task may depend on some release task and even if it isn't passed via command line it might be executed.

Android Gradle - is use splits only for release possible?

I want use "splits" by "abi", but only for release build. Is this possible? I try use ext variable and variable by "def" also which is set to false by default. This variable is set to true in buildTypes for releaseWithLog (and release).
But I don't know how Gradle work, because when I add writeln() with test message to "debug", "releaseWithLog" and "release" and run build, all messages are in output, so this confirms me that variable "splitsEnabled" is set to true though I build for debug - and I expect value "false" for debug (and not using splits for debug therefore).
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
ext {
splitsEnabled = false
}
defaultConfig {
...
}
buildTypes {
debug {
...
}
releaseWithLog {
...
splitsEnabled = true
}
release.initWith(releaseWithLog)
release {
...
}
}
...
splits {
abi {
println(splitsEnabled)
enable splitsEnabled
reset()
include 'x86', 'armeabi-v7a', 'armeabi'
exclude 'x86_64', 'mips64', 'arm64-v8a', 'mips'
universalApk true
}
}
...
You can solve this easily with a command line argument to Gradle, or the "Script parameters:" field for a Gradle task in Android Studio. I used -P to define 'dbgBld' symbol and used it for debug builds, e.g.:
gradle -PdbgBld installDebug
My build.gradle file has the following splits command:
splits {
abi {
enable !project.hasProperty('dbgBld')
reset()
include 'armeabi', 'armeabi-v7a', 'x86', 'mips'
universalApk true
}
}
Now to build release I use:
gradle assembleRelease
The 'dbgBld' symbol is not defined, so the splits enable field resolves to true and I get 5 APK files. When building for debugging, the -PdbgBld is already saved in my Android Studio configuration and I get only one "fat" APK for debugging, which results in much faster debug builds.
Greg

Categories

Resources