-1

I am working on a project that uses android-support-v4.jar as a library (in the libs folder of my app), and I want to rename the android.support.v4 package in it but I am told that this can't be done because the directory is not located in the project.

(But I need it because I have ActionSherlock as an imported module, which also uses android-support-v4 as a dependency. When I first ran the app, I get error message, related to the loading of this library twice)

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
user1611830
  • 4,749
  • 10
  • 52
  • 89

4 Answers4

1

You should have the same copy of the android-support-V4.jar in both libs directories. Just copy the one on your libs into the ActionBarSherlock libs directory.

Emmanuel
  • 13,083
  • 4
  • 39
  • 53
0

You can't refactor other people's package structure. And: You don't need to.

Just remove the library from your own project's libs folder. The IDE is smart enough to take the support-library from ActionBarSherlock. (if you have imported it correctly)

Lovis
  • 9,513
  • 5
  • 31
  • 47
0

In ActionSherlock module in build.gradle file

dependencies {
   compile 'com.android.support:support-v4:+'
}

and in your main project in build.gradle file

dependencies {
    compile project(':libraries: ActionSherlockModule')
}
Dimentar
  • 603
  • 7
  • 13
0

Your problem is likely one of the following:

  1. You are referencing two different versions of android-support-v4.jar. Check the file signature to ensure that both projects are using the same file.

  2. You have included the sources of the support library in the parent project and are attempting to provide a jar in the child project. It's recommended to simply use provided android-support-v4.jar from the SDK folder.

In other words: no, you should not be attempting to rename the package name of the support library.

Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
  • Yes indeed I have two different versions of the same `android-support-v4.jar` but when I delete the one in the `libs` folder, `imports` in my main activity is no longer recognized. And when I delete the one in the `ActionBarSherlock`, this one is not compiled anymore. How can I circumvent the problem – user1611830 Dec 06 '13 at 15:25
  • You need the library in both projects; simply ensure that the files are identical. – Paul Lammertsma Dec 06 '13 at 15:31
  • sorry I am very new to `Android`, how can I detect if their identical ? – user1611830 Dec 06 '13 at 15:45
  • I copied the support file from the app libs directory the one of `ActionBarSherlock` and I get this message : `UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl;` – user1611830 Dec 06 '13 at 16:11
  • This likely means that the library occurs twice in the class path. See [the answers in this question](http://stackoverflow.com/questions/15387530/android-dex-unexpected-top-level-exception-already-added), especially the one relating to nested dependencies. – Paul Lammertsma Dec 06 '13 at 17:36