Meaning of "android.enableAapt2 will be removed at the end of 2018"? - android

Gradle version: 4.4
Android Plugin Version: 3.1.2
Hi.
I'm working on an Android which should be deploy by using a Mobile Device Management called AirWatch.
So since Android Gradle Plugin 3.0.0, even if I update application version code and version name, the MDM thinks that the last deployed version and the current one are the same.
Using dump badging command, I see that the platformBuildVersionName is empty. So when I disable aapt2 from my gradle properties file, platformBuildVersionName is filled. which allow me to deploy on the MDM. The problem is not up to date we don't when they will. So this is the work around I found. I know that the option 'android.enableAapt2' is deprecated and should not be used anymore.
My question is what's the meaning "It will be removed at the end of 2018"? Is that mean, at the end of 2018, my app will not compile anymore?
Thanks

The issue with platformBuildVersionName missing has been fixed recently in AAPT2.
AAPT2 it is now released it in GMaven for faster releases (so you need to have the google() dependency in your build.gradle file), so please try with android gradle plugin 3.2.0 alpha16 or newer which may already contain it. If that still doesn't work, keep an eye out for new versions, it should be released shortly (if it hasn't been yet).
As for the information about AAPT1 deprecation - it means that at some point in the near future, near the end of 2018, there will be a release of Android Gradle Plugin that removes the android.enableAapt2=false flag. AAPT1 will be completely removed then so the hacks with disabling AAPT2 won't work anymore. If you run into any other issues with AAPT2 please file them on issue tracker, so that the team can fix them before everyone will need to move away from AAPT1.

In 2019 New update
From Gradle.properties remove
android.enableAapt2=false this line
it will work now.

1.Projenin gradle.properties:
android.enableAapt2=false
2.File-> settings-Build, Execution > Instant run
unselected all options and rebuild projects

Related

How can I fix "unexpected element <queries> found in <manifest>" error?

All of a sudden, I am getting this build error in my Android project:
unexpected element <queries> found in <manifest>
How do I fix it?
The Android Gradle Plugin needs to know about new manifest elements, particularly
for the manifest merger process. The plugin has a tendency to get confused if it
sees elements in the manifest merger that it does not recognize, tossing out
build errors like the one in the question.
In this case, Android 11 introduced <queries> as a manifest element, and older versions of the Android Gradle Plugin do not know about that element.
The fact that this occurs from manifest merger means that simply upgrading a dependency
might bring about this error. For example, if you upgrade to the latest
version of com.awesome:awesome-library, and it contained a <queries> element
in its manifest, you might crash with the aforementioned error in your builds,
even without any other changes in your code.
Google released a series of patch versions of the Android Gradle Plugin to address this:
3.3.3
3.4.3
3.5.4
3.6.4
4.0.1
If you are using an existing plugin in the 3.3.* through 4.0.* series, upgrade
to the associated patch version (or higher) from that list, and you should no longer
run into that error (e.g., classpath 'com.android.tools.build:gradle:4.0.1').
If you are using Android Studio 4.1 or higher, with a matching
Android Gradle Plugin (e.g., in the 4.1.* series), you should be fine without
any changes. Those plugin versions were already aware of <queries>.
See this Android Developers Blog post for more.
I had this issue in Flutter, but I believe this solution will work for both Flutter and native Flutter development.
Follow these steps
Read this short blog post to get some understanding: Preparing your Gradle build for package visibility in Android 11
Delete the .gradle folder inside the Android folder, i.e., android > .gradle
In the project build.gradle file, upgrade your class path appropriately based on the blog in the link above, e.g., I upgraded to classpath 'com.android.tools.build:gradle:4.0.1'
Upgrade the distribution URL too. It's in android>gradle>gradle-wrapper.properties file appropriately. E.g., I upgraded it to distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
You can invalidate caches and restart your Android Studio. Make sure you have a good Internet connection, because it will download the new Gradle files.
I also suddenly had the same issue two days ago in Android Studio 4.1.1. I solved the issue by upgrading the build Gradle version.
Previous setting in the build.gradle file of the project was:
classpath("com.android.tools.build:gradle:3.5.3")
Current setting:
classpath("com.android.tools.build:gradle:3.5.4")
The issue was gone immediately. :)
Fixing the error is very simple.
Update your Android Studio to the last version
and use the last stable Gradle plugin version.
At the current time, I use Android Studio version 4.1.3 with Gradle Plugin 6.8.2
For use in queries, you should write queries code in out of application tag, not inside application tag.
For more information, see the photo below:
I had this error in the react-native-image-crop-picker library, and I solved this problem by updating the Gradle version as mentioned in previous answers.
It was:
classpath("com.android.tools.build:gradle:3.5.3")
Updated to:
classpath("com.android.tools.build:gradle:3.5.4")
And I ran a:
cd android && ./gradlew clean && cd .. && npx react-native run-android
Then it worked OK.
Due to the new default settings and features for package visibility in Android 11 that need to add <queries>, you must update your Android Gradle plugin.
Google has added some patches to current versions listed in Android Gradle plugin release notes, 4.0.0 (April 2020).
If you want to use a newer version of Android Gradle, you should search for a compatible wrapper from Android Gradle plugin release notes, Update Gradle.
Update your Gradle version to 4.0.1 or later.
File android/gradle/wrapper/gradle-wrapper.properties: update the distribution URL to:
distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip
File android/build.gradle: update the Gradle plugin:
classpath 'com.android.tools.build:gradle:4.1.2'
to 4.0.1 or later. Here it is 4.1.2 with Gradle version to 6.5 or later.
You can see the distribution chart at How to update gradle in android studio?

debug build cannot access out.jar during build because it is being use by another process

now that I'm working from home I'm trying to work for my home desktop (windows) when I try and run a debug build. I get the error.
Execution failed for task ':app:packageDebug'.
> Exception modifying resource jar file: : D:\Dev\APPFOLDER\app\build\intermediates\merged_java_res\debug\out.jar: The process cannot access the file because it is being used by another process.
I don't understand what is going on I can run the build just fine on my laptop (Mac). I've even gone as far as to completely factory reset my computer.
I've not figured out how to fix this but the issue is with com.heapanalytics.android I've disabled heap for now.
This happened with me and solved it by adding this to your build.gradle if you are initialization it in the run time.
android {
defaultConfig {
// Add this section to enable Heap event capture.
ext {
heapEnabled = true
}
// ...
}
// ...
}
Hi #Donovan I've been facing the same issue when started updating my project from windows. Same project works fine and able to build apk in mac os.
Finally figured out the cause because of your answer. Thanks and check out below solution too.
Current System OS : Windows 10
My solution :
---Nb:Only disabling heap analytics will work. But I tried below steps with heap analytics and works for me.
Updated all dependencies with latest version (only updating lib doesn't resolve the issue: but its recommended).
Update 'com.heapanalytics.android' version (**very important) in project level build.gradle. In my case I updated to version '1.7.0'
Update google play services version in project level build.gradle
Add permisiion in manifest if not previously included. It was for
firebase analytics instance.

'Failed to transform" error after migrating to AndroidX

I'm using Android Studio 3.2 Canary 14 and am trying to migrate an existing project to use AndroidX. It sounds from https://developer.android.com/topic/libraries/support-library/androidx-rn that I have to have set android.enableJetifier=true (this was done automatically for me when selecting "Refactor to AndroidX.." option). I've also updated target API level to 28. Anyone else seeing this issue?
Failed to transform
'/Users/jooreill/.gradle/caches/modules-2/files-2.1/com.google.firebase/firebase-perf/15.0.0/6e68f6e44b0c9d91756f903547ee3853349ae666/firebase-perf-15.0.0.aar' using Jetifier. Reason: null. (Run with --stacktrace for more
details.) To disable Jetifier, set android.enableJetifier=false in
your gradle.properties file.
The above error occurs when I run "Clean". In general am getting multiple errors like following if a do gradle sync:
Unable to resolve dependency for
':app-instant#debug/compileClasspath': Failed to transform file
'play-services-measurement-base-15.0.2.aar' to match attributes
{artifactType=jetified-aar} using transform JetifyTransform
For those experiencing the same issue with Android Studio 3.2 Canary 15 (or later) after using "Refactor to AndroidX...":
I had to update some dependencies manually, i.e. change
classpath 'io.fabric.tools:gradle:1.25.1'
to
classpath 'io.fabric.tools:gradle:1.27.0'
in my project's build.gradle file.
If you're using dagger you have to upgrade to version 2.20 or later.
This is because some libraries are not yet compatible with the AndroidX refactor as mentioned under Known issues in the AndroidX release notes.
I had been experiencing this problem while running assembleAndroidTest on Jenkins.
The weirdest part was that this task ran sans any issues on my mac's terminal without any issues, but failed on Jenkins with-
Failed to transform file 'cucumber-java-1.2.5.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
Had been looking for solutions for a couple of days now, having worked though different suggestions - none of which worked.
Finally, disabling Jetifier in gradle.properties resolved it for me.
android.enableJetifier=false
I was able to work around a similar problem by excluding a certain library from being jetified, which can be done by adding to gradle.properties:
android.jetifier.blacklist = ...
Note that this option was added in Android Gradle plugin 3.3.0-rc01 as a temporary workaround.
See https://issuetracker.google.com/issues/119135578#comment5 for more details.
As per a statement on the AndroidX refactor made by a Google Engineer (Support Library) during the I/O session "What's New in Support Library?", Google already discovered bugs related to Jetifier in Android Studio 3.2 Canary 14.
Thus, it is advised to wait until Canary 15 (to be released the coming week) before starting the AndroidX migration process.
I had this same error after adding JDK 11 to my machine. It set itself as default JDK and this error started happening.
After setting JDK 8 as default, it was fixed.

Crashlytics Generate Symbols task got stuck

Trying to Generate symbols for crashlytics using
./gradlew crashlyticsGenerateSymbolsDebug.
But this process get stuck, even with --debug there is no logs.
Any idea why this is happening?
Mike from Fabric here. This was a bug introduced in 1.24.3 of the Fabric Gradle plugin. It's been fixed in 1.24.4.
The same problem happened to me today when trying to build a release APK of a project I work on.
Like Alkaiser mentioned, it seems to be a problem with the Fabric tools.
Just open the following URL to see the available Fabric tool versions:
https://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml
And then go to the project level Gradle file, and change the io.fabric.tools classpath to use an earlier version - 1.24.2 should solve the problem.

gradle fails with Problems reading data from Binary store error

I have a Gradle file that runs the tests. It does not build anything. All it has is a unzip task that extracts all jars in a Gradle configuration into a particular directory and then runs the task of type Test. This test task points the testClasses directory to the location where the previous copy task has extracted the configuration into.
My build fails with the error message:
Problems reading data from Binary store
When I run 'gradle dependencies' it does not show any error/warning
When I run the copy task individually, it runs very well fine.
Only when I run everything it fails with error :
> Could not resolve all dependencies for configuration ':testConfig'.$
> Problems reading data from Binary store in /tmp/gradle8793563212642185736.bin (exist: false)$
I see the file /tmp/gradle8793563212642185736.bin does not exist. What could be the reason for this?
I solved upgrading following packages to last version (06/02/2021), so:
project app-level build.gradle file:
com.google.firebase:firebase-analytics:17.2.2
to
com.google.firebase:firebase-analytics:18.0.2
Project-level build.gradle file:
com.google.gms:google-services:4.3.3
to
com.google.gms:google-services:4.3.5
In my case setting org.gradle.parallel=false flag fixes the issue, but it's not a solution for my project, flag increase CI build time from ~15min to ~45min.
Turns out it was just a network problem for me. Gradle just needed to connect to the internet.
It happened with Flutter development in my case. Apparently, it is not an actual issue and there is no magic fix. Cleaning build file with "Flutter clean" and restarting the command line executer window solved the issue.
I was working with version 5.x earlier and then I upgraded to 6.0.1 and it resolved the issue.
this is how you can upgrade
cd android
./gradlew clean
./gradlew wrapper --gradle-version 6.0.1
./gradlew -v # to download the new version
cd ..
flutter clean
flutter run # might take 15 - 20mins for the first time
There are mainly a few steps to solve this problem.
Go to gradle.properties and set org.gradle.parallel=false and sync. Make sure your sync gradle offline option is off
Start the build with this option. If it's a big project setting org.gradle.parallel=false will take a long time.
Cancel the build repeat the steps setting org.gradle.parallel=true.
Also do not turn on offline build
This solution worked in my flutter project. I solved it by making these changes:
In android level build.gradle file, replace classpath 'com.android.tools.build:gradle:3.5.4' with classpath 'com.android.tools.build:gradle:4.0.1' (basically upgrade the version from 3.5.4 to 4.0.1)
In gradle-wrapper.properties file, replace distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip with distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip (upgrade from 5.6.2 to 6.1.1)
and if you have added classpath 'com.google.gms:google-services:4.3.3' to android level build.gradle file, replace that too with classpath 'com.google.gms:google-services:4.3.5' (upgrade from 4.3.3 to 4.3.5)
In my case the writing problem was there was no enough storage to build the app so I needed to restart my Mac and it finished building successfully.
I know am too late but it might help someone in the future so
Start by upgrading Gradle to the latest version.
Binary store issues reported to GitHub are often fixed right away, especially if they include a Minimal, Reproducible Example.
If upgrading didn't work, it can be useful to run the task again with Performance options disabled:
--no-parallel
--no-configure-on-demand
Next please find an existing issue or open a new one so it can be fixed in future versions. These things are all helpful:
Minimal, Reproducible Example
Build Scan
Smallest change that introduced the problem (e.g. worked on 5.5, but not 5.6)
I ended up here after publishing an artifact to mavenLocal().
I tried a lot but in the end what helped me was:
Upgrading gradle from 6.3 to 6.9
./gradlew wrapper --gradle-version 6.9
Hope this saves me half an hour next time this occurs.
Thanks to Cedric's hint, stopping gradle offline mode and make it online, fixed the issue for me

Categories

Resources