Skip to main content

Android: "Unable to execute dex: Multiple dex files define"

Solution

1) This is a build path issue. Make sure your bin folder is not included in your build path. Right click on your project, go to properties and then Build Path. Make sure that Honeycomb library is in your libs/ folder and not in your source folder. Include the libraries in libs/ individually in the build path. BTW, you may want to bring in the android-support-v4 library to get Ice Cream Sandwich support instead of the Honeycomb support library.
2) The reason was that the support library was referenced by two library projects used by my app project but with different versions.
In more details: My app depends on 2 library projects
  • FaceBookSDK 3.0 -> which is referencing android-support-v4
  • ActionBarSherlock -> which is referencing android-support-v4 but with a modified version to support maps.
To solve the problem I had to make FaceBookSDK library depend on ABS library instead of the support library directly. 
3) If some of you facing this problem with facebook-connent-plugin for phonegap try to remove files in bin/class/com/facebook/android directory ! -> and rebuild
4) The Solution for me was just to do following things:
  1. ->lib directory in your project and delete any multiple elements.
  2. Project->Properties->Java build Path and delete any Dependency Library was added automatically and not by you! ->Apply
  3. Restart Eclipse IDE
  4. Now Clean the project.
  5. Run/Debug on Device/Emulator the project ... 
Good Luck

Comments

Popular posts from this blog

Fragment: App loads with white screen for 3 secs before showing proper UI

Issue: 1) When my application start then white/black screen appears, and then main UI is display.  2) Before my fragment load in activity black/white screen appears for 3/4 seconds and then fragment load. Solution: To fix this nasty problem, update the /res/values/styles.xml to include <item name="android:windowDisablePreview">true</item> or <item name="android:windowBackground">@android:color/black</item> for example : <!-- Application theme. -->  <style name="AppTheme" parent="AppBaseTheme">  <!-- All customizations that are NOT specific to a particular API-level can go here. -->  <item name="android:windowDisablePreview">true</item>  <!-- <item name="android:windowBackground">@android:color/black</item> -->  </style>

Error: Retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23

My project is going on easily but suddenly what I found below bugs when developing an app. I know it's minor bug but it may be useful to anyone. Here is the error: Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'. Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'. Solution: This happens because after updates your android studio uses API 23 by default. 1) First check that your compile SDK version must match the support library's major version. If you are using version 23 of the support library, you need to compile against version 23 of the Android SDK. Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22.   2) Go to your project structure -> Properties -> and change Build tool version to...

Android: Check whether activity is in stack or not.

Solution There's possibility to check current tasks and their stack using ActivityManager . So, to determine if an activity is the last one: request android.permission.GET_TASKS permissions in the manifest. Use the following code: ActivityManager mngr = (ActivityManager) getSystemService( ACTIVITY_SERVICE );  List<ActivityManager.RunningTaskInfo> taskList = mngr.getRunningTasks(10); if(taskList.get(0).numActivities == 1 && taskList.get(0).topActivity.getClassName().equals(this.getClass().getName())) {             Log.i(TAG, "This is last activity in the stack");  }