我几个月前在Eclipse中创建了一个带有Android原型的Maven项目。从那时起,我已经能够直接从Eclipse构建和部署我的应用程序,我也相信Maven安装工作(我通常有BUILD SUCCESS)。但是,我刚才意识到这个"成功"并不意味着什么 - 我尝试部署我使用Maven构建到手机后通过终端获得的apk,应用程序立即崩溃。我注意到在构建期间,我得到了一堆" Dx坏类文件魔法(cafebabe)或版本(0033.0000)"错误,所以我认为编译器存在一些问题 - 使用6而不是7,反之亦然。 在尝试在网上找到的一堆解决方案时,我还更新了我的SDK工具,然后导致Eclipse告诉我必须更新到版本23,因为我正在使用22.6。但是,我无法更新IDE,因为我得到了相互冲突的依赖关系"错误。与此同时我也阅读了所有新版本都有很多错误,所以我试着回去,但是现在我的工具文件夹在sdk文件夹中丢失了,没有任何效果。这也是当我不再能够从Eclipse运行应用程序时 - 我可以构建它,但是尝试在我的手机上运行它会导致以下错误:
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]]
此时我放弃并下载了新版本的Eclipse,更准确地说是ADT Bundle。这也没有完全顺利,因为我在安装SVN和Maven插件时遇到了一些问题。因此,我尝试使用Android Studio;这要求我将原始项目导出为Gradle项目。我不确定导出过程是否完全成功,但我决定暂时搁置并尝试再次解决Eclipse问题。
无论如何,要长篇大论,我现在处于一个工作Eclipse的地方(有点 - 当我尝试打开它时它仍然会挂起,然后我必须删除组织.eclipse.e4.workbench插件xml文件),特别是我下载的较新版本。我可以在Eclipse中构建我的应用程序(Maven安装失败),但我无法运行它。但是,在终端中部署apk可以正常工作,我的应用程序也会加载。
我现在要弄清楚的是:
这是我目前得到的Maven错误:
[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]
我不想在这里填写所有代码和配置文件,所以如果还有其他需要 - 请告诉我,我会添加它。
由于
修改
我的清单:
<?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>
我的pom:
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 me.comocomo.nutrino NutrinoAndroid α 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>