我试图在我的Android应用程序中进行测试。我有这个build.gradle的根目录:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
configure(allprojects) { project ->
buildscript {
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
mavenLocal()
}
}
}
project.ext.preDexLibs = !project.hasProperty('disablePreDex')
subprojects {
group = 'com.firext.android'
ext.androidBuildToolsVersion = '19.1.0';
ext.androidMinSdkVersion = 18;
ext.androidCompileSdkVersion = 19;
ext.androidTargetSdkVersion = 19;
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "file://${System.getenv("ANDROID_HOME")}/extras/android/m2repository" }
mavenLocal()
}
project.plugins.whenPluginAdded { plugin ->
if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
} else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
}
}
}
apply plugin: 'java'
这对于build.gradle项目模块:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':libraries:AndroidBootstrap')
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services:3.1.+'
compile 'com.github.pedrovgs:renderers:1.0.9'
compile 'com.jakewharton:butterknife:5.0.1'
compile 'com.etsy.android.grid:library:1.0.4'
compile 'ch.acra:acra:4.5.0'
compile 'com.loopj.android:android-async-http:1.4.4'
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile 'com.android.support:support-v4:+'
androidTestCompile 'com.google.guava:guava:14.0.1',
'com.squareup.dagger:dagger:1.1.0',
'org.hamcrest:hamcrest-integration:1.1',
'org.hamcrest:hamcrest-core:1.1',
'org.hamcrest:hamcrest-library:1.1',
'com.jakewharton.espresso:espresso:1.1-r2'
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
signingConfigs {
release {
//Omitted
}
debug {
testCoverageEnabled = true
}
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs += 'src/gen'
res.srcDirs = ['res']
}
test {
java.srcDir file('src/test/java')
resources.srcDir file('src/test/resources')
}
androidTest.setRoot('.')
androidTest {
java { srcDirs = [
'src/test/java'
] }
res.srcDirs = ['res']
assets.srcDirs = [
'assets'
]
resources.srcDirs = [
'src'
]
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
productFlavors {}
}
这在清单中:
<application
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/FirextTheme"
android:name=".FirextApplication">
这就是风格:
<resources>
<style name="CustomDialog" parent="android:Theme.Holo.Light.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowIsFloating">false</item>
</style>
<style name="FirextTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/ActionBar</item>
</style>
<style name="ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#D30000</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#ffffff</item>
<item name="android:displayOptions">useLogo|showHome</item>
</style>
</resources>
当我进行同步时,我收到此错误:
Error:(29, 24) No resource found that matches the given name (at 'theme' with value '@style/FirextTheme').
在此之前,我有一个默认的build.gradle并且工作正常,但现在没有......什么不对?
答案 0 :(得分:0)
您应该将defaultConfig
添加到android
部分:
android {
compileSdkVersion ext.androidCompileSdkVersion
buildToolsVersion ext.androidBuildToolsVersion
defaultConfig {
minSdkVersion ext.androidMinSdkVersion
targetSdkVersion ext.androidTargetSdkVersion
}
}
Holo仅适用于4.0。如果您需要支持旧版本,则必须使用AppCompat或ActionBarSherlock
您可以将style.xml
更改为:
<style name="FirextTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/ActionBar</item>
</style>