Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gradle error when Theme declare-styleable in two libraries

I tried to compile an android project using the following build.gradle file:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    maven {
        url 'https://github.com/Goddchen/mvn-repo/raw/master/'
    }
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.1.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 18
    }
}

dependencies {
        compile 'com.android.support:appcompat-v7:18.0.+'
        compile 'com.android.support:support-v4:18.0.+'

        compile 'com.google.android.gms:play-services:3.2.+'

        compile 'com.facebook.android:facebook:3.5.+'
        compile 'com.android:volley:1.0'
        compile 'org.jraf:android-switch-backport:1.0'

}

But this fails with the following error:

:TestProject:processDebugResources
/home/lukas/apps/Splots_test/apps/TestProject/build/res/all/debug/values/values.xml:1622: error: Error: No resource found that matches the given name: attr 'switchStyle'.
:TestProject:processDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':TestProject:processDebugResources'.
> Could not call IncrementalTask.taskAction() on task ':TestProject:processDebugResources'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

After looking at the generated values.xml I found that it was missing the declare-styleable "Theme" section of android-switch-backport.

This section is defined in both Appcompat and AndroidSwitchBackport, but only one of these is included in the final file:

lukas@lukas-Workstation:~/apps/Splots_test/apps$ grep -r 'declare-styleable name="Theme"' .
./TestProject/build/exploded-bundles/ComAndroidSupportAppcompatV71800.aar/res/values/values.xml:    <declare-styleable name="Theme">
./TestProject/build/exploded-bundles/OrgJrafAndroidSwitchBackport10.aar/res/values/values.xml:    <declare-styleable name="Theme">

Is there any way to tell gradle it should merge the attributes of both libraries?

like image 279
Lukas H Avatar asked Oct 28 '13 00:10

Lukas H


2 Answers

I run into this problem,too.I think you need to change the attrs.xml file in android-switch-backport library.

Try changing this

<declare-styleable name="Theme">
        <attr name="switchStyle" format="reference" />
        <attr name="switchPreferenceStyle" format="reference" />
</declare-styleable>

to this:

<declare-styleable name="AppTheme">
        <attr name="switchStyle" format="reference" />
        <attr name="switchPreferenceStyle" format="reference" />
</declare-styleable>
like image 66
jonah_w Avatar answered Oct 17 '22 06:10

jonah_w


Just so you know, I am the developer of the Switch Backport library, and this problem no longer exists since version 1.3.1.

(Make sure you include the correct repo when upgrading, since it is no longer maven central).

like image 31
BoD Avatar answered Oct 17 '22 07:10

BoD