Android Studio 2.2 & 2.3 Gradle project refresh failed - android

I am new to Android Studio though I have watched a few tutorials before. I am getting the following error when I try to make a project on Android Studio 2.3:
Gradle "Projectname" project refresh failed.
Error:Failed to delete original file 'C:\Users\myname\AppData\Local\Temp\gradle_download2913498326076248476bin' after copy to 'C:\Users\myname\.gradle\caches\modules-2\files-2.1\javax.inject\javax.inject\1\6975da39a7040257bd51d21a231b76c915872d38\javax.inject-1.jar'.
Its the same error I got before updating from 2.2 to 2.3.
I tried searching the internet but couldn't find a solution.
Does anyone know how to fix this?

If "Messages Gradle Sync" recommends an upgrade; you probably already did this.
Disable instant run, To do this:
2.a. Open the Settings or Preferences dialog: On Windows or Linux, select File > Settings from the menu bar. On Mac OSX, select Android Studio > Preferences from the menu bar.
2.b. Navigate to Build, Execution, Deployment > Instant Run.
Uncheck the box next to Restart activity on code changes.
Check your anti-virus and turn-off, try again. I have not had this issue, but it was recommended on some older posts with success.
Hope one of these takes care of it. :)

Related

Android Studio can't find runner

I cloned a project from git and built it in android studio without any problems but I don't have (Run app) in android studio and also when I run run-android I get this error:
Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`
but I can run my emulator from AVD manager!
I did every solutions that I found with search but they didn't work for me
For me, the reason was one of the following:
Gradle sync was in progress
Gradle sync had failed
For the second case, go to your top-level or app build file and click Try again or Sync button on the notification shown at the top of the file.
You could also just try to sync the IDE with Gradle with either of these buttons:
I faced a similar error. I was trying to import a built apk to profile it and ran into the scenario where the run button was grayed out.
Ultimately what worked. I went to File > Manage IDE Settings > Restore default settings.. and redid the android studio setup.
Note: Doing this will RESET the entire Android Studio and redownload everything.
1- Give the SDK path (to find the emulator path), Usually in User\YourUsername\AppData (is hidden by default)\Local\Android\Sdk. in File->Project structure, SDK location. Also the Java\Jdk path for (JDKs) and the path "...java\util\concurrent" exist
Do not reset the IDE Settings (because you need to reinstall a lot of things and it will not solve)
2 possibility - from File->Setting->Tools->Emulator to check the Launch in a tool window
3 possibility -

How to disable Instant Run for Android Studio 3.0

After making a few changes I am getting an error
Session 'app': Error Installing APKs
According to some it is because of Instant Run.
On the latest Stable Android Studio 3.0, under Build, Execution, Deployment I don't have any option for Instant Run, even checked in the settings search. Any clue where I might be able to disable it?
Update 1: Tried reinstalling. No change.
Build number 171.4408382
Update 2: Gave reset a shot https://stackoverflow.com/a/19397632/1926621 still nothing.
Update 3: Not a duplicate. Must be something in the settings. A complete clean install/reset did it.
Screenshot of what I see:
Go to Android Studio Settings or Preferences (for MAC) -> Build,Execution,Deployment -> Instant Run.
Then deselect the "Enable Instant Run" checkbox at the top.
Linux Screenshot:
Windows Screenshot:
For Mac go to Help in MenuBar and type 'preferences'
or,
go to 'Android Studio -> Preferences' in MenuBar
Mac ScreenShot
Instant Run is not a feature of Android Studio 3.5 (and later) any more and so cannot be disabled.
In case you find an old guide recommending to disable it, you can ignore this instruction.
See here 1 and here 2.
Just make sure you go to Android Studio -> Preferences instead of File -> Other settings -> default settings.
Instant run should be there.
Instant Run is removed from Android Studio 3.5 and added Apply Changes which works for Android 8 and above please follow the link for more https://android-developers.googleblog.com/2019/08/android-studio-35-project-marble-goes.html
Finally fixed!
As other users on Linux and such saw the Instant Run option in the settings, I tried reinstalling and resetting the installation, following https://stackoverflow.com/a/19397632/1926621
Removed all old settings, and installation of Android Studio( kept the SDK files). Changed the path. Opened the same project, and the options were now there!
Easiest/Laziest option for For mac would be CMD+SHIFT+A Search for instant run, click on relevant suggestion and uncheck the checkbox
Instant run is not a feature in Android Studio Bumblebee anymore.

no cached version available for offline mode

At office, I am behind a proxy. The internet access is restricted.
So I performed a gradle sync at home and copied the folder ".gradle" present at C:\Users\username.gradle from my home PC to the same location on my office PC.
Now on my office PC, I set gradle in Android Studio to "Work Offline" but still whenever I try to perform a gradle sync, I get an error stating
Error: Could not download google-services.jar (com.google.gms:google-services:3.0.0): No cached version available for offline mode
However on digging through the ".gradle" folder I was able to locate the google-service.jar file at
C:\Users\username\.gradle\caches\modules-2\files-2.1\com.google.gms\google-services\3.0.0\32b833222c886ecfb37d79b1a05ce1eddb702db1
I am not sure how to proceed. Please help.
I had to dig for this a long time in the 2019.2 version. This option has moved in the UI. It is now in the toolbar of the gradle tools:
see JetBrains documentation at https://www.jetbrains.com/help/idea/jetgradle-tool-window.html#offline
This Error occurs when in your Android Studio's Gradle Tools Offline Mode option is Enabled.
When Enabled it lookes like this.
To fix it, you can Disable mode by clicking on the option shown in below screenshot.
> Update: I heard Google Listened to the suggestion! and now in new android studio versions, when you start a new project, a popup will come with option to either build with gradle online or offline.. Great for you all..
You need to re-enable your gradle online mode
Google changed the location of doing this...
After the latest version as at this time i am typing this answer, which is version below
Android Studio 3.6.1
built on February 27, 2020
I have sent a message to the them so Google changes this in next update..Cos the new location confuses the Software engineers who are used to the old way of doing it...
But for now follow these clear 2 steps to find it and toggle it Online or Offline easily..
Just Go to the top-right hand corner of your SDK and click the vertical Gradle tab as circled in red in the my picture below...
Then you Click this icon (which looks like a symbol in an electrical schematic circuit) on the gradle table that comes out.. As Circled in Red in my picture below..
Maybe helps someone. Just remove --offline in "Command-line Options:"
click on gradle on the right
toggle offline mode
try again (sync with gradle files)
It seems that in newer versions of IntelliJ (I am on 2018.1) you may need to uncheck the Offline checkbox in Gradle preferences.
Just for reference 2019.1 Ultimate IntelliJ, go to Gradle -> Settings (a top-rightmost icon) -> Uncheck the Offline work in Global Gradle settings.
Gradle Tab not presented, go to View -> Tool Windows -> Gradle to show it first.
I'm using android studio in MacBook
step 1 - Go to preferences by clicking android studio on the left
uppermost corner.
step 2 - Go inside Build,Execution,Deployment.
step 3 - Finally select Gradle.
step 4 - then, uncheck offline work. Click apply then ok.
step 5- lastly try to sync once again.
Hope this will work because it works for me.
You can set startParameter.offline=false in your settings.gradle
Try running gradle with the --debug flag, in addition to the --offline flag. That will tell you exactly where it's looking for the files.
One possible reason for the error is that the path of the .gradle folder is different between your home and office PC, possibly because your username is different on each machine. The .gradle cache uses absolute paths (see .gradle/caches/modules-2/metadata-2.16/artifact-at-repository.bin for an example). This is a documented Gradle issue: https://discuss.gradle.org/t/copying-the-gradle-cache-to-another-machine/7546/13. If possible, use the same GRADLE_HOME at home and work to resolve the issue.
How to configure gradle to work "offline" (using cached dependencies)
Uncheck the 'Offline work' under the Global Gradle settings fixes my issue.

Unable to clean or rebuild project in Android Studio 2

I have a problem with my Android studio 2. That's whenever I want to clean or rebuild my android project, I always get this message
Error:Execution failed for task ':app:clean'.
Unable to delete directory: C:\Users\MyPC\Desktop\SharePlace\app\build\intermediates
and can not fix it. what I only can do is go to File explorer and delete it.
then come back android studio and rebuild again. Sometime, that way also does not work.
I need some help to fix that Android studio. Please.
Thank inadvance!
Solution 1 :
you are using Android Studio 2.0 Beta, this issue might appear (more likely if you are working on NTFS filesystem) and it seems like the "Instant Run" is the culprit. Search for "Instant Run" in settings and uncheck the box.
I have filed an issue on the bug tracker.
Solution 2 :
You need to go to the source file directly. Close the studio and go to the path the issue is located at and delete the folder there.
I got a lot of faults like this.
Try to refresh all gradle projects: in Android Studio click on the "Gradle" tab on the right side of the window. When the gradle menu is shown, click on two blue mixed arrows icon. Then wait a moment until gradle completes refreshing and try cleaning or rebuilding again.
For me it was fixed by running Android Studio as administrator.
Manually deleted folder( build\generated and build\intermediates) after closing android studio works for me.
Found the solution. For windows, goto Task Manager and find your Android Studio. Expand it and end task for OpenJDK Platform Binary as depicted below
screenshot.
Then re-run your app in Android Studio again. It should work, and you don't have to restart your Android Studio all the time. More productivity~

Android Studio not setting up new project properly

When I open Android Studio I get the following errors:
On Clicking File > New > Project the following screen comes up:
This, as opposed to this:
Anyone know why this is the case:
I tried reinstalling Android Studio, no luck.
Then I tried reinstalling Android Studio, SDK and HAXM, pretty much everything I could uninstall, I tried opening new project from welcome screen... still no luck.
Any ideas?
Thanks.
Click "Enable Android support" in the first picture.
Go to File>Invalidate caches/restart>Invalidate and restart.
If your problem is not resolved, try clicking on "Enable Android support".
If your problem is not resolved, try going to Android SDK Manager and install:
Extras/Google Repository
Extras/Android Support Repository
Restart Android Studio when install finish.
If your problem persists and you are not going to use these plugins, click on "Disable not loaded plugins".
I hope this will help you.

Categories

Resources