[英]Efficient way to fix Gradle error “Attribute ”xxx“ has already been defined” in Android Studio?
In my project, i have a module abc : 在我的项目中,我有一个模块abc :
//abc module (lib) dependency
dependencies {
compile 'com.android.support:support-v4:21.0.3'
}
And my app's dependency: 和我的应用程序的依赖关系:
dependencies {
compile project(':abc')
}
And the errors are: 错误是:
“Attribute ”mnp“ has already been defined”
“Attribute ”xyz“ has already been defined”
...
And i found that all these attributes are defined in declare-styleable
of module abc and they are quite a lot . 我发现所有这些属性都是在abc模块declare-styleable
中定义的,并且它们很多 。 I dont know where they produce the duplicate since i can run normally from Eclipse, not Android Studio. 我不知道它们在哪里产生重复项,因为我可以从Eclipse而不是Android Studio正常运行。 Some suggests that to manually rename the attributes of those but I think it is time consuming. 有些人建议手动重命名这些属性,但我认为这很耗时。
Any better solution? 有更好的解决方案吗? Thank you! 谢谢!
This happens to me as well when I import project from Eclipse. 当我从Eclipse导入项目时,也会发生这种情况。 Android Studio seems to binds library project even thou there was an error adding library modules. 即使添加库模块出错,Android Studio似乎仍会绑定库项目。
I can usually fix this by firstly delete library modules, then opening Project's settings.gradle
file and delete imports from there. 我通常可以通过以下方法解决此问题:首先删除库模块,然后打开Project的settings.gradle
文件并从此处删除导入。 After this, import of library modules works well. 此后,库模块的导入效果很好。
And when I have issues with styleable file, I can usually fix this by setting SDK version to at least 20 (Android 5.0) 而且,如果我在样式文件方面遇到问题,通常可以通过将SDK版本设置为至少20(Android 5.0)来解决此问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.