简体   繁体   English

解决Android Studio中Gradle错误“属性“ xxx”已定义”的有效方法?

[英]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.

相关问题 Gradle错误“属性”xxx“已在Android Studio中定义” - Gradle error “Attribute ”xxx“ has already been defined” in Android Studio Gradle错误:Android Studio中“属性“ rippleColor”已定义” - Gradle error: “Attribute ”rippleColor“ has already been defined” in android studio HoloEverywhere,ActionBarSherlock与Gradle给出'属性xxx已经定义' - HoloEverywhere, ActionBarSherlock with Gradle gives 'Attribute xxx has already been defined' 错误:(1)属性“ rippleColor”已在android studio中定义 - Error:(1) Attribute “rippleColor” has already been defined in android studio 属性“titleTextStyle”已在android studio 1.2.1中定义? - Attribute “titleTextStyle” has already been defined in android studio 1.2.1? Android:错误:(464)属性“ dividerPadding”已经定义 - Android: Error:(464) Attribute “dividerPadding” has already been defined 错误:属性“ android:orientation”已经定义 - Error:Attribute “android:orientation” has already been defined Android属性已经定义 - Android Attribute has already been defined Android:属性'rippleColor'已经定义 - Android: Attribute 'rippleColor' has already been defined 错误:(2)属性“ spinnerStyle”已被定义 - Error:(2) Attribute “spinnerStyle” has already been defined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM