Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't build with gradle when Google Play Services added as dependency

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

: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

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)

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

like image 979
alvinmeimoun Avatar asked Dec 25 '22 05:12

alvinmeimoun


1 Answers

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)

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

like image 50
alvinmeimoun Avatar answered Dec 30 '22 18:12

alvinmeimoun