2013-10-28 14 views
9

Próbowałem skompilować android projekt stosując następujący plik build.gradle:błąd Gradle gdy Motyw deklaruje-styleable w dwóch bibliotekach

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' 

} 

Ale to nie powiedzie się z powodu następującego błędu:

: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 

Po obejrzeniu wygenerowanych wartości .xml odkryłem, że brakowało stylu "theme" stylu "zignoruj" w Android-switch-backport.

Ta sekcja jest zdefiniowana zarówno AppCompat i AndroidSwitchBackport, ale tylko jeden z nich znajduje się w końcowej pliku:

[email protected]:~/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"> 

Czy istnieje jakiś sposób, aby powiedzieć Gradle powinno łączyć cechy obu bibliotek?

Odpowiedz

1

tak wiesz, jestem twórcą biblioteki Przełącznik backportu, a problem ten już nie istnieje od wersji 1.3.1 .

(Upewnij się, że podczas aktualizacji uaktualniono poprawnie transakcję repo, ponieważ nie jest ona już centralna).

+0

Dzięki, to naprawdę doceniane :) –

5

Również napotykam ten problem. Myślę, że musisz zmienić plik attrs.xml w bibliotece android-switch-backport.

Spróbuj zmienić ten

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

do tego:

<declare-styleable name="AppTheme"> 
     <attr name="switchStyle" format="reference" /> 
     <attr name="switchPreferenceStyle" format="reference" /> 
</declare-styleable> 
+0

oznacza to rekompilację biblioteki? – GorillaApe

+1

@Parhs Tak, musimy. Z powodu konfliktu nazewnictwa między biblioteką przełącznika android-backport a biblioteką app-compat. – Koruk

+0

@Koruk jak to zrobić, jeśli zainstalowałeś go z build.gradle? Musisz pobrać samą bibliotekę? Skąd? –

Powiązane problemy