0

I've created a Maven project with an Android archetype in Eclipse several months ago. Since then I have been able to build and deploy my app directly from Eclipse, and I also believed Maven install to be working (I usually got BUILD SUCCESS). However, I just realized a few days ago that this "success" doesn't mean much - I tried deploying the apk I got after building with Maven to my phone (via the terminal), and the app immediately crashed. I noticed that during the build, I get a bunch of "Dx bad class file magic (cafebabe) or version (0033.0000)" errors, so I figured there was some problem with the compiler - using 6 instead of 7 or vice versa. While trying a bunch of solutions I found online, I also updated my SDK tools, which then caused Eclipse to tell me that I had to update to version 23, as I was working with 22.6. However, I was unable to update the IDE, as I got "conflicting dependencies" error. In the meantime I also read all over the the new version had a lot of bugs, so I tried going back, but by now my tools folder was missing from the sdk folder, and nothing worked. This is also when I was no longer able to run the app from Eclipse - I could build it, but trying to run it on my phone resulted in the following error:

08-25 15:15:39.965: E/AndroidRuntime(23081): java.lang.RuntimeException: Unable
to instantiate activity ComponentInfo{me.comocomo.nutrino/me.comocomo.nutrino.
MainActivity}: java.lang.ClassNotFoundException: Didn't find class "me.comocomo.
nutrino.MainActivity" on path: DexPathList[[zip file "/data/app/me.comocomo.
nutrino-9.nativeLibraryDirectories=[/data/app-lib/me.comocomo.nutrino-9,
/vendor/lib, /system/lib]]

At this point I gave up and downloaded a new version of Eclipse, more accurately the ADT Bundle. This didn't go entirely smoothly either, as I had some issues installing the SVN and Maven plugins. Therefore, I tried working with the Android Studio; this required me to export my original project as a Gradle project. I'm not sure the export-import process was entirely successful, but I decided to put it on hold and try to resolve the Eclipse issue again.

Anyway, to make a long story so much longer, I am now at the point where I have a working Eclipse (sort of - it still hangs every other time when I try opening it, and then I have to delete the org.eclipse.e4.workbench plugin xml file), specifically the newer version I have downloaded. I can build my app in Eclipse (Maven install fails), but I can't run it. However, deploying the apk in the terminal works, and my app loads.

What I'm trying to figure out now is:

  1. How can I get rid of the ClassNotFoundException when running the app in Eclipse? I'm thinking it has something to do with the classpath file, but a) this is just a hunch and b) I have no idea what exactly the problem is.
  2. How can I get the Maven install to work? At the moment, the build fails - I will attach the error at the end.
  3. Even when the Maven install succeeded before, I got the "Dx bad class file magic.." warnings, and these dependencies were skipped. What can I do in order to get these files to be built (these are server classes that were build using the 1.7 compiler, and as far as I know, they can't be build with 1.6)?

This is the Maven error I am currently getting:

[ERROR] Failed to execute goal on project NutrinoAndroid: Could not resolve
dependencies for project me.comocomo.nutrino:NutrinoAndroid:apk:alpha: Failed to
collect dependencies for [com.google.android:android:jar:4.1.1.4 (provided),
com.google.android.support:android-support-v4:jar:4 (compile),
com.google.android.support:android-support-v7-appcompat:jar:4 (compile),
android.support:compatibility-v7-appcompat:apklib:19.0.1 (compile),
android.support:compatibility-v7-appcompat:jar:19.0.1 (compile),
me.comocomo.nutrino:nutrino-api:jar:0.0.1-SNAPSHOT (compile),
com.octo.android.robospice:robospice-google-http-client:jar:1.4.12 (compile),
com.octo.android.robospice:robospice:jar:1.4.12 (compile),
commons-logging:commons-logging:jar:1.1.1 (provided),
com.google.http-client:google-http-client-jackson2:jar:1.18.0-rc (compile),
joda-time:joda-time:jar:2.3 (compile), org.quartz-scheduler:quartz:jar:2.2.1
(compile), org.quartz-scheduler:quartz-jobs:jar:2.2.1 (compile)]: Failed to read
artifact descriptor for java-activation-framework:jaf:jar:1.1.1: Could not
transfer artifact java-activation-framework:jaf:pom:1.1.1 from/to central
(http://repo.maven.apache.org/maven2): java.io.IOException: Remotely Closed [id:
0x33cfa965, /10.100.101.106:65051 :> repo.maven.apache.org/23.235.43.215:80] ->
[Help 1]

I don't want to just pile all of my code and configuration files here, so if there's anything more required - let me know and I'll add it.

Thanks

Edit

My manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="me.comocomo.nutrino"
android:versionCode="10"
android:versionName="alpha" >

<uses-permission android:name="android.permission.INTERNET" />

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="19" />
<!-- android:minSdkVersion="11" -->

<application
    android:allowBackup="true"
    android:icon="@drawable/planbtn"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppCompat.Light" >
    <service
        android:name="com.octo.android.robospice.JacksonGoogleHttpClientSpiceService"
        android:exported="false" />

    <activity
        android:name="me.comocomo.nutrino.MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Login.LoginActivity"
        android:label="@string/title_activity_login"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Goals.GoalsSignupActivity"
        android:label="@string/title_activity_goals_signup"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Login.SignUp.EmailSignUpActivity"
        android:label="@string/title_activity_email_sign_up"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.Translucent"
        android:windowSoftInputMode="stateVisible" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Goals.GoalInfoActivity"
        android:label="@string/title_activity_goal_info"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Goals.GoalsTargetWeightFragment"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Goals.GoalsDevicesAppsConnectFragment"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Goals.GoalsPhysiqueLifestyleActivity"
        android:label="@string/title_activity_goals_physique_lifestyle"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Goals.ActivityLevelActivity"
        android:label="@string/title_activity_activity_level"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Goals.ReduceFatActivity"
        android:label="@string/title_activity_reduce_fat"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.DiaryItemTypes.NonFood.LogDrinkActivity"
        android:label="@string/title_activity_log_water"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.DiaryItemTypes.NonFood.LogSleepActivity"
        android:label="@string/title_activity_log_sleep"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.DiaryItemTypes.NonFood.LogMeasurementsActivity"
        android:label="@string/title_activity_log_measurements"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.DiaryItemTypes.NonFood.LogFeelingActivity"
        android:label="@string/title_activity_log_measurements"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.DiaryItemTypes.Util.SelectMealsActivity"
        android:label="@string/title_activity_select_meals"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.DiaryItemTypes.Util.RateNutrinoActivity"
        android:label="@string/title_activity_rate_nutrino"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.DishBreakdownActivity"
        android:label="@string/title_activity_meal_breakdown"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Goals.BasicDetailsActivity"
        android:label="@string/title_activity_basic_details"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.ChooseAlternativeActivity"
        android:label="@string/title_activity_choose_alternative"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.RecipeActivity"
        android:label="@string/title_activity_recipe"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.RateDishActivity"
        android:label="@string/title_activity_rate_dish"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.MealBreakdownActivity"
        android:label="@string/title_activity_meal_breakdown"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.DailyBreakdownActivity"
        android:label="@string/title_activity_daily_breakdown"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Profile.MyProfileActivity"
        android:label="@string/title_activity_my_profile"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.ConnectionProblemActivity"
        android:label="@string/title_activity_connection_problem"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Profile.BodyActivity"
        android:label="@string/title_activity_body"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Profile.FoodAllergiesActivity"
        android:label="@string/title_activity_food_allergies" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Profile.ConnectActivity"
        android:label="@string/title_activity_connect" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Profile.SettingsActivity"
        android:label="@string/title_activity_settings" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Profile.SetProfileActivity"
        android:label="@string/title_activity_set_profile" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.TasteActivity"
        android:label="@string/title_activity_taste" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.EditGoalsActivity"
        android:label="@string/title_activity_edit_goals" >
    </activity>
    <activity
        android:name="me.comocomo.nutrino.Diary.PinMealActivity"
        android:label="@string/title_activity_pin_meal" >
    </activity>
</application>

And my pom:

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 me.comocomo.nutrino NutrinoAndroid alpha apk NutrinoAndroid

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <platform.version> 4.1.1.4
    </platform.version>
    <android.plugin.version>3.5.3</android.plugin.version>
    <src.dir>src</src.dir>
</properties>
<repositories>
    <repository>
        <id>snapshot-repository.java.net</id>
        <name>Java.net Snapshot Repository for Maven</name>
        <url>https://maven.java.net/content/repositories/snapshots/</url>
        <layout>default</layout>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>${platform.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.android.support</groupId>
        <artifactId>android-support-v4</artifactId>
        <version>4</version>
    </dependency>
    <dependency>
        <groupId>com.google.android.support</groupId>
        <artifactId>android-support-v7-appcompat</artifactId>
        <version>4</version>
    </dependency>
    <dependency>
        <groupId>android.support</groupId>
        <artifactId>compatibility-v7-appcompat</artifactId>
        <version>19.0.1</version>
        <type>apklib</type>
    </dependency>
    <dependency>
        <groupId>android.support</groupId>
        <artifactId>compatibility-v7-appcompat</artifactId>
        <version>19.0.1</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>me.comocomo.nutrino</groupId>
        <artifactId>nutrino-api</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <exclusions>
            <exclusion>
                <artifactId>activation</artifactId>
                <groupId>javax.activation</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> 
        <version>2.7</version> </dependency> -->
    <dependency>
        <groupId>com.octo.android.robospice</groupId>
        <artifactId>robospice-google-http-client</artifactId>
        <version>1.4.12</version>
        <exclusions>
            <exclusion>
                <artifactId>commons-logging</artifactId>
                <groupId>commons-logging</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.octo.android.robospice</groupId>
        <artifactId>robospice</artifactId>
        <version>1.4.12</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.http-client</groupId>
        <artifactId>google-http-client-jackson2</artifactId>
        <version>1.18.0-rc</version>
    </dependency>
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>org.quartz-scheduler</groupId>
        <artifactId>quartz</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.quartz-scheduler</groupId>
        <artifactId>quartz-jobs</artifactId>
        <version>2.2.1</version>
    </dependency>
</dependencies>
<build>
    <sourceDirectory>${src.dir}</sourceDirectory>
    <finalName>${project.artifactId}</finalName>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>${android.plugin.version}</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <sdk>
                    <platform>16</platform>
                </sdk>
            </configuration>
        </plugin>
    </plugins>
</build>

Mor
  • 47
  • 3
  • Have you added MainActivity.java in manifest file?. Please show manifest file. – MysticMagicϡ Aug 25 '14 at 12:49
  • your launcher is FragmentActivity? – Arash GM Aug 25 '14 at 12:50
  • http://stackoverflow.com/questions/10610564/android-with-maven-apk-unknown – Opiatefuchs Aug 25 '14 at 13:08
  • @Dhruti Yeah, it's in the manifest. I'll add the manifest in a second. – Mor Aug 25 '14 at 14:08
  • @Arash It's an ActionBarActivity. – Mor Aug 25 '14 at 14:11
  • @Opiatefuchs Not sure which part of the question you are referring to, but I tried both the accepted answer and also changing the maven plugin version to 3.6.0 (currently ${android.plugin.version}) - neither worked. – Mor Aug 25 '14 at 14:12
  • Can you post your POM? – Ricardo Gladwell Aug 25 '14 at 15:36
  • Hey @RicardoGladwell, just added my pom to the question. – Mor Aug 26 '14 at 06:17
  • Have you Mavenised the compat APKLIB libraries like `compatibility-v7-appcompat` in your local Eclipse workspace? – Ricardo Gladwell Aug 26 '14 at 10:49
  • @RicardoGladwell I don't think that I have. Should I just right click the appcompat project I'm using and "Convert to Maven Project"? I'm only using this project locally, because for some reason I have to use a library project. I also exported it and uploaded it to our artifactory, which is what I was trying to use as Maven dependencies. – Mor Aug 26 '14 at 11:13
  • See the answer here: http://stackoverflow.com/questions/25343987/android-maven-project-in-eclipse-with-apklib/25426885#25426885 – Ricardo Gladwell Aug 26 '14 at 11:21
  • OK, @RicardoGladwell, I tried mavenizing the support project, but now when I do Maven -> Update Project on my original project, I get this: "error configuring project -- un-recognised maven-android project type". I guess I didn't convert the other project correctly? I selected "Convert to Maven Project" and set the groupId to be android.support, artifactId to be compatibility-v7-appcompat and version 19.0.1, as is the apk-type dependency in my pom. What am I missing? – Mor Aug 26 '14 at 11:59
  • Are you matching the coordinates correctly? For example, you say you set the type as "apk" when in your POM its listed as "apklib". – Ricardo Gladwell Aug 26 '14 at 13:21
  • @RicardoGladwell I'm not sure - the groupId, artifactId and version are the same; but I don't know where to set the type. If can't put it in the appcompat project, as the tag is unrecognized when I run Maven install. At the moment, I pretty much gave up on my original project and created and new Maven project with Android archetype; I put the appcompat project as two dependencies in the pom file, one of type apklib and the other jar, as was with my previous project, but Maven install fails. As for the Eclipse build, it doesn't work unless I add the local appcompat project as a library project. – Mor Aug 27 '14 at 08:43

0 Answers0