Call "Maven Project Builder" in Eclipse at startup as & # 8594; Android application (or manually)

Setting up Android to develop an environment using Eclipse and Maven

I am working on an Android project with Maven as a build tool and am now playing with the configuration of Eclipse, Android ADT, m2eclipse, Maven Android Plugin, Maven Integration for Android Development Tools and Subclipse, but cannot make it work acceptable. That is, the build time is too long or the project does not rebuild and is not deployed on the emulator, as it should be.

Current configuration status

At the moment, I have done something like the following with the result described below:

  • Eclipse Galileo (3.5.2) is installed from the default repositories of Ubuntu 11.04.
  • Installed the Eclipse plugins mentioned above and the Android SDK.
  • Imported project via Check out Maven Projects from SCM.
  • Disable all project builders except Maven Project Builder.
  • Make sure Build Automatically is checked.

File save

Maven Project Builder is called and launched:

  •   aapt [package, -m, -J, ... / application / target / generated-sources / r, -M, ... / application / AndroidManifest.xml, -S, ... / application / target / generated- sources / combined-resources / res, -A, ... / application / assets, -I, ... / android-7 / android.jar] 
  •   dx [--dex, --output = ... / application / target / classes.dex, ... / application / target / android-classes] 
  •   aapt [package, -f, -M, ... / application / AndroidManifest.xml, -S, ... / application / target / generated-sources / combined-resources / res, -A, ... / application / target / generated-sources / combined-assets / assets, -I, ... / android-7 / android.jar, -F, ... / target / xxx-android-project-1.0-SNAPSHOT.ap_] 

Time: ~ 15 seconds, during which:

  • Eclipse is blocked for subsequent user operations, such as Save.
  • One processor core is busy and the system becomes sluggish.

On Run As โ†’ Android Application

The application is installed and running correctly for ~ 10 seconds.

Exit to the console (Android):

  Android Launch!
 adb is running normally.
 Performing com.xxx.android.activity.LoginActivity activity launch
 Automatic Target Mode: Preferred AVD 'xxx_test_device' is available on emulator 'emulator-5554'
 Uploading xxx-android-project.apk onto device 'emulator-5554'
 Installing xxx-android-project.apk ...
 Success!
 Starting activity com.xxx.android.activity.LoginActivity on device emulator-5554
 ActivityManager: Starting: Intent {act = android.intent.action.MAIN cat = [android.intent.category.LAUNCHER] cmp = com.xxx.android / .activity.LoginActivity}

What i would like to do

File save

Only the saved file should be compiled and placed in the configured output folder, instantly quickly.

On Run As โ†’ Android Application

  • Maven Project Builder is called, which runs the lengthy aapt and dx process that is currently running for each file save.
  • The application is installed and running on the emulator.

Questions

  • How to achieve what is described above?
  • Is it possible to start Maven Project Builder just before launching As โ†’ Android Application, but not every time the file is saved? How?

Other approaches

I tried to disable Build Automatically, enable all Builders, and then run Project โ†’ Build Project in the project in question, but then nothing happens, and when I do Run As โ†’ Android Application, there are no code changes.

I tried disabling Maven Project Builder and turning on all other Builders, turning on Build Automatically, but after saving the file, I see this in the console (Android):

Refreshing resource folders. Starting incremental Pre Compiler: Checking resource changes. Nothing to pre compile! Starting incremental Package build: Checking resource changes. Starting full Post Compiler. Refreshing resource folders. Starting incremental Pre Compiler: Checking resource changes. Nothing to pre compile! 

And in Run As -> Android Application the application crashes with this error:

 java.lang.RuntimeException: Unable to instantiate application com.xxx.android.XXXApplication: java.lang.ClassNotFoundException: com.xxx.android.XXXApplication in loader dalvik.system.PathClassLoader@44bfe130 

Related Questions

Android compilation is slow (using Eclipse).

Explains why the dx process is so long and suggests using Ant from the command line to build manually and only if necessary. I actually tried this, but couldn't get it to work with Maven dependencies, even when copying all JAR dependencies to libs/ using the Maven plugin.

For a maven project in eclipse, can I configure the Project / Clean menu item to call mvn clean?

Explains how to run specific goals after clearing a project through Eclipse, but I would not want to clear the project before each installation on the emulator.

TL DR

I would like Eclipse to start aapt and dx processes through Maven Project Builder only when I launch as โ†’ Android application, and not when saving the file. Then the application should be running in the emulator.

+4
source share
2 answers

Go to Gradle and Gradle-enabled IDEs like IntelliJ or Android Studio.

0
source

The new version of Maven Integration for Android Development Tools, which is faster and, I hope, will solve some of your problems, will appear next week or so.

+1
source

All Articles