Project Building successfully in Eclipse but not in Intellij - android

I have an Android project which uses the following library projects along with using the Android Support v4:
ActionBarSherlock
SlideMenuLib
Facebook
Google Play services
My project is working fine in eclipse and im able to launch the porject directly from the IDE but when I try to import and run the same project in IntelliJ (13.0.2), it gives me the following error
Android Dex: [Splash] com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
I know from the error that somehow IntelliJ is picking up the Supportv4 library multiple times from all the three places but any attempt to play around with the Support library imports, the project stops compiling saying com.android.support.v4 is missing in both Eclipse and Intellij.

Fixed the problem. Thanks to the solution found here: Intellij: android-support-v4.jar in included in actionBarSherlock and Project => IllegalArgumentException
I changed the scope of the support library in ActionbarSherlock and SlideMenuLib to 'provided' and that did the trick.

You have problems with your imports probably your project are using the same two libraries (older and new) and do not know with one should be used.
Check your Libs files, lib-project and references.
Try to: build path -> Order and Export, Uncheck the jar that is the same that the imported library uses.

Related

Android multidex support library using eclipse

Using Eclipse, is possible to generate an Android project using multidex for creating multiple
dex files? Searching over the net I found how to do that using gradle but nothing about to use that on
Eclipse without gradle
It looks like ADT's ant-tasks project is no longer maintained (it resides under 'legacy' folder).
So if you can't migrate to Gradle, you can edit the DexExecTask manually. You'll have of course to rebuild the project locally..
[Edit - 10/25/2014] maven-android-plugin does support multi-dex. However, it currently has a small issue: secondary dex files placed in wrong location. This pull request strives to fix that, so stay tuned! (Fixed in 4.0.0)

Jar mismatch scenario

I'm encountering a lot of jar mismatch errors lately and I'd like to avoid them in the future.
So, here's my question: suppose I have an app that uses 2 library projects, both of which use the v4 support library jar. In total, I have 3 jar files. What can I do to avoid the jar mismatch error?
All I've read so far is the case where you have a project and a single library project. In this case, I think your supposed to delete the jar file in the project and keep the one in the library project.
This is quite common if your project references several libraries, and each library references the same other library.
An example of this, your app is referencing the android support library v4, and you have 2 libraries which are also referencing the support library v4.
If you update your apps reference to the support library, but you don't update the support library v4 in your other libraries you will see this error.
The best thing is on each referenced library and your app, right click on the project > android tools > add support library. This will get the latest version and you should no longer see these errors.
If you're facing mismatch issue then simply copy one of them and paste in remaining libraries. E.g. as you've 3 v4 support library jars then copy one of them and paste at place of remaining two jars.
Try to understood by my example I used Map and Facebook in My project now Facebook,Map and my project have Android support jar so i removed Android Support jar from Facebook,My project but remain jar on Map,now i'm addded Android-Map-Extension as library project on Facebook And finally add Facebook library project on My project .....

After upgrading to Android Developer Tools version 22, compiling fails

Today, I upgraded ADT to version 22. After that, my projet wouldn't compile resources at all. My "gen" folder was empty and as such all my java files that require "R" wouldn't compile.
After a few non-full time hours, I restarted the "Android SDK Manager" and this time, I noticed these:
- "Android SDK Platform Tools" (upgrade)
- "Android SDK built-tools" (new)
After installing those, I was finally able to fully compile my project.
ADT22 use Android Private Libraries show project/libs'jar, add Exported feature, if you wannt reference library projects' private libraries, you must check the Exported
https://plus.google.com/photos/117122118961369445953/albums/5878509263473846433/5878509268379848162?authkey=CL3Frb-S_qj-fQ
If you are using some libraries or/and dependencies with other projects, you may also experience errors at execution time. In my case I had problems with Sherlock "Unable to execute dex: Multiple dex files define Lcom/actionbarsherlock/R$attr" and with some other jar file I am using "VFY: unable to find class referenced in signature" In that case, you must go to project properties, Java Build Path section, and remove Android Dependencies and Android Private Libraries, both in the main project and also in the dependent projects like for example Sherlock. After that you perform Clean on all projects. Everything should be restored. That worked for me, after a hard battle!

How to resolve java.lang.NoClassDefFoundError

I am using:
org.apache.commons.lang.builder.EqualsBuilder
in a in an Android library project (A) that in turn is used in another library project (B).
This works fine in the Android app that consumes library project B.
However, I have built an Android Test project to unit test the Android app - in particular the library project B classes. When doing so I encounter the following exception:
java.lang.NoClassDefFoundError: org.apache.commons.lang.builder.EqualsBuilder
I have included
commons-lang-2.6.jar
which contains the
org.apache.commons.lang.builder.EqualsBuilder
namespace in library project A build path for export.
I have searched SO for this issue and found a number of posts on the NoClassDefFoundError, but none that have a situation with unit testing.
I found the answer. After reviewing this article, I realized that I needed both the jar from project A and the commons-lang-2.6.jar in the test project. Adding BOTH jars to the build path and export resolved the issue.

Use support library in android projects and library (Android Studio)

I'm using the new Android Studio, I'm looking for a way to use the support library from multiple projects. Basically I have a project that uses the ActionBarSherlock this projects requires the support library. So I added a reference as like in this question.
Now I have the problem that my main project also uses the support library so I have it includes twice in some way. If I remove the library from one of both projects I'll get errors that some support library related classes are unknown which is clear for me, but if I have a reference in both projects I'll face this error:
Android Dex: [ProjectName] UNEXPECTED TOP-LEVEL EXCEPTION:
Android Dex: [ProjectName] java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ShareCompat$ShareCompatImplJB;
Android Dex: [ProjectName] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
Android Dex: [ProjectName] at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
Android Dex: [ProjectName] at com.android.dx.command.dexer.Main.processClass(Main.java:490)
Android Dex: [ProjectName] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
...
Any idea how to fix this?
I fixed this by going into File > Project Structure... and selecting Modules then click on the module's Dependencies tab. Then next to the library I changed the scope from Compile to Provided.
This means the module can still use it, but it doesn't reach compile, since I assume you are already using that JAR in your main project.
Hope this helps!
I had a similar issue happen to me. Select actionbarsherlock in the project tab/bar/whatever (on the left, so you can see the project tree). hit F4 to open the module settings.
Make sure that you are not using the same dependencies twice in actionbarsherlock and your project.
Also make sure that you're using the version of the support library that's in the android-studio sdk (android-studio/sdk/extras/android).
Finally, if you're like me, make sure you didn't accidentally make actionbarsherlock dependent on itself, thus loading the library twice THAT way! >.<
Take a look at these images showing my module preferences:
http://imgur.com/a/JupWp
Also, don't forget to make sure libs isn't hiding any of the same ones!
Did this use to be an Eclipse project? If so try going into Eclipse, clean the project, exit, rebuild in IntelliJ. I believe this is a state-issue, not a configuration issue.
Instead of importing android support library as jar, I changed the libraries (in my case facebook sdk) dependencies in build.gradle to:
dependencies {
compile 'com.android.support:support-v4:13.0.0'
}

Categories

Resources