1

I've got one issue with Eclipse.

There is an android project configured with Maven. Here is pom.xml from child project (all versioning configuration was moved o parent pom.xml):

<dependency>
    <groupId>android.support</groupId>
    <artifactId>compatibility-v4</artifactId>
</dependency>
<dependency>
    <groupId>android.support</groupId>
    <artifactId>compatibility-v7-appcompat</artifactId>
         <type>apklib</type>
</dependency>
<dependency>
     <groupId>android.support</groupId>
     <artifactId>compatibility-v7-appcompat</artifactId>
         <type>jar</type>
</dependency>

Also there is mavenised compatibility-v7-appcompat project imported into workspace as a Library. This project was copied into workspace (because there is an issue with libraries on other locations) and imported to my maven project (Properties -> Android -> Libraries).

I've got one Activity.

public class HelloActivity extends ActionBarActivity

Now I've got an error when i try to debug application:

01-02 13:36:22.753: E/AndroidRuntime(11867): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{somepackage.android/somepackage.android.hello.activities.HelloActivity}:
java.lang.ClassNotFoundException: somepackage.android.hello.activities.HelloActivity in loader dalvik.system.PathClassLoader[/data/app/somepackage.android-2.apk]

I tried everything from other questions. Order & Export in Build Path in both projects and still nothing (Adding libraries with resources Using Eclipse from here: http://developer.android.com/tools/support-library/setup.html)

When I change it to

public class HelloActivity extends FragmentActivity

It works properly, even if I leave AppCompat style in AndroidManifest:

<activity
    android:name="somepackage.android.hello.activities.HelloActivity"
    android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
    android:windowSoftInputMode="stateHidden|adjustResize" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

What is more, I get an error when app is loaded on device:

[2014-01-02 13:36:19 - compatibility-v7-appcompat] Could not find compatibility-v7-appcompat.apk!

Even thought this project has "Is Library" checkbox set in android properties.

This is how the project looks like: project

I would appreciate help :)

Marian Przyszedł
  • 699
  • 1
  • 9
  • 19
  • Can you please provide me more details about the solution with this issue. I have the same configuration as yours, but still getting the Multiple dex files... Did you used the https://github.com/mosabua/maven-android-sdk-deployer ? – thekadrik Feb 26 '14 at 16:53
  • Yes, I did. Look at last answer here. There are instructions how to fix this problem. If it doesn't work for You, please write more details... – Marian Przyszedł Feb 27 '14 at 10:33

2 Answers2

0

Check whether the package is selected under java build path->order/export. If its not select then select. if a library is not select under this list there will no error at build time. when run the project specific package will not exported with that project this will cause ClassNotFoundException

CoolMonster
  • 2,258
  • 25
  • 50
  • OK, right now I've got new error while building: `[2014-01-02 14:03:11 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; [2014-01-02 14:03:11 - es-base-app] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;` Is the problem because compatibility-v7-appcompat exports v4, and my project has v4 in maven dependency? How to solve it? – Marian Przyszedł Jan 02 '14 at 13:03
  • can u please clean the bin folder and try to build once again. but i am not sure about this problem but i facing this problem while build the app for distribution to app store. may be a bug in eclipse. – CoolMonster Jan 02 '14 at 13:09
0

Thanks to CoolMonster I resolved it by doing like this:

  • In mavenised compatibility-v7-appcompat project
    • Project -> Properties -> Order and Export -> select only android-support-v7-appcompat.jar
  • In my project
    • Project -> Properties -> Order and Export -> select Maven Dependencies, Android Private Libraries and Android Dependencies.
Marian Przyszedł
  • 699
  • 1
  • 9
  • 19
  • Go to: **Java Build Path -> Order and Export** select and **put in order** on the top of the list: Android Private Libraries, Android Dependencies, Maven Dependencies. – Marian Przyszedł Feb 27 '14 at 10:33