I was working on android studio 1.4, there clicking on gradle sync icon ("Sync Project with gradle files") on the top middle , performed only sync for gradle scripts, no build.
Now in Android Studio 2.2, clicking on gradle sync perform sync and build both.
Is there a way to stop AS from doing that, no build, only sync.
Found it myself, we have to tick the "skip source generation.." in gradle experimental settings. For my purpose I have given the value 0 in module numbers.
Related
I have an issue with Android Studio where it doesn't automatically do a gradle sync when changing branches.
Which causes many false positives problems in code like unresolved references etc...
I have found a workaround to force the sync by running File > Sync Project with Gradle Files.
Is there anyway to force the IDE to do this automatically by scripting or using a plugin or anything.
After downgrading from Gradle 6.1.1 to 7.2 and Android Gradle Build tools 7.1.0 to 4.0.1 (by switching branches in Git) I got the following exception in the Run console (tool window) of Android Studio Bumblebee 2021.1.1 (when trying to run the app on a device):
Unable to determine application id: com.android.tools.idea.run.ApkProvisionException: Couldn't get post build model. Module: My_App.app Variant: debug
The Grade build runs successfully but the app won't be installed in the device.
In Android Studio run File > Invalidate Caches ... and restart (you don't need to select the optional "Clear file system cache and Local History"). Just to be sure, also run Build > Clean Project.
I have faced this issue when i upgrade to android studio Dolphin. So for me this workaround was to delete the existing app configuration from Run/Debug Configurations.
After that add new configuration by clicking the left top + icon and then add Android App.
IDE keeps sending *-sources.jar requests on each sync. This files are missing on server, so it leads to waste of time on each sync (especially on multi module projects). Is there a gradle or IDE option to disable this file requests? or optimize number of requests for multi module project?
There are few solutions how to build project offline:
Do it in terminal
gradle --offline build
Change it in gradle window (Android Studio 3.6.1)
I have a multi-module build that has multiple variants, for example modules App, LibA and LibB and variants release, debug, and tester. When I run a build profile for the tester variant, I see under dependency resolution that the following are running:
App:releaseCompileClasspath
App:releaseRuntimeClasspath
App:releaseImplementationDependenciesMetadata
App:releaseRuntimeOnlyDependenciesMetadata
App:releaseAnnotationProcessorClasspath
App:releaseApiDependenciesMetadata
App:releaseCompileOnly
App:releaseCompileOnlyDependenciesMetadata
These extra tasks are slowing down my build, is there any reason they are running or any way to disable them?
Voila! This exact scenario has been targeted in Android Studio 3.3!
Android Studio 3.3 now supports Single-variant project sync!
As per the latest release notes for Android Studio 3.3,
Syncing your project with your build configuration is an important step in letting Android Studio understand how your project is structured. However, this process can be time-consuming for large projects. If your project uses multiple build variants, you can now optimize project syncs by limiting them to only the variant you have currently selected.
Requirements:
Android Studio 3.3 or higher
Android Gradle plugin 3.3.0 or higher
Steps:
Click File > Settings > Experimental > Gradle (Android Studio > Preferences > Experimental > Gradle on a Mac) and select the Only sync the active variant checkbox
Surprisingly, my project is completely written and developed in Java only, it's also not containing any dependencies declared for Kotlin. Yet I'm receiving this weird error:
A problem occurred configuring project ':app'.
Configuration:
When I use the below configuration, it works perfectly fine, builds the project and the app gets installed on my device/emulator:
Android Studio Version: 3.1 Stable release
Gradle Plugin Version: 3.0.1
Gradle Distribution URL:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
BUT When I use the latest configuration declared below, the error occurs while running the app as shown in the images:
Android Studio Version: 3.1 Stable release
Gradle Plugin Version: 3.1.0
Gradle Distribution URL:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Steps I've followed/things I've tried:
Clean Project
Rebuild Project
Sync Project
Deleting build folder from project tree
Checked that project doesn't contain any names, references or declarations missing
Invalidate Caches/Restart
Check the whole dependency tree to make sure any Kotlin dependency is not imported or used as my project doesn't make use of Kotlin language
None of the above have worked!
I think instant run might be creating issue .
Do one thing disable instant run in android studio and try again .I think it might will resolve issue .
Try to update Android Studio. Turn off Instant Run from Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run.