今天在编译项目的时候碰到一个问题,代码完全相同的情况下,只是把项目移到SVN的另一个目录,编译无法通过
Gradle提示如下错误(不方便截自己的图片,网上转一个):
Gradle: Execution failed for task ':AplikaceBeta1.0.1:mergeDebugResources'. Failed to run command: C:\Users\David\AppData\Local\Android\android-studio\sdk\build-tools\android-4.2.2\aapt.exe s -i C:\Users\David\Desktop\facebook-android-sdk-3.5\facebook-android-sdk-3.5\samples\AplikaceBeta1.0.1Project\AplikaceBeta1.0.1\build\exploded-bundles\AplikaceBeta101ProjectLibrariesFacebookUnspecified.aar\res\drawable\com_facebook_profile_picture_blank_square.png -o C:\Users\David\Desktop\facebook-android-sdk-3.5\facebook-android-sdk-3.5\samples\AplikaceBeta1.0.1Project\AplikaceBeta1.0.1\build\res\all\debug\drawable\com_facebook_profile_picture_blank_square.png Error Code: 42 Output: C:\Users\David\Desktop\facebook-android-sdk-3.5\facebook-android-sdk-3.5\samples\AplikaceBeta1.0.1Project\AplikaceBeta1.0.1\build\exploded-bundles\AplikaceBeta101ProjectLibrariesFacebookUnspecified.aar\res\drawable\com_facebook_profile_picture_blank_square.png ERROR: Unable to open PNG file
老外的答案还是很给力的:
Are you using Windows? This error could happen if the generated build file path exceeds the Windows (not NTFS) max path length of 260 characters. Make sure your project path is not too long, use short names as well.
Maximum Path Length Limitation In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\some 256-character path string" where "" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)
总结原因,就是项目文件路径太长,超过了长度限制,256个字符
通过修改文件名以及简化路径,减少相应文件的深度,成功解决了这个问题。
希望小伙伴们能快速解决掉这个问题。