当谷歌播放服务作为依赖项添加时,不能使用gradle构建吗

时间:2021-12-12 21:09:49

I'm trying to add Google Play Services to my project to use MapView, but when i add this to build.gradle compile "com.google.android.gms:play-services:5.2.08" i got a build error

我试图将谷歌Play服务添加到我的项目中,以使用MapView,但是当我将其添加到build中时。我得到了一个构建错误

:app:mergeDebugResources
D:\...\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\5.2.08\res\drawable-mdpi\common_signin_btn_text_disabled_focus_light.9.png ERROR: Unable to open PNG file
D:\...\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\5.2.08\res\drawable-hdpi\common_signin_btn_icon_focus_light.9.png ERROR: Unable to open PNG file
D:\...\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\5.2.08\res\drawable-xhdpi\common_signin_btn_icon_normal_light.9.png ERROR: Unable to open PNG file
D:\...\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\5.2.08\res\drawable-mdpi\ic_plusone_medium_off_client.png ERROR: Unable to open PNG file
D:\...\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\5.2.08\res\drawable-xhdpi\common_signin_btn_text_normal_dark.9.png ERROR: Unable to open PNG file
D:\...\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\5.2.08\res\drawable-xhdpi\common_signin_btn_text_pressed_dark.9.png ERROR: Unable to open PNG file
Error:Failed to run command:
    C:\...\AndroidStudio\sdk\build-tools\android-4.4W\aapt.exe s -i D:\...\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\5.2.08\res\drawable-mdpi\common_signin_btn_text_disabled_focus_light.9.png -o D:\...\app\build\intermediates\res\debug\drawable-mdpi-v4\common_signin_btn_text_disabled_focus_light.9.png
Error Code:
    42
Output:
    D:\...\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\5.2.08\res\drawable-mdpi\common_signin_btn_text_disabled_focus_light.9.png ERROR: Unable to open PNG file
:app:mergeDebugResources FAILED
Error:Execution failed for task ':app:mergeDebugResources'.
> Error: Failed to run command:
    C:\...\AndroidStudio\sdk\build-tools\android-4.4W\aapt.exe s -i D:\...\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\5.2.08\res\drawable-mdpi\common_signin_btn_text_disabled_focus_light.9.png -o D:\...\app\build\intermediates\res\debug\drawable-mdpi-v4\common_signin_btn_text_disabled_focus_light.9.png
Error Code:
    42
Output:
    D:\...\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\5.2.08\res\drawable-mdpi\common_signin_btn_text_disabled_focus_light.9.png ERROR: Unable to open PNG file

My build.gradle file

我的建立。gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-L'
    buildToolsVersion "20.0.0"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    defaultConfig {
        applicationId "com.test.myapp"
        minSdkVersion 'L'
        targetSdkVersion 'L'
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    compile 'com.android.support:support-v4:21.0.0-rc1'
    compile 'com.android.support:palette-v7:21.0.0-rc1'
    compile 'com.android.support:cardview-v7:21.0.0-rc1'
    compile 'com.android.support:support-v13:21.0.0-rc1'

    compile "com.google.android.gms:play-services:5.2.08"
}

I installed everything in Extras, Android L, Android 4.4W and Android 4.4.2 on SDK Manager (everything is up to date)

我在SDK管理器上安装了所有配件,Android L, Android 4.4W, Android 4.4.2(都是最新的)

Tried adding compile 'com.android.support:appcompat-v7:21.0.0-rc1' , Rebuild Project, still doesn't work

尝试添加编译'com.android.support:appcompat-v7:21.0 -rc1',重建项目,仍然不起作用。

2 个解决方案

#1


10  

Thank's to this post ! The path of the files causing the problem was bigger than 260 characters and can't work on a NTFS filesystem (Sorry, i forgot to mention that i use Windows 7)

感谢这篇文章!导致问题的文件路径大于260个字符,无法在NTFS文件系统上运行(对不起,我忘了提到我使用了Windows 7)

You can opt this this tool http://www.ntwind.com/software/utilities/visual-subst.html to shorten the path and overcome the mergeDebugResource Exception

您可以选择这个工具http://www.ntwind.com/software/applicties/visual -subst.html来缩短路径并克服mergeDebugResource异常

#2


0  

I hit this also, and the answer was the same as you documented (THANK YOU!) - where the build failed citing a very long path name. I was trying to build the sample at:

我也点了这个,答案和您所记录的一样(谢谢!)我试着在:

https://github.com/playgameservices/android-basic-samples

https://github.com/playgameservices/android-basic-samples

I moved the toplevel folder to root at a much shorter path. Then the build was completely clean.

我将toplevel文件夹移到更短的路径上。然后构建就完全干净了。

And yes it was on a Win7 box running an NTFS filesystem.

是的,它在运行NTFS文件系统的Win7盒子上。

Reminds me of the old saying - There are only three good numbers in Computer Science:

这让我想起了一句老话——计算机科学中只有三个好数字:

0, 1, and infinity

Cheers,

欢呼,

#1


10  

Thank's to this post ! The path of the files causing the problem was bigger than 260 characters and can't work on a NTFS filesystem (Sorry, i forgot to mention that i use Windows 7)

感谢这篇文章!导致问题的文件路径大于260个字符,无法在NTFS文件系统上运行(对不起,我忘了提到我使用了Windows 7)

You can opt this this tool http://www.ntwind.com/software/utilities/visual-subst.html to shorten the path and overcome the mergeDebugResource Exception

您可以选择这个工具http://www.ntwind.com/software/applicties/visual -subst.html来缩短路径并克服mergeDebugResource异常

#2


0  

I hit this also, and the answer was the same as you documented (THANK YOU!) - where the build failed citing a very long path name. I was trying to build the sample at:

我也点了这个,答案和您所记录的一样(谢谢!)我试着在:

https://github.com/playgameservices/android-basic-samples

https://github.com/playgameservices/android-basic-samples

I moved the toplevel folder to root at a much shorter path. Then the build was completely clean.

我将toplevel文件夹移到更短的路径上。然后构建就完全干净了。

And yes it was on a Win7 box running an NTFS filesystem.

是的,它在运行NTFS文件系统的Win7盒子上。

Reminds me of the old saying - There are only three good numbers in Computer Science:

这让我想起了一句老话——计算机科学中只有三个好数字:

0, 1, and infinity

Cheers,

欢呼,