I just updated Android Studio to version 4.2. I was surprised to not see the Gradle tasks in my project.
In the previous version, 4.1.3, I could see the tasks as shown here:
But now I only see the dependencies in version 4.2:
I tried to clear Android Studio's cache and sync my project again, but there was no change.
Is this a feature change?
OK, I found why I got this behaviour in android studio 4.2.
It is intended behaviour. I found the answer in this post: https://issuetracker.google.com/issues/185420705.
Gradle task list is large and slow to populate in Android projects.
This feature by default is disabled for performance reasons. You can
re-enable it in: Settings | Experimental | Do not build Gradle task
list during Gradle sync.
Reload the Gradle project by clicking the "Sync Project with gradle Files" icon and the tasks will appear.
It could be cool that this experimental change is put in the release note of android studio 4.2.
Go to File -> Settings -> Experimental and uncheck Do not build Gradle task list during Gradle sync, then sync the project File -> Sync Project with Gradle Files. If the problem is still there, just reboot Android Studio.
1.
2.
Solution 1:
You can alternatively use the below gradle command to get all the tasks and run those in terminal
./gradlew tasks --all
Solution 2.
You can also create run configuration to run the tasks like below:
Step 1:
Step 2:
Step 3:
Then your run configuration will be listed like in step 1 image. You can choose and simply run it as usual.
To check the task list use the below command
./gradlew task
You will get the list of available task. To execute a particular task run command as follow
./gradlew <taskname>
Inside your android studio, select File option in toolbar -> then click on Settings option.
From settings, select the last option "Experimental"
Within there, select Uncheck the option that I have shared the screenshot below.
Then click Apply.
4. After that, Sync your project again from the file option, over their Sync project with Gradle Files
All set :)
This solution works for me
Go to File -> Settings -> Experimental and uncheck Do not build Gradle task list during Gradle sync, then sync the project File -> Sync Project with Gradle Files.
I had a similar issue and I solved it by executing the following terminal command in my Android Studio Terminal:
./gradlew tasks --all
For Android Studio Electric Eel | 2022.1.1 and later
Go to settings and uncheck this thing in below picture:
After that, sync your project again
To use firebase I need to use the The Google Services Gradle Plugin however I m not under android studio. I already downloaded from maven the google-services-3.0.0.jar but what to do with it? is their any way to make it running outside android studio ? else what exactly this plugin do ? is it possible to do it manually ?
It is possible.
Gradle is just a build tool. Android studio uses Gradle to describe, build and run your project. Gradle plugin is something you add to your build.gradle script. While it's theoretically possible to use it outside Gradle, it's not meant to be used that way.
You can still use the Gradle script in any IDE that supports Gradle, or simply run it from the command line.
The only thing you need in your Gradle project is the following line:
apply plugin: 'com.google.gms.google-services'
I currently switch to android studio 2.2 and I have a big problem. when I build project to deploy on emulator I got this error:
Error:Execution failed for task ':app:clean'.
> Unable to delete directory: /mnt/D/Document/WorkSpace/Android/Test/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/25.0.0/jars
I clean that path and again it tell me that:
Error:Execution failed for task ':app:clean'.
> Unable to delete directory: /mnt/D/Document/WorkSpace/Android/Test/app/build/intermediates/exploded-aar/com.android.support/cardview-v7/25.0.0/jars
I clean it handy and again:
Error:Execution failed for task ':app:clean'.
> Unable to delete directory: /mnt/D/Document/WorkSpace/Android/Test/app/build/intermediates/exploded-aar/com.android.support/support-compat/25.0.0/jars/libs
I don't know how many steps exists and if I pass all these steps, may be I mentally!
I don't have these issues in android 1.4. is this a bug about android studio or related to my system(Arch Linux)?
Thanks in advance.
Disable Instant Run. It is in
File -> Settings -> Build,Execution -> Instant Run
This worked for me.
For me there was a stuck debug test inside of Android Studio and mockable-jar was used inside of that JVM and couldn't be deleted.
What I had to do is.. stop the frozen JVM from Task Manager, then clean.
What I'll do the next time this happens is.. stop the frozen debug test from Android Studio, then clean.
i finally fix it!
after:
apply plugin: 'com.android.application'
add this line of code to build.gradle(Module: app) file:
task clean(type: Delete) {
delete rootProject.buildDir
}
it will delete all jar and lib files from build your directory.
hope to enjoy :)
My project was build initally with bradle build system in android studio after I switching branches in git I got the following error.
This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system.
When i try exetuting gradle task I get error :
Error:Android Source Generator: [project-name] AndroidManifest.xml file not found , Even though I have the file in proper place.
I have been trying to fix this from several days. I have tried re-importing the project, clone the project again. Any help is gladly welcome.
Thanks,
I have an Android project that requires the Jsoup library. I've tried everything I can think of to get the jar shaded into the APK.. I just can't get it working. Logcat tells me:
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: org.jsoup.Jsoup
Does anyone know how to include/shade a maven artifact into an APK with Android Studio?
I have found the answer. The trick is to append ":sources". See an example here: http://www.alonsoruibal.com/my-gradle-tips-and-tricks/
I have seen the same type of error every time someone else adds a library with Gradle. Build is usually successful but app crashes when it tries to use the new library. Running task clean with Gradle helps.