gpt4 book ai didi

Android 构建 - "duplicate class: com.myapp.R"

转载 作者:行者123 更新时间:2023-11-29 01:39:01 25 4
gpt4 key购买 nike

我被这个构建错误难住了。看起来它可能与使用 AppCompat 有关,就好像我从构建文件中删除了该依赖项一样,构建错误不再存在。我没有使用产品风格,实际上这个项目确实非常简单——一个 Android 模块、几个类和一些资源。我使用的是 Android Studio 测试版 0.89(最新)。

我搜索了源代码树,可以看到两个名为 R.java 的文件,一个在应用命名空间中,另一个在 AppCompat 命名空间中。

相关的是第二个构建错误:“重复类:com.myapp.BuildConfig.java

搜索显示项目中只有一个同名文件。

此构建错误是什么意思,我该如何解决?

build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 19
buildToolsVersion "20.0.0"

defaultConfig {
applicationId "com.myapp"
minSdkVersion 15
targetSdkVersion 19
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:appcompat-v7:19.0.0'

}

最佳答案

我会尝试删除您的 R.java 文件,然后重建项目。

如果这不起作用,try doing this.

  1. Delete the "gen", "target" and "out" folders
  2. Revert the changes within the "ipr" and "iml" files (or just delete them all, maybe even .idea folder)
  3. Start IntelliJ 12
  4. Open the pom file
  5. Right click -> "Maven" -> "Reimport"
  6. "Build" -> "Rebuild project"

关于Android 构建 - "duplicate class: com.myapp.R",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25995050/

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