使用 React-Native 为 Android 构建应用程序失败并出现此错误
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Error: more than one library with package name 'com.github.xinthink.rnmk'
这似乎是由 react-native-material-kit (RNMK) 引起的。但是在 Sublime Text 中搜索所有项目文件,我找不到任何重复的 'com.github.xinthink.rnmk'。 作为引用,该应用程序的 iOS 版本运行良好。
编辑
这是我的settings.gradle 文件:
rootProject.name = 'myAppName'
include ':app'
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-material-kit'
project(':react-native-material-kit').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-material-kit/android')
include ':RNMaterialKit'
project(':RNMaterialKit').projectDir = file('../node_modules/react-native-material-kit/android')
这些是来自 build.gradle 的依赖项:
dependencies {
compile project(':react-native-vector-icons')
compile project(':react-native-material-kit')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':RNMaterialKit')
}
当我从依赖项(最后一行)中注释掉“compile project(':RNMaterialKit')”时,应用程序会正常构建并启动。但是,这样做可能会破坏使用该包的 react-native-material-kit。
最佳答案
抱歉,我还不能发表评论。我认为问题在于您在 settings.gradle
和 build.gradle
中使用了多个此库。
因此转到您的 build.gradle
并删除 compile "com.facebook.react:react-native:+"
。希望它
有效。
关于android - 错误 : more than one library with package name 'com.github.xinthink.rnmk' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37328031/