Error: the file path in the windows is too long, below 240 characters

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

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

Everything worked fine until I made some changes to the build.gradle (app) file, but then I deleted these new lines of code and android studio still keeps giving me an error. The error is related to the compilation of 'com.google.android.gms: play-services: 8.3.0' . I tried to delete / rename these png images inside the specified folder, but then when I rebuild the project, the png images are automatically loaded. My build.gradle (project) file contains the classpath 'com.android.tools.build:gradle:1.0.0' . I want to know what causes this error, and how to fix it? Thank you very much.

+66
android android-gradle google-play-services android-gradle-plugin
Nov 24 '15 at 23:17
source share
14 answers

I just ran into the same problem. I do not know how to fix your exact problem, but I found a job; I see that your project has a hierarchy of file hierarchy. Why not just move your project from a lower level?

Example: C:\Projects\YourProject

This fixed the problem for me.

+101
Nov 25 '15 at 8:37
source share

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

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

Android Studio picks up the changes and displays your new build location in the Project view. This is much easier than transferring the entire project.

EDIT

While Windows 10 Preview now offers the option for longer file path restrictions, these restrictions are currently only available for applications that specifically support longer file paths.

It currently seems like these accessibility apps are apparently only apps that are installed through the Windows Store.

Currently, Gradle cannot and possibly cannot enable this option to use the extended NTFS file path length.

+165
Jan 08 '16 at 15:10
source share

The cause of the problem: 'C: \ users ... \ commom_google_signin_btn_text_dark_normal.9.png' the path of the character is more than 240 characters, which exceeds the maximum file path length limit for Windows.

Solution: Move the project to the top directory, for example, C: \ your_project, or reduce the length of the name of your project.

Here is the limit diagram of the window path enter image description here

+11
Apr 18 '16 at 6:56
source share

As a very simple alternative to actually moving the project, I would suggest using a hard link. The syntax for this would be:

 mklink /JC:\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 should be.

+6
Jan 06 '16 at 12:51 on
source share

I agree with the answer of Vladimir Dimov. You should choose a short path for your project, as it is mentioned that the file path should be below 240 characters on Windows. This link helps me: http://www.feelzdroid.com/2016/01/android-studio-error-file-path-too-long-windows.html

+2
Feb 11 '16 at 11:39
source share

As a complement to lodock's answer, you can use the hash on the project path if you have many projects with the same name:

 import java.security.MessageDigest def hashString(String s){ MessageDigest.getInstance("SHA1").digest(s.bytes).encodeHex().toString() } allprojects { buildDir = "C:/AB/${hashString(projectDir.getAbsolutePath())}" } 
+2
Oct 14 '16 at 2:05
source share

Shortening the project’s paths is actually a bit of a hack, Ivan Neeson’s answer seems the way forward.

If you are fortunate enough to use Android Studio, you will see a useful error message. If, however, you encounter the same problem as for the command line created using the ion assembly, you will see that there is some kind of crunch error for the png file, and this is not so obvious.

The real issue is Google Play services that have extravagant file names like common_google_signin_btn_text_light_normal_background.9.png that are just not Windows friendly. Dump that inside the Android assembly and the path explodes out of our control on the \ android \ build \ intermediates \ exploded-aar \ com.google.android.gms \ play-services-base \ 10.2.1 \ res \ drawable-xhdpi- v4 platforms \ common_google_signin_btn_text_light_normal_background.9.png

+2
May 05 '17 at 1:59 pm
source share

Take a look at http://feelzdroid.com/2016/01/android-studio-error-file-path-too-long-windows.html . The solution is too simple to keep the folder path less than 240 characters.

Make sure there are less than 240 charters on the way.

+1
Jan 07 '16 at 6:39
source share

You should leave your project directory as deep as possible. For example: - D: / AndroidWorkSpace / ProjectName

Because support for Android Studio is only 240 project path character length

thank

+1
May 03 '16 at 11:46
source share

You can use the NTFS junction point to create a shorter path to your project. To learn more about Junctions, read the following: Hard links and links

A connection (also called a soft link) differs from a hard link in that the storage objects that it refers to are separate directories, and the connection can link directories located on different local volumes on the same computer. Otherwise, transitions work the same way with hard links.

0
Jan 26 '16 at 13:33
source share

I found this problem when I have two duplicate folders like,

 E:\project-one\project-one 

and when it has a long folder name for example

 E:\project-one-with-very-big-name 

To avoid this problem, make the project folder simple and short.

0
Dec 28 '16 at 6:37
source share

For Windows users:

You may be tempted to create a network resource in the root folder of the project, and then display it. This method will shorten the overall path length, but will cause problems for Android Studio due to the difficulty of detecting modified files. The best solution is to use the subst command. Here is an example script to work around the problem. Change the names as needed and change them to point to the project and install the directories.

File: launchAS.cmd

 subst P: "C:\private\java42\ide\42g\workspaces\AndroidStudioProjects" cd "C:\private\java42\programs\android-studio-base\bin" start studio64.exe 

The above commands will create a P: drive and map it to the project root folder. This will reduce the overall path length to the project files and may give you some relief for the problem with a path name that is too long. Use P: \, since when opening projects you would use a long root name.

To remove a mapping use command: subst P: / d

0
Jan 23 '17 at 21:21
source share

I ran into the same problem, my project is on C drive, and it is in a deeper path. What I did was, I just moved my project to another place on a lower deep path, and it works, you just change the project location and the project does not have to be in a deep location hierarchy.

0
Oct. 16 '18 at 16:08
source share

I had a different experience with this problem. At first I had this error, but then I noticed that my previous projects in the same directory were opening. This is the way:

C: \ Users \ koralis \ Documents \ extract \ Ex_Files_Android_App_Dev_LDS_Upd \ Exercise Files \ Ch01 \ 01_06 \ ImageAssets

Surprisingly, I upgraded this version of Gradle to "com.android.tools.build:gradle{.2.2" from "com.android.tools.build:gradle:2.0.0".

This solved my problem.

0
Mar 15 '19 at 9:37
source share



All Articles