I have in build.gradle Android splits:
splits {
abi {
enable true
reset()
include 'x86', 'mips', 'armeabi-v7a', 'armeabi'
universalApk false
}
}
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
output.versionCodeOverride =
versionCodes.get(output.getFilter(OutputFile.ABI), 0) * 1000000 + android.defaultConfig.versionCode
}
}
After update of Robolectric to 3.0 I become path error:
build/intermediates/manifests/full/debug/AndroidManifest.xml not found or not a file; it should point to your project's AndroidManifest.xml
because I in build/intermediates/manifests/full/ have 4 splits folders
armeabi/ armeabi-v7a/ mips/ x86/
How can i set in Robolectric config or in gradle configuration, that I have splits?
Thank you
UPDATE:
In all my classes I have following configuration:
#RunWith(RobolectricGradleTestRunner.class)
#Config(sdk = 21, manifest = "../application/AndroidManifest.xml", constants = BuildConfig.class)
I think the easiest way will just be to point it to your x86/AndroidManifest.xml
You can specify this using the manifest key in your #Config, e.g.
#Config(manifest="path-here")
Since you will need this for every test, you might also consider creating a properties file. For more details on this, the docs are here
Related
Getting this Warning (Even when variant.getAssemble() is not used anywhere):
API 'variant.getAssemble()' is obsolete and has been replaced with 'variant.getAssembleProvider()'.
I have updated following components:
Android Studio
v3.3
Gradle PlugIn
v3.3
Gradle Distribution URL (gradle-wrapper.properties)
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
gradle.properties
android.debug.obsoleteApi=true
variant.assemble has been deprecated and replaced by a new provider API.
If for example you are using it as next:
variant.outputs.all { output ->
variant.assemble.doLast {
....
}
}
}
Then replace it the new provider API:
variant.outputs.all { output ->
variant.getAssembleProvider().configure() {
it.doLast {
....
}
}
}
It's a warning, it doesn't negatively impact your build. You may go forward and update to AGP 3.3.0.
The new Android Gradle Plugin started leveraging lazy configuration (Task Configuration Avoidance API and Provider API) which, if used properly, may improve build speeds by only evaluating tasks and properties which are needed. Consumers of AGP need to use the updated API (e.g. getAssembleProvider().configure() instead of getAssemble()) otherwise the tasks and properties are always evaluated.
The point of lazy API: Don't configure tasks which aren't going to run in a particular build.
Read more:
https://docs.gradle.org/4.10/userguide/lazy_configuration.html
https://docs.gradle.org/4.10/userguide/task_configuration_avoidance.html
What to do
If it's not coming from your code there's nothing for you to do other than wait for updated libraries (and pray they do it right).
If it comes from your code, here's an example of migration: I'm using this bit of code from Jake Wharton to disable BuildConfig.java generation for my library modules.
libraryVariants.all {
it.generateBuildConfig.enabled = false
}
Using the new lazy API it looks like this.
libraryVariants.all {
it.generateBuildConfigProvider.configure {
it.enabled = false
}
}
The eager API would cause the generateBuildConfig task to be configured even if I didn't need it, such as running clean. The lazy API configures the task only if it's part of the task graph to run. This saves time during the configuration phase.
How to figure out if it comes from your code? Put this in your gradle.properties
android.debug.obsoleteApi=true
Now run a build and check the output for stack traces.
Full error
For completeness, here's an example of a full error message caused by the Fabric plugin 1.27.0 with AGP 3.3.0:
WARNING: API 'variant.getExternalNativeBuildTasks()' is obsolete and has been replaced with 'variant.getExternalNativeBuildProviders()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getExternalNativeBuildTasks(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Bad example
Here's a diff of how Facebook React dealt with the API migration in their plugin: https://github.com/facebook/react-native/pull/23103/files
In other words, they didn't. taskProvider.get() is equal to task - both uses are eager. The tasks are always configured.
The only thing this approach achieves is removing the warning so
the consumer has no idea they're not getting any benefits of the lazy API,
the plugin author is no longer reminded they're using it wrong.
The Task Configuration Avoidance API docs contain a migration guide and a helpful table describing how to create and chain tasks lazily. If you're a plugin author, please read it.
I had the same Warning!!
And this is my app level gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId 'com.lauszus.facerecognitionapp'
minSdkVersion 16
targetSdkVersion 28
versionCode 6
versionName '1.2.3'
vectorDrawables.useSupportLibrary = true
ndk {
stl 'c++_static'
cFlags '-std=gnu++11 -fexceptions -frtti -DANDROID_STL=c++_static'
}
setProperty('archivesBaseName', rootProject.name + '-' + defaultConfig.versionName)
}
splits {
abi {
enable true
reset()
universalApk true
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
}
project.ext.abiCodes = ['armeabi-v7a':1, 'arm64-v8a':2, 'x86':3, 'x86_64':4]
applicationVariants.all { variant ->
variant.outputs.each { output ->
def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(com.android.build.OutputFile.ABI))
// Because abiCodes.get() returns null for ABIs that are not mapped by ext.abiCodes,
// the following code does not override the version code for universal APKs.
if (baseAbiVersionCode != null) {
output.versionCodeOverride = baseAbiVersionCode * 1000000 + variant.versionCode
}
}
if (variant.getBuildType().isMinifyEnabled()) {
variant.assemble.doLast {
variant.mappingFile.renameTo(variant.mappingFile.parent +
"/$archivesBaseName-$variant.baseName-mapping.txt")
}
}
}
signingConfigs {
release
}
buildTypes {
debug {
jniDebuggable true
externalNativeBuild {
ndkBuild {
arguments 'NDK_DEBUG=1', 'NDEBUG=null'
}
}
}
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
externalNativeBuild {
ndkBuild {
path 'src/main/cpp/Android.mk'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation project(':opencv')
}
// These values are all set in my global gradle.properties file
if (project.hasProperty('storeFile') && project.hasProperty('storePassword') &&
project.hasProperty('keyAlias') && project.hasProperty('keyPassword')) {
android.signingConfigs.release.storeFile = file(storeFile)
android.signingConfigs.release.storePassword = storePassword
android.signingConfigs.release.keyAlias = keyAlias
android.signingConfigs.release.keyPassword = keyPassword
} else {
android.buildTypes.release.signingConfig = null
}
If your app level gradle file contains variant.assemble.doLast block then; Try changing “variant.assemble.doLast” to “variant.assembleProvider.get().doLast”
like this:
if (variant.getBuildType().isMinifyEnabled()) {
variant.assembleProvider.get().doLast { //HERE
variant.mappingFile.renameTo(variant.mappingFile.parent +
"/$archivesBaseName-$variant.baseName-mapping.txt")
}
}
referred web link.
This type of warning can appear if some library used is your project is using this method
Check your app level gradle. or applied gradle in it. made changes like below
Original :
android.applicationVariants.all { variant ->
variant.assemble.doLast {
After Fix :
android.applicationVariants.all { variant ->
variant.assembleProvider.get().doLast {
Temporary solution!
- Edit your root "build.gradle" file.
- Change "com.android.tools.build:gradle:3.3.0" to "3.2.0"
Done.
same problem:
https://stackoverflow.com/a/52470224/8920453
and see this:
https://stackoverflow.com/a/54239512/8920453
I was trying to split the apk based on architecture. It was working on another app. But not this one. This error gets happen each time trying to build the gradle.
Any ideas to solve this. I've tried some casting. but nothing happens.
Here's the full split code
splits {
abi {
enable true //enables the ABIs split mechanism
reset() //reset the list of ABIs to be included to an empty string
include 'arm64-v8a', 'armeabi-v7a', 'x86'
universalApk true
}
}
// map for the version code
project.ext.versionCodes = ['armeabi':1, 'armeabi-v7a':2, 'arm64-v8a':3, 'mips':5, 'mips64':6, 'x86':8, 'x86_64':9]
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
output.versionCodeOverride = project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1000000 + android.defaultConfig.versionCode
}
}
I had this issue last time after upgrade NDK version to latest version in Android Studio. I also found solution to fix this. If anyone has this issue , I hope it is the best question and answer for you. Please check my answer.
I found solution by reading on release note here for NDK revision 16.
If you config your project with Application.mk just add the following to your Application.mk file:
APP_STL := c++_shared
If you're using CMake via Gradle, add the following to your build.gradle:
externalNativeBuild {
cmake {
cppFlags ""
arguments "-DANDROID_STL=c++_shared"
}
}
To keep up to date with new release and note, please follow this NDK Revision History to apply with new changed.
I hope it can fix your issue.
According to Android documentation this is a known issue, and its due to the fact that the gradle plugin still includes unsupported ABIs by default. armbeabi was deprecated in NDKr16 and removed in r17 hence the warning. To fix, list your supported architectures under splits.abi:
...
splits {
abi {
...
reset()
include "x86", "armeabi-v7a", ...
}
}
Got same issue and fixed through modifying the module build.gradle file by adding below setup:
android {
...
splits {
abi {
enable true
reset()
include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' //select ABIs to build APKs for
universalApk true //generate an additional APK that contains all the ABIs
}
}
project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
output.versionCodeOverride =
project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1000000 + android.defaultConfig.versionCode
}
}
}
For your reference, good luck.
This doesn't resolve my problem, i resolved by adding this:
ndk {
abiFilters "armeabi-v7a"
}
to android.defaultConfig
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
}
}
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