Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building an Android Project from Command Line with Eclipse

I created a "Hello World" Android Project in Eclipse (Indigo) on Windows 7 64-bit. It's using Android SDK 1.6.

It builds from the IDE without any problems.

Now I want to build it from the command line. I found this question: Opening an eclipse project through command prompt or batch file and Headless Building with APT in Eclipse, so I ran this:

C:\inst\Android\eclipse>eclipsec.exe -data "C:\eclipsewsTest1" -application org.
eclipse.jdt.apt.core.aptBuild

What I'm getting is the following:

Building workspace
Building '/And1'
Invoking builder on '/And1'.
Invoking builder on '/And1'.
Invoking 'Java Builder' on '/And1'.
Cleaning output folder for And1
Build done
Invoking builder on '/And1'.

and then a dialog shows this message:

An error has occurred. See the log file C:\eclipsewsTest1\.metadata\.log

This log file contains something like this:

eclipse.buildId=M20110909-1335
java.version=1.7.0_01
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.java.product -application org.eclipse.jdt.apt.core.aptBuild
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product -data C:\eclipsewsTest1 -application org.eclipse.jdt.apt.core.aptBuild

!ENTRY org.eclipse.core.resources 2 10035 2011-12-09 10:50:35.233
!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.

!ENTRY org.eclipse.osgi 4 0 2011-12-09 10:50:35.553
!MESSAGE An error occurred while automatically activating bundle com.android.ide.eclipse.ddms (351).
!STACK 0
org.osgi.framework.BundleException: Exception in com.android.ide.eclipse.ddms.DdmsPlugin.start() of bundle com.android.ide.eclipse.ddms.

Does anybody know what the problem is?

like image 651
abieganski Avatar asked Dec 09 '11 10:12

abieganski


People also ask

Can I develop Android app using Eclipse?

For developing the android application using eclipse IDE, you need to install the Eclipse. you can download it from this location download the Eclipse. Eclipse classic version is recommended but we are using the Eclipse IDE for JavaEE Developers.

What is difference between Eclipse and Android Studio?

Eclipse, the IDE, has a speedier start-up time. It mostly supports Java, but it can also work with other languages such as C, C++, C#, PHP, Perl, and Ruby. Android Studio is an integrated development environment (IDE) for Android operating systems.


1 Answers

# 1. go into you Eclipse project
cd "C:\Users\username\workspace\app"

# 2. create build files (only first time)
"C:\Program Files\Android\android-sdk\tools\android.bat" update project --path .

# 3. Set Java JDK Path
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_25

# 4. Build with "ant debug"
"C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\bin\ant" debug

# 5. Deploy (and replace existing with -r)
"C:\Program Files\Android\android-sdk\platform-tools\adb.exe" 
   install -r "C:\Users\username\workspace\app\bin\appActivity-debug.apk"

# 6. Run it. Look up package and activity name in `AndroidManifest.xml`
"C:\Program Files\Android\android-sdk\platform-tools\adb.exe" 
   shell am start -n <your_package>/<activity_android:name>

# 7. View log.
"C:\Program Files\Android\android-sdk\platform-tools\adb.exe" logcat

Also see this blog and Android help.

like image 167
PiTheNumber Avatar answered Oct 28 '22 16:10

PiTheNumber