gradle is getting installed multiple times and its ends up with failure - gradle

when I open a new project on android studio it stuck at the Gradle installation process.
android studio installs the Gradle plugin multiple times as you can see from the build window
Download https://services.gradle.org/distributions/gradle-7.4-bin.zip finished, took 1 m 53 s 231 ms (115.85 MB)
Download https://services.gradle.org/distributions/gradle-7.4-bin.zip finished, took 4 m 29 s 699 ms (115.85 MB)
I don't know what could cause the problem, I tried to create a new project but the same problem

you can find gradle-wrapper-properties both files. delete one and synk project.
or clean project/rebuild project
or invalidate cache and restart
#android_studio

Try updating android studio to the newer version
Hopefully, it should solve the issue.

Related

.NET Core solution build gives a GenerateDepsFile error

Environment
Visual Studio 2019 (latest SP upto Dec 2020)
.NET Core 3.1 with latest SP up to Dec 2020
WebAPI project with lots of child DLLs being loaded at runtime
Problem Context
When the solution is build, a "GenerateDepsFile:" error is given by MS Build for a particular project in the solution. It tries to add an item to a dictionary when it already exists, but not which dictionary it is trying or what duplicate key is being attempted.
Exploration Performed
There are no compilation errors (apart from Deps file)
All referenced projects are building fine with no errors in themselves
All NuGet references are available with no errors
Clean and Rebuild all solutions involved
Manually delete the objand bin folders across codebase
The "GenerateDepsFile" task failed unexpectedly is too large and you should check its detailed build log to judge what is the real problem.
Under Tools-->Options-->Projects and Solutions-->Build and Run--> set MSBuild project build output verbosity to Detailed and then build again to get its detailed log.
Also, you can share the detailed error build log here with us.
Maybe you could check these suggestions:
1) clean nuget caches or just delete all cache file under C:\Users\xxx\.nuget\packages.
2) do not forget to delete .vs hidden folder under the solution folder, bin, obj folder of the project, and then use dotnet restore command or msbuild -t:restore command to restore these files.
3) update VS2019 to the latest 16.8.4 and your Net Core 3.1 Sdk to the latest 3.1.11.
After lots of exploration, it looked like a multi version NuGet package scenario (cleaned the NuGet cache already)
Finally I went to all child projects and validated if the same version of all NuGet package is being used across. It turned out that the version of some assemblies ( esp Microsoft.Data.SqlClient) were different in child projects and the calling project.
Since the projects themselves were building all fine, this was not reported on project level, but when those DLLs were getting consumed in parent one, it start giving the error.
It turned out the child projects were built a while back with the latest version available at that time. The parent project was just referencing the DLLs from the output folder and was not aware of previous version and got its own version updated..
So, do ensure that when a particular version of NuGet is approved at one place, that gets updated across the whole eco-system!
However MS should update the error to at least point what dictionary is failing with what specific key in the main message as its very hard to debug with the verbose log.
The "GenerateDepsFile" task failed unexpectedly.
I believe You just need to delete the bin and obj folder and then Clean and Rebuild solution.
this should work, It work for me after going through many approaches.

Switching From VS Mac To VS Windows got "java.exe" exited with code 2

Hello Guys
I got an issue when switching my Xamarin.Forms project from VSMac to VsWindows!
"java.exe" exited with code 2 when deploying.
I already try:
delete bin/ obj/ folders
remove all packages and re-add them
MultiDex
Verify the path (removing special char "!##$%ˆ&*(-_" etc..)
If you got an idea, tell me ;)
Regards,
If G Clovs solution doesn't work, then:
make sure the netstandard on your mac is exactly the same on your Windows pc.
Make sure you have the same Android SDK downloaded on your Windows - through Tools Menu > SDK manager.
If you are using stable channel for vs for mac updates, then make sure you are not suing the preview of budget packages on your Windows.
Apply the same logic in 3 for preview channel.
To avoid all these issues:
Simply go to vs for mac 2019, change to stable build and update the vs for mac to latest.
Update all android SDK and build tools to say v28
Update all nugget packages for the two projects and build successfully.
Go to vs 2019 and update vs to latest.
Repeat step 2 for vs.
Deselect preview in nugget package manager, and update nugget packages in the two projects.
Build successful.
Try the below steps, it was working for me.
Open Visual Studio in Windows
Open your Solution
Find for "Resource.designer.cs" file in Android Project and delete it
Remove obj and debug folders form PCL and Android project
Clean and Rebuild
Happy Coding :)
Kishore Kumar
With turning third page of google, I didn't find any answer.
But I found the answer by my own.
The issue was comming from the Android.csproj and the Keystore Path.
It was set to my Mac Path even if I had already changed it on
VSWindows AndroidProject => Properties => Signin
So I removed this lines on Android.csproj (edited with third text editor):
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>YourMacPath/Alias.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>Password</AndroidSigningStorePass>
<AndroidSigningKeyAlias>Alias</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>AliasPassword</AndroidSigningKeyPass>
On debug & release Part.
Then you can edit them on VS Windows.
Hope I helped someone.
See ya

Issues after updating Cordova from 3 to 2 on Visual Studio

After updating my Visual Studio 2015 Professional to use Cordova Update 3, I became unable to use it. New and existing Cordova projects don't show my www folder's files (although they still exist in disk) and I can't add them back due the error "The project file could not be loaded. Could not find file _apachecordovaprojectsourceitems.targets".
Every build fails with error MSB4044 The "RunMdaInstall" task was not given a value for the required parameter "MdaVsixDir".
There's a bug opened for this issue https://connect.microsoft.com/VisualStudio/feedback/details/1894979/cordova-update-3-totally-breaks-project-type
However, I have another machine where the VS 2015 still have the Cordova Update 2 installed and everything is ok. I don't dare to click the update button... The problem is that I can't use this machine to develop my project because it belongs to the company I work for, and I only work on this Cordova project at night, at home.
Is there any workaround for this problem?
I have a fix for this bug, thanks to help from MS Support!
1) Delete this folder: C:\Users[username]\appdata\local\microsoft\VisualStudio\14.0\ComponentModelCache
2) Open Visual Studio and create a new blank cordova project. This will regenerate the deleted folder.
3) Debug the blank project in ripple, first run may complain about a problem with Chrome and the debugger may fail to connect. Close chrome after this, and try debugging one more time and it should connect as desired.
4) Enjoy a once-more functioning development environment!

Visual Studio Tools for Apache Cordova : Error when creating or opening Project

I am running Visual Studio 2015 under Windows 10.
I was able to successfully create and open Cordova projects, but suddenly one day I started receiving the following error message:
An equivalent project (a project with the same global properties and tools version) is already present in the project collection, with the path "{path-to-cordova-project}". To load an equivalent into this project collection, unload this project first.
When I go to modify the Visual Studio installation, I can see "HTML/JavaScript (Apache Cordova)" appearing twice in the list of features:
As you can see, there is a replaced version, and an Update 1.
I have tried every combination of uninstalling/installing each of Apache Cordova (Replaced) and (Update 1), and also Tools and Windows SDK 10.0.10240. I also tried deselecting/selecting to reinstall.
I managed to get it working once for creating new projects, but when I opened a project which failed to open before, it started failing again for creation and opening, and haven't been able to get it working again.
I tried completely uninstalling VS 3 times, once using the command G:\vs_professional.exe /uninstall /force
I also tried tried renaming C:\ProgramData\Package Cache folder before installing again.
But it seems to be leaving bytes somewhere, because after reinstalling I can still see the Recent projects, and project templates downloaded before uninstalling.
I am now going to consider formatting the partition and reinstall Windows, but this is very frustrating and disappointing.
I hope someone come up with a solution for this before I proceed to format.
Thanks.
PS: I think the latest thing I installed before this started to happen was ASP.NET 5 Beta 7. But I am not sure if this was the root cause of this problem.
Same problem with (Visual Studio Tools for Apache Cordova Update 1 + ASP.NET 5 beta 7). I resolved it by uninstalling beta 7 of ASP.NET 5 (uninstall explain here) and do a devenv.exe /resetuserdata
Fixed it uninstalling apache cordova tools and using the vs installer to install it again.
Also did removed AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache and devenev /resetuserdata
so that may be also needed, not sure.

Visual Studio hangs constantly during build

Probably between 25 and 50% of the times I build my solution, I see this:
"The operation you requested is taking longer than expected to complete. This dialog will close when the action completes."
I hate this window in ways I can't describe. It never resolves, the Cancel button is never enabled, and the only way to remedy it is to kill the devenv process and load up my entire solution again, knowing full well that I've fixed nothing and I'm equally liable to see the same thing when I attempt my build.
My solution is about 60 projects in total, which are mostly C# class libraries, with a few each of web applications, web services, and console applications. However, the problem persists even when building one slice of the codebase with the majority (50) of the projects unloaded.
My problem is that the output windows doesn't tell me anything at the point at which it freezes, and I don't know how else to determine the cause of this lockup. If I were to guess, I would assume that it's a deadlock in the filesystem or something, but I don't know how to go about proving this--much less how to prevent it.
What can I do to diagnose and eliminate this from my solution so that I never see it again? In general, how can I diagnose problems that occur during a build?
Had a similar issue, VS would hang for 45 or so seconds then build for 4 seconds and complete. The 45 seconds of hang would not produce any output to GUI and VS would hang.
Using ProcMon I could see 3 million+ file operations on the /packages/ folder via devenv.exe when I would build this project (and would continue for some time after)!! The first steps of the build you can see that it was checking EVERY PACKAGE to see if it needed to do a package restore (it did not).
Since I tend to blame NuGet for everything, I disabled NuGet Package Restore "allow NuGet to download missing packages" checkbox under Visual Studio -> Options -> Nuget Package Manager -> General. To my delight, the build was very fast. 5 seconds total!
Turns out that we had enable package restore on build enabled (I think this is on by default now in VS) AND we also had the packages checked into source control. It seems this causes TFS to thrash in some way... Checking for restoring packages must trigger TFS to do some source control operation checks.
FYI this was VS2013 UPDATE 4 - Nuget version: 2.8.50926.663, on a sln with NumberOfProjects = 38, but I could recreate this hang just building a single csproj with 2 dependencies.
Update:
Localhost "Rebuild All" on Sln with SccNumberOfProjects = 53 was taking 7:05 with 2 minutes of visual studio frozen / unresponsive
down to 4:14 on a 2 core i5 with no freezing
down to 2:44 on a 4 core i7
Also: This was on a machine with various file watcher security tools, likely not adding any speed to this whole process... and possibly to blame.
Update in 2021:
If you are looking for a paradigm shift, the new SDK style csproj format (see migration tool) + nuget PackageReference makes updates almost instant (< 20 SECONDS for same projects in scenarios above) - highly recommend you upgrade any legacy projects.
** Known incompatibility - website package references do not support static file references via nuget ( checkout LibMan)
I have seen this happen on large projects when MSBuild is running with the diagnostic switch turned on. In Visual Studio, go to Tools / Options / Projects & Solutions / Build And Run, then check the MSBuild project build output verbosity value. If its not set to Minimal, try setting to minimal and see if your builds are able to complete.
I did not try any of the above solution as by the time I tried my approach - all was well again.
My steps are as following:
Close VS
Delete the .vs folder
Open my solution
Clean Solution OK
Build Solution OK
Optional Rebuild OK
In my case setting "maximum number of parallel project builds" to 1 kinda helped (i.e. building a project from clean state causes 1 min freeze followed by normal build and every subsequent build works fine).
Aforementioned setting can be set in Tool -> Options -> Projects and Solutions -> Build and Run.
Seems like running Visual Studio as Administrator solved the problem for me! (For always running a program as Administrator see How to Run Visual Studio as Administrator by default)
I've found Visual Studio hanging a lot on building larger projects. Turns out it was ReSharper. After I turned it off: Tools -> Options -> ReSharper -> Suspend Now, everything built fine no issues (even on very large solutions, 100+ projects)
There was a suggestion on Microsoft Connect that Modelling project was responsible for the freezes. I removed a Modelling project from our solution and have experienced no freeze since then (about a week).
For me it was something to do with npm package install that ran automatically. I went to Tools > Options > Project and Solutions > External Web Tools and unchecked all external tools and restarted VS. After that, I was able to build it again. I know I need them to be checked but I need to figure out what's triggering them and what's wrong with this solution file.
VS2019 exhibits this issue as well for me, in my case, the problem was because of dependencies stored on a network share. I have a hunch that Windows Defender Antivirus was scanning a lot of extra stuff that was in the network share, which is only accessible when connected to a fairly slow VPN.
For me the issue was witch an extension that automatically runs T4 templates on build (AutoT4). Disabling it when working with solutions with EF fixed the issue.
I moved my VS 2008 development platform from Windows 7 to Windows 10 and encountered a situation where Visual Studio would hang up every time I tried to build a large project. I had to build the project, then use the Task Manager to kill VS and then restart. Needless to say, this made debugging really difficult! Anyhow, the problem was that in moving to Win 10, VS was no longer running as administrator (and perhaps Win 10 is more particular about privileges). Changing the properties so that the program ran as administrator resolved the problem. (IngoB -- I don't have enough status to comment on your post, but thanks for pointing this out!)
Just try below command with admin mode. Before running this command make sure to close all VS instance.
devenv /resetuserdata
Note: devenv is located at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
In addition to the felickz's answer which solves (or almost solves) this problem for builds:
Except the problem during a build I also had problem with the Package Management Console. It took about a minute to wait for it. Using the procmon I found that the NuGet repository folder was parsed each time this window is opened (very smart, Microsoft!). There were about 1000 packages in this folder. After removing everything from the above folder the performance problem diapered.
Note that my answer relates to the VS 2015 (and may be below). I didn't tested, but suspect in VS 2017 it should be ok.
Visual Studio 2017
Removing Anaconda3 from the installation fixed it. In procmon I saw hundreds of thousands of calls looking for files in the Anaconda3 folder from hundreds of instances of powershell spawned by msbuild.
I had this problem because of an issue restoring nuget packages. There was a duplicate entry in the packages.config file. Rather than report it as an error, the build would just hang forever.
I didn't discover the problem until I tried to restore the nuget package through the "Manage Nuget Packages..." option in the menu. After removing the duplicate, the build completes properly.

Resources