Mehvish Ali
Mehvish Ali

Reputation: 752

java.nio.file.InvalidPathException after Update

I have recently updated my Android Studio to v 2.2 Preview 5. and as I tried to run my one of my project I am getting 2 Errors.

  1. java.nio.file.InvalidPathException after Update (As I preview the layout.)
  2. Error:Execution failed for task ':app:mergeDebugResources'.> D:\Work\petrichors\projects\Eguide\app\src\main\res\layout-xlarge-xhdpi-land: Error: Invalid resource directory name.

However the project was running fine on previous version I had.

Log:

java.nio.file.InvalidPathException: Illegal char <:> at index 8: @android:drawable/ic_menu_slideshow
    at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
    at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
    at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
    at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
    at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
    at java.nio.file.Paths.get(Paths.java:84)
    at com.android.ide.common.res2.ResourceItem.parseFileName(ResourceItem.java:585)
    at com.android.ide.common.res2.ResourceItem.parseXmlToResourceValue(ResourceItem.java:405)
    at com.android.ide.common.res2.ResourceItem.getResourceValue(ResourceItem.java:240)
    at com.android.ide.common.res2.AbstractResourceRepository.getConfiguredResources(AbstractResourceRepository.java:393)
    at com.android.ide.common.res2.AbstractResourceRepository.getConfiguredResources(AbstractResourceRepository.java:349)
    at com.android.tools.idea.configurations.ResourceResolverCache$1.compute(ResourceResolverCache.java:166)
    at com.android.tools.idea.configurations.ResourceResolverCache$1.compute(ResourceResolverCache.java:163)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
    at com.android.tools.idea.configurations.ResourceResolverCache.getResourceResolver(ResourceResolverCache.java:163)
    at com.android.tools.idea.configurations.Configuration.getResourceResolver(Configuration.java:1212)
    at com.android.tools.idea.rendering.RenderTask.getResourceResolver(RenderTask.java:198)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:425)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$52(RenderTask.java:659)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Upvotes: 1

Views: 2236

Answers (2)

Anthony S.
Anthony S.

Reputation: 36

I had the same InvalidPathException problem this morning, also after updated to v2.2 preview 5. I solved it by removing leading/trailing spaces and line-break on the concerned XML declaration.

Check if there is a ':' which should not be here.

It seems Android Studio is a bit more sensitive to XML values.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006984

However the project was running fine on previous version I had.

That directory has been invalid for several years. Most likely, the tools and Android just ignored it, or did not honor all of its qualifiers, and now the build tools are validating the directory names.

Change layout-xlarge-xhdpi-land to layout-xlarge-land-xhdpi. Qualifier rules have to appear in the directory name (left to right) in the order that they appear in "Table 2" (top to bottom).

Or, better yet, remove -xhdpi outright. Having a density qualifier in anything other than a drawable or mipmap resource directory is a code smell. It should not be necessary and may not be doing what you think it should be doing anyway.

Upvotes: 1

Related Questions