Moving an Android Studio project causes an error - android

I moved an Android Studio project that used Gradle from D:\old\file\path to D:\new\file\path and now I'm getting the following error:
Installation failed with message Invalid File: D:\old\file\path\app\build\intermediates\split-apk\debug\slices\slice_8.apk
I tried uninstalling the app from my phone and still got the same error. I also tried an emulator but that didn't work either.

Close your project. Using your system file manager, delete all .iml files you have inside your project folder (probably this will be few files, two or three). This is the point where you instruct your A.S. to forget the older path.
Then import - not open - import your project on a brand new window of your Android Studio.
From the File menu, use Invalidate caches and restart. Clean Build and run again.

I figured it out.
Build -> Clean Build worked

Related

Android Studio 4.0.0 - Unable to save settings: Failed to save settings. Please restart Android Studio

from a week I was updated my Android Studio version to stable version 4.0.0 then I am started getting this errors in my studio and unable to build the app.
Unable to save plugin settings: The plugin org.jetbrains.android failed to save settings and has been disabled. Please restart Android Studio
But I forcefully enabled all plugins in my Studio by going to File-->Settings-->Plugins --> All are enabled.
Select Embedded JDK in Android Studio
Try that:
delete the .idea folder in the android project folder where you faced this problem.
Close Android Studio. Now navigate to your projects .idea folder and rename the workspace.xml file to workspace-o.xml and delete a workspace.xml~ if it exists (i.e., AS has a corrupt workspace layout file).
This should fix the problem. Restart AS and configure the workspace back they way you like it (i.e., it will start with a simple view: View/Tools Windows/Project etc.).
I started my first project in Android Studio and my answer may not be the correct one. I ran into this problem during building the My Activity project. It always came back with this error asking me to restart. Finally I thought that the controlled folder file access is preventing me. I temporarily switched-off the protection(against Ransomware in Windows 10) and tried the Build. I stopped getting these messages. But, I have other problems I am looking into.
I deleted the .idea folder and then I invalidated the cache (file-> invalidate Cache/Restart)
This fixed my issue.

Gradle Error while running flutter project in Android Studio

I am completely new to flutter.
Yesterday I installed flutter, added path variables and it works straight from cmd.
I also created a project using cmd and opened it in Android Studio.
Import of Dart and Flutter plugins has done, too.
Then what the problem could be here ?
you need to delete cache of android studio and restart build of the project .
go to file in android studio and click in invalidate cache screen
This error means that a file that Gradle has downloaded has become corrupted.
Delete the .gradle directories in both your home directory and in your project's root directory and try building again.

Android Studio - Gradle sync failed: Already disposed

After updating to Android Studio 3.2 Beta 1, I started getting the following error for two different projects:
Gradle sync failed: Already disposed!
There is no error with Android Studio 3.1.3, and there was no error with various canary versions of Android Studio 3.2 before updating to beta 1.
I already tried everything I can think of (e.g. complete cleaning of project, including all generated .gradle/.iml/.idea files/folders, as well as a complete invalidate cache and restart of Android Studio) without success. The build works as expected from command line using Gradle.
This is not a duplicate of Android Studio Gradle Already disposed Module
EDIT
The event log is showing
Unable to save plugin settings: The plugin org.jetbrains.android failed to save settings and has been disabled. Please restart Android Studio
In the "IDE Fatal Errors" window, I am seeing the following exception:
'Gradle: backport-util-concurrent:backport-util-concurrent:3.1#jar' already disposed: --------------Creation trace:
java.lang.Throwable
at com.intellij.openapi.util.TraceableDisposable.<init>(TraceableDisposable.java:45)
at com.intellij.openapi.roots.impl.libraries.LibraryImpl.<init>(LibraryImpl.java:103)
at com.intellij.openapi.roots.impl.libraries.LibraryImpl.<init>(LibraryImpl.java:69)
at com.intellij.openapi.roots.impl.libraries.LibraryTableBase$LibraryModel.readExternal(LibraryTableBase.java:327)
at com.intellij.openapi.roots.impl.libraries.LibraryTableBase.loadState(LibraryTableBase.java:64)
at com.intellij.openapi.roots.impl.libraries.LibraryTableBase.loadState(LibraryTableBase.java:30)
at com.intellij.configurationStore.ComponentStoreImpl.doInitComponent(ComponentStoreImpl.kt:375)
at com.intellij.configurationStore.ComponentStoreImpl.initComponent(ComponentStoreImpl.kt:331)
at com.intellij.configurationStore.ComponentStoreImpl.initPersistenceStateComponent(ComponentStoreImpl.kt:121)
at com.intellij.configurationStore.ComponentStoreImpl.initComponent(ComponentStoreImpl.kt:96)
at com.intellij.openapi.components.impl.PlatformComponentManagerImpl.initializeComponent(PlatformComponentManagerImpl.java:54)
EDIT2:
More recent version of Android Studio 3.2 are having the same issue.
As it turned out, the problem was that I was trying to open a project directory that was a symlink to the actual location (on the same partition). Gradle (on command line) had no issues building the project from the symlinked location, however, opening it in Android Studio resulted in the obscure and non helpful error described above.
Simple solution
1.Delete module folder and modules.xml file under .idea folder.
2.Close Android Studio
3.Reopen and sync
Possible duplicate problem:
Android Studio 3.0 - Unable to save settings: Failed to save settings. Please restart Android Studio Android Studio 3.0 - Unable to save settings: Failed to save settings. Please restart Android Studio
This worked for me: Delete the .idea folder.
1) Go to File--> Settings -->Plugins Disable any plugins not loaded (i.e. red in color) #friederbluemle This may not apply to you.
2) Enable the one plugin, Android Support
3) Right-click on your 'app' directory (contains your module gradle.build file) in Android Studio and select 'Show in Explorer' --- this opens that directory.
4) Quit Android Studio. Get out of any and all instances of Android Studio to allow you to then delete the fold, .idea, in that directory.
5) Restart AS, you'll notice the project will not come up -- you'll have to pick in the dialog window that appears. That's ok. Pick it, and it will 'rebuild' the folder, .idea.
6) Go to File--> Settings -->Plugins Enable any and all plugins if any.
What worked for me was going to Android Studio File and Invalidate/Restart options.
What worked for me is as follows
Delete the .idea folder
Close Android Studio
Reopen Android Studio and allow it sync your project all over.

Gradle sync failed in android studio

I am using eclipse for developing android applications.Its works good and I can debug and run the application.But now I installed android studio and move to creating new apps using android studio,But i get the following error
Gradle sync failed
What is gradle and how can i fix this problem, Now also I can't import my eclipse project to android studio
I had the same issue when importing my project from eclipse to android studio. I'll tell you how I fixed it. It's simple.
- Solution 1: It is possible to import your project from eclipse to android studio, but android studio version 1.2 currently has bugs with that. What I did is I created a new application with the same app name, same package name, same minimum api and all these things... Then normally, go to your app's folder that you want to import it from eclipse, and copy it's src folder and java folder, maybe asset and libs folder too if you have them, and paste it to your newly created project in android studio by going to that folder: "Users/AndroidStudioProjects/appname/".
If that's not your issue, try the other following solutions:
- Solution 2: Add this to your gradle.properties file in the project. This will just increase your android studio's memory:
org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=512m
You can also replace 512 to 1024 if you have enough memory in your pc.
- Solution 3: Try to close all your pc apps that consume large memory, and try that: In android studio, there is a toolbar at the top, where there is "Build" tab. Select Clean Project then Rebuild Project. Then try to sync your project again.
If you find the File Encoding Error is showed in your log when trying to sync your gradle, click on it and change the project formatting to UTF-8.
Source: https://stackoverflow.com/a/30498383/4843993
I would prefer to start solution 2 then 3 first before trying solution 1. If you still face the same issue, tell me. :)

Gradle project sync failed?

When I started up my project this morning it randomly gave me a message saying Gradle project sync failed. Basic Functionality(eg. editing, debugging) will not work properly. in Android Studio. I looked at other answers that people had put up for this problem but they haven't been working. I invalidated my chaches/restarted my project but no luck. I also deleted my .gradle folder from my project folder and still no luck. If any of you guys could help me that would be awesome! This didn't happen yesterday when I was working on the project or anything, I wonder why its happening now. Oh yea it also says this as a gradle message: Error:C:\Users\Dave\.gradle\caches\2.2.1\scripts\settings_ad4t0wp5ikihzl1y1o83b5sbw\SettingsScript\buildscript\cache.properties (The system cannot find the file specified) :
Thanks again for anyone who reads this/ can help!
There is a file - "cache.properties" that gradle creates for you, upon first time inception of any project. The path for this file is "~Home_Directory\.gradle\2.2.1\taskArtifacts". You may find this path in your home directory. So basically, this file - "cache.properties" is missing from the "taskArtifacts" folder.
One of the solution that worked for me is to copy file - "cache.properties" from any test project of yours to this project that's currently experiencing an issue.
Regards
I had to choose using the Default Gradle Wrapper instead of local.
<< SETTINGS -->/ BUILD TOOLS --> Gradle --> radio button switch... >>
It has helped me to fix the same problem.
I had experience similar sync failed problem with gradle based android project (in Android Studio 1.1.0). I solved this problem without deleting .gradle from my user directory,
steps I followed was
Go to File -> Settings -> Compiler(Gradle Based Android Project)
Change VM options to -Xmx512m -XX:MaxPermSize=512m.
Click Apply -> OK and then tap on Try Again option in sync failed message to clean build the project.
Works like charm!!
UPDATE - 1 : For Android Studio 1.3, Compiler option mentioned in above Step-1 is present inside tab Build, Execution, Deployment.
I had faced similar kind of problem earlier!
But don`t know after rebuild the project and cleaning it, it worked normally.
Invalidate dependency cache by running
gradle clean build --refresh-dependencies
from project root and then re-import your project. Worked for me once.
May be you have put Android Studio into offline mode. To fix it, go to Preferences -> Gradle and ensure that the "Offline work" checkbox is not checked.
Than do
File -> Invalidate caches / Restart
Shutdown Android Studio
Rename/remove .gradle folder in the user home directory
Restart Android Studio let it download all the Gradle stuff it needs
android studio 0.4.2: Gradle project sync failed error
Delete the folder C:\Users\.gradle and reopening the android studio solved my problem

Categories

Resources