很难让Gradle构建Android L“;错误:多次找到项目样式/AppTheme“;
我目前正在尝试使用Android L SDK版本创建一个Android应用程序。 但是,当尝试使用Gradle构建项目时,我遇到以下错误: “错误:多次找到项目样式/AppTheme” 指向我的res/values-v21/styles.xml 我知道res/values/styles.xml中已经定义了一个样式“AppTheme”,但据我所知,我遵循了《Android开发者指南》中关于使用Android L的规定。也许有人可以帮助我: 这是我的: build.gradle很难让Gradle构建Android L“;错误:多次找到项目样式/AppTheme“;,android,xml,android-studio,android-gradle-plugin,android-5.0-lollipop,Android,Xml,Android Studio,Android Gradle Plugin,Android 5.0 Lollipop,我目前正在尝试使用Android L SDK版本创建一个Android应用程序。 但是,当尝试使用Gradle构建项目时,我遇到以下错误: “错误:多次找到项目样式/AppTheme” 指向我的res/values-v21/styles.xml 我知道res/values/styles.xml中已经定义了一个样式“AppTheme”,但据我所知,我遵循了《Android开发者指南》中关于使用Android L的规定。也许有人可以帮助我: 这是我的: build.gradle apply plug
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.mayuonline.ribbit"
minSdkVersion 'L'
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:20.+'
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="resume.kelseyhrubes" >
<uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/primary_light</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light">
</style>
<style name="AppTheme">@color/primary
@color/primary_dark
@color/primary_light
</style>
</resources>
values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="resume.kelseyhrubes" >
<uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/primary_light</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light">
</style>
<style name="AppTheme">@color/primary
@color/primary_dark
@color/primary_light
</style>
</resources>
@颜色/原色
@颜色/原色/深色
@颜色/主光
values-v21/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="resume.kelseyhrubes" >
<uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/primary_light</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light">
</style>
<style name="AppTheme">@color/primary
@color/primary_dark
@color/primary_light
</style>
</resources>
@颜色/原色
@颜色/原色/深色
@颜色/主光
我为格式错误道歉,我希望所有内容都可读。
如果有人知道我做错了什么,请告诉我。我只想制作一个具有甜美材质设计的应用程序。与错误状态一样,您在values-v21/styles.xml中定义了两次AppTheme。移除其中一个。啊,当然!我不知道为什么我没有注意到这一点。