本文介绍了使用 Google Drive 在 OS X 上的 Android Studio 中导致 gradle 构建失败的图标文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于大学课程,我需要使用 Google Drive 文件夹作为我的项目位置.问题是 Google Drive 使我隐藏的 OS X Icon 文件 出现.

For a college course, I am required to use a Google Drive folder as my project location. The problem is that Google Drive makes my hidden OS X Icon files appear.

当我尝试在 Android Studio 中运行应用程序并构建它时,会打开一个 Icon 文件并收到以下消息:

When I try running the app within Android Studio, and it gets built, an Icon file opens and I get the following messages:

build文件夹下的文件是生成的,不要编辑.

错误:文件名必须以 .xml 结尾.

我的res/layout 文件夹包含一个Icon 文件,它(显然)不以.xml 结尾.我删除了该文件,但仍然出现相同的错误.

My res/layout folder contains an Icon file, which (obviously) does not end in .xml. I deleted the file, but I still get the same error.

有没有办法解决这个问题,在 Mac 上的 Google Drive 文件夹中构建我的应用程序,还是不可能?

Is there a way to work around this issue to build my app in a Google Drive folder on a Mac, or is it not possible?

以下是上下文中的错误:

Here are the errors in context:

/Users/meda/GoogleDrive/Gloriane-CS115/AndroidStudioProjects/MyFirstApp/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.4.0/res/drawable/Icon
Error:Error: The file name must end with .xml
:app:preBuild UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:prepareDebugDependencies
:app:generateDebugBuildConfig UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
Error:Error: The file name must end with .xml
:app:generateDebugResources UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
Error:Error: The file name must end with .xml
/Users/meda/GoogleDrive/Gloriane-CS115/AndroidStudioProjects/MyFirstApp/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.4.0/res/color-v23/Icon
Error:Error: The file name must end with .xml or .png
/Users/meda/GoogleDrive/Gloriane-CS115/AndroidStudioProjects/MyFirstApp/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.4.0/res/drawable-hdpi-v4/Icon
Error:Error: The file name must end with .xml or .png
/Users/meda/GoogleDrive/Gloriane-CS115/AndroidStudioProjects/MyFirstApp/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.4.0/res/drawable-ldrtl-hdpi-v17/Icon
Error:Error: The file name must end with .xml or .png
/Users/meda/GoogleDrive/Gloriane-CS115/AndroidStudioProjects/MyFirstApp/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.4.0/res/drawable-ldrtl-mdpi-v17/Icon
Error:Error: The file name must end with .xml or .png

推荐答案

这些是我们根据 Hod 的回答开发的解决方案.

These are the solutions we developed, based on Hod's answer.

删除所有当前的Icon文件

Getting rid of all current Icon files

  1. 在项目的父文件夹中打开一个终端窗口.
  2. 要查找图标文件,请执行: find .-name Icon\*
  3. 如果得到任何结果,请执行: find .-name 图标\* -delete

自动删除以后的Icon文件

Automatically removing future Icon files

  1. 在项目的父文件夹中打开一个终端窗口.
  2. 复制并粘贴此咒语((改编自 https://stackoverflow.com/a/9625233/631051),它将每分钟删除 Icon 文件:(crontab -l 2>/dev/null; echo "*/1 * * * * find .-name Icon\* -delete") |crontab -
  1. Open a terminal window in the parent folder to your projects.
  2. Copy and paste in this incantation ( (adapted from https://stackoverflow.com/a/9625233/631051), which will delete Icon files every minute:(crontab -l 2>/dev/null; echo "*/1 * * * * find . -name Icon\* -delete") | crontab -

要撤消,请输入以下咒语(改编自 https://askubuntu.com/a/719877/43296) 在终端窗口中(在任何文件夹中):crontab -l |grep -v 图标|crontab -

To undo, enter the following incantation (adapted from https://askubuntu.com/a/719877/43296) in a terminal window (in any folder): crontab -l | grep -v Icon | crontab -

假设

所有这些都假设您有:

  • 在您的项目层次结构中没有名称以 Icon 开头的文件要保留.
  • 没有涉及您想要保留的 Icon 的 cron 作业.
  • no files whose names start with Icon in your projects hierarchy that you want to keep.
  • no cron jobs involving Icon that you want to keep.

这篇关于使用 Google Drive 在 OS X 上的 Android Studio 中导致 gradle 构建失败的图标文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 23:42