gpt4 book ai didi

android - 无法在 Windows 上最近安装的 Android Studio 上构建 Support7Demos

转载 作者:可可西里 更新时间:2023-11-01 10:19:18 25 4
gpt4 key购买 nike

我试图构建 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。没有区别。

然后我改变了:

编译 'com.android.support:appcompat-v7:18.0.+'

编译 '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,那么我只会收到大量新错误,然后我又回到了方 block 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.+'
}

请注意,更改构建工具似乎没有任何作用。

最佳答案

我在一个小时前构建了 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。

我列出的所有依赖项都是必需的。我将它们一一添加,并分别解决了一些错误,直到一切开始正常工作。

关于android - 无法在 Windows 上最近安装的 Android Studio 上构建 Support7Demos,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33293283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com