Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: File path too long on windows, keep below 240 characters

So, I made some changes to my build.gradle(app) file and android studio gives me this error (open the image in new tab for better viewing): Error description from Logcat

My build.gradle(app) file (this is not the edited file, I deleted new lines of code and still no luck/solution.): Build.gradle

Everything was quite working well until I made some changes in the build.gradle(app) file, but then I deleted those new lines of codes and android studio is still keep giving me the error. The error relates to the compile 'com.google.android.gms:play-services:8.3.0'. I have tried deleting/renaming those png images inside the stated folder,but then when I rebuild the project, the png images are automatically downloaded. My build.gradle(project) file contains classpath 'com.android.tools.build:gradle:1.5.0'. I want to know what causes this error, and how to fix it? Many thanks.

like image 218
Neel0507 Avatar asked Nov 24 '15 23:11

Neel0507


People also ask

How do I shorten a long file path?

The general strategy is to keep the first two folders at the beginning, replace the middle with an ellipsis, and leave the final folder and filename on the end.


4 Answers

You could also try changing your build directory for your project since that is where most of the path issues will arise. In your root build.gradle file

allprojects {
    buildDir = "C:/tmp/${rootProject.name}/${project.name}"
    repositories {
       ...
    }
}

Android Studio will pick up on the change and still show your new build location in the Project view. It's a lot easier than moving your entire project.

EDIT

While Windows 10 Insider Preview now offers the ability for allowing for longer file path limits these limits currently are only actually accessible to apps which have specifically enabled support for longer file paths.

At the current time, it appears that these applications with the extended path enabled seem to be only apps that are installed via the Windows Store.

At the current time, Gradle does not and potentially cannot have this option enabled to utilize the enhanced NTFS file path length.

like image 195
lodlock Avatar answered Oct 14 '22 06:10

lodlock


I just ran into the same issue. I don't know a fix for your exact problem, but I found a work around; I see your project has a deep file path hierarchy. Why not just move your project up from a lower level?

Ex: C:\Projects\YourProject

That fixed the problem for me.

like image 39
Vladimir Dimov Avatar answered Oct 14 '22 05:10

Vladimir Dimov


Cause of problem : 'C:\users...\commom_google_signin_btn_text_dark_normal.9.png' icon path length is greater than 240 character which exceeds Maximum File Path Length Limitation of Windows OS.

Solution is : Move your project into top directory like 'C:\your_project' or reduce length of your project name.

Here is windows path limit chart enter image description here

like image 22
Biswajit Karmakar Avatar answered Oct 14 '22 05:10

Biswajit Karmakar


As a very solid alternative to actually moving the project I'd suggest using a hard link. The syntax of that would be like this

mklink /J C:\AndroidProjects\ProjectName C:\MyVeryVeryVeryVery…VeryVeryVeryLongPath\ProjectName

Now you can work on your project in C:\AndroidProjects\ProjectName, and have the changes right where your project is supposed to be.

like image 39
Daniël van den Berg Avatar answered Oct 14 '22 04:10

Daniël van den Berg