我试图让Support7Demos构建,但我一直遇到问题。
初始错误:
Error:(23, 21) No resource found that matches the given name: attr 'colorAccent'.
Error:(21, 21) No resource found that matches the given name: attr 'colorPrimary'.
Error:(22, 21) No resource found that matches the given name: attr 'colorPrimaryDark'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'.
Error:(23, 21) No resource found that matches the given name: attr 'colorAccent'.
Error:(21, 21) No resource found that matches the given name: attr 'colorPrimary'.
Error:(22, 21) No resource found that matches the given name: attr 'colorPrimaryDark'.
Error:(35, 21) No resource found that matches the given name: attr 'alertDialogTheme'.
Error:(21, 21) No resource found that matches the given name: attr 'colorPrimary'.
Error:(22, 21) No resource found that matches the given name: attr 'colorPrimaryDark'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Dialog.Alert'.
Error:(21, 21) No resource found that matches the given name: attr 'colorPrimary'.
Error:(22, 21) No resource found that matches the given name: attr 'colorPrimaryDark'.
Error:(35, 21) No resource found that matches the given name: attr 'alertDialogTheme'.
Error:(21, 21) No resource found that matches the given name: attr 'colorPrimary'.
Error:(22, 21) No resource found that matches the given name: attr 'colorPrimaryDark'.
Error:(35, 21) No resource found that matches the given name: attr 'alertDialogTheme'.
Error:(21, 21) No resource found that matches the given name: attr 'colorPrimary'.
Error:(22, 21) No resource found that matches the given name: attr 'colorPrimaryDark'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog.Alert'.
Error:(21, 21) No resource found that matches the given name: attr 'colorPrimary'.
Error:(22, 21) No resource found that matches the given name: attr 'colorPrimaryDark'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog.Alert'.
Error:(21, 21) No resource found that matches the given name: attr 'colorPrimary'.
Error:(22, 21) No resource found that matches the given name: attr 'colorPrimaryDark'.
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '***'' finished with non-zero exit value 1
将compilesDkVersion
更改为21,将targetSdkVersion
更改为21。没有区别。
然后我改变了:
compile 'com.android.support:appcompat-v7:18.0.+'
到
compile 'com.android.support:appcompat-v7:21.0.+'
现在我得到了:
Error:(35, 21) No resource found that matches the given name: attr 'alertDialogTheme'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Dialog.Alert'.
Error:(35, 21) No resource found that matches the given name: attr 'alertDialogTheme'.
Error:(35, 21) No resource found that matches the given name: attr 'alertDialogTheme'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog.Alert'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog.Alert'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '***'' finished with non-zero exit value 1
最后将compile 'com.android.support:appcompat-v7:21.0.+'
改为v23,因为它推荐......但这就是我碰壁的地方。最终错误:
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '***'' finished with non-zero exit value 1
我最好的谷歌搜索导致了Error retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23,但如果我将编译版本更改为23,那么我只会收到许多新错误,而且我会回到1号广场。
这是我的build.gradle,它提供的错误最少:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.example.android.supportv7"
minSdkVersion 7
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.+'
}
作为一个注释,更改构建工具似乎没有做任何事情。
答案 0 :(得分:2)
我在一小时前建立了Support7Demos。这是我在Eclipse工作几年后首次尝试迁移到Android Studio。为了使构建工作在新的导入Support7Demos之后我做了这个:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.android.supportv7"
minSdkVersion 7
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:gridlayout-v7:23.1.0'
compile 'com.android.support:palette-v7:23.1.0'
compile 'com.android.support:mediarouter-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
}
我的意思是你的主要问题是Support7Demos需要更多依赖。并更正您机器上安装的compileSdkVersion,targetSdkVersion和buildToolsVersion。
我列出的所有依赖项都是必需的。我逐个添加它们,每个都解决了一些错误,直到一切都开始工作。