IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl;

。_饼干妹妹 提交于 2019-12-04 04:13:39

Apparently there were 2 reasons for this issue.

1) PagerSlidingTabStrip library depends on a local support lib v4 jar. Remove the dependency and add the project as a library project in your app and inside it add the maven dependency for support v4. So it should look exactly like the Facebook library project from above.

2) RoboSpice library depends on LRUCache from support lib v4 (https://github.com/octo-online/robospice/issues/195). Just exclude it from your main build.gradle file and you should be good to go.

compile ('com.octo.android.robospice:robospice-spring-android:1.4.7')
        {
            exclude module: 'support-v4'
        }

Hopefully this will help somebody and not spend an entire week with this problem like I did. Oh, and trillion of thanks to @Snicolas. Couldn't have solved it without his help.

Edit: As of RoboSpice v1.4.8, there is no more local support lib dependency, so this issue is fixed.

For anyone who happens to hit this error while using Visual Studio with Xamarin, like I did;

I solved it by simply removing the reference to "Xamarin.Android.Support.v4" from the References folder within the project, then cleaned and built project as normal.

When this is for Xamarin.Android, this error occurs for version mismatching between depended packages. You've got to remove this Xamarin.Android.Support.v4 package from the project along with other mismatching packages. (What does mismatching means here is, if your target Android version is Android 6, all packages listed in the packages.config file should have targetFramework="monoandroid60" packages. If any package won't abide this, it's a mismatching version). If you have messed with versions, then removing the reference and cleaning stuff alone won't work. You've got to remove all the mismatching packages from the Nuget Package Manager (Tools > NuGet Package Manager > Manage NuGet Packages for Solution...). Note that when you're to remove these packages, you'll also need to remove the depended packages. No harm go ahead and remove them all and you can re-install them with the correct version.

Once you've removed the package along with the dependent packages, try building the project. After a successful build, re-install the packages from the Nuget Package Manager with the correct version. (Package versions are listed according to the API levels, Ex: Android 6 which is API 23, would support packages of version 23.x.x)

Cleanup the project and build it, hopefully it'll succeed building!

Hope this'll help cleanup the mess!

Run "gradle androidDependencies" and check your dependencie tree. Add an exclude for the modules that are overlapped.

For example i had to do the following:

dependencies {
  compile 'com.google.android:support-v4:r7'
  compile project(':libraries:actionbarsherlock')
  compile ('com.github.chrisbanes.actionbarpulltorefresh:extra-abs:+') {
    // Need to specifically exclude this as it is specified in our own project
    exclude module: 'actionbarsherlock'
    exclude module: 'support-v4'
  }
}

The page slider library also have support library dependency. Thus you are getting this error. In case of maven all you need to do is change your main project pom file dependency entry of the support library to scope as provided.

<dependency>
    <groupId>android.support</groupId>
    <artifactId>compatibility-v4</artifactId>
    <version>13</version>
    <scope>provided</scope>
</dependency>

In case of gradle i think you need to change the dependency configuration to match maven provided scope

Please refer the following link for more details Convert Maven to Gradle

I just got this same issue. I simply updated all Xamarin.Android.Support… nuget packages to the same version.

Note: this app was older so I did not go to the Latest stable version as there were other dependencies that would have needed to be updated. I simply moved them all to the highest common version.

Good luck! Tom

Remove all old reference .dlls and relevant to that and add again from NuGet.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!