gpt4 book ai didi

android - 导入项目时发生Gradle构建错误: “Error: The file name must end with .xml”

转载 作者:行者123 更新时间:2023-12-03 06:33:24 25 4
gpt4 key购买 nike

我正在尝试在我的 friend 最近推送到GitHub的Android Studio中克隆存储库。他在资源目录中放置了一个png文件,当我尝试构建它时,控制台会说:

/.../app/src/main/res/picture100/empty.png: Error: The file name must end with .xml

我在Google上搜索了很多解决方案,但是发现在大多数类似情况下,控制台消息显示为“文件名必须以.xml或.png结尾”,因此请注意,我的消息中没有 no“或.png “,因为它只是gradle不允许在资源文件中使用的png文件。

我已经和 friend 确认我们正在使用相同版本的Gradle(4.1)和Android Plugin(3.0.0)。

build.gralde:
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.xyzhang.testapp"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

对于gradle构建失败,将永远不会解析符号R。它显示为红色。

如何解决这个问题?

最佳答案

/.../app/src/main/res/picture100/empty.png: Error: The file name must end with .xml

似乎您已在 res 文件夹内创建了 picture100 文件夹。 Android不允许您在 res 目录中创建此类文件夹。因此,您必须将其删除。

或者,如果您希望继续使用 picture100 文件夹,则必须将 xml文件放入该文件夹中。

您可以在 可绘制 Mipmap 中使用图像文件

关于android - 导入项目时发生Gradle构建错误: “Error: The file name must end with .xml”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48971785/

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