Skip to main content

Ant not rebuilding Android application with `ant debug install`



Starting with a clean project created with:







android create project -n something -t android-7 -p something -k com.example.something -a Something







When I run ant debug install and open the application in my emulator, I see (as expected)





Emulator screenshot from initial build





Here's where it goes bad. I now change something trivial in the application. In this example, I'm going to remove the setContentView call from the main activity so it looks like this:







package com.example.something;

import android.app.Activity;

import android.os.Bundle;

public class Something extends Activity {

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

//setContentView(R.layout.main); REMOVED

}

}







Now I rebuild the application with ant debug install and run it in the emulator. I see this:





Emulator screenshot after rebuild





This is wrong. I just removed the text with my previous edit. If I do ant clean before ant debug install , I get the expected result:





Expected result after rebuild





I don't want to have to run ant clean before each time I run ant debug install . How can I make ant actually rebuild the program without running ant clean each time?








Details:





Here's the output from the inital ant debug install :







$ ant debug install

Buildfile: /home/x/android/something/build.xml



-set-mode-check:



-set-debug-files:



-set-debug-mode:



-debug-obfuscation-check:



-setup:

[echo] Gathering info for something...

[setup] Android SDK Tools Revision 16

[setup] Project Target: Android 2.1

[setup] API level: 7

[setup]

[setup] ------------------

[setup] Resolving library dependencies:

[setup] No library dependencies.

[setup]

[setup] ------------------

[setup]

[setup] WARNING: No minSdkVersion value set. Application will install on all Android versions.



-build-setup:

[echo] Creating output directories if needed...

[mkdir] Created dir: /home/x/android/something/bin

[mkdir] Created dir: /home/x/android/something/bin/res

[mkdir] Created dir: /home/x/android/something/gen

[mkdir] Created dir: /home/x/android/something/bin/classes



-pre-build:



-code-gen:

[echo] ----------

[echo] Handling aidl files...

[aidl] No AIDL files to compile.

[echo] ----------

[echo] Handling RenderScript files...

[renderscript] No RenderScript files to compile.

[echo] ----------

[echo] Handling Resources...

[aapt] Generating resource IDs...



-pre-compile:



-compile:

[javac] Compiling 2 source files to /home/x/android/something/bin/classes



-post-compile:



-obfuscate:



-dex:

[dex] Converting compiled files and external libraries into /home/x/android/something/bin/classes.dex...



-crunch:

[crunch] Crunching PNG Files in source dir: /home/x/android/something/res

[crunch] To destination dir: /home/x/android/something/bin/res

[crunch] Crunched 0 PNG files to update cache



-package-resources:

[aapt] Creating full resource package...



-package:

[apkbuilder] Current build type is different than previous build: forced apkbuilder run.

[apkbuilder] Creating something-debug-unaligned.apk and signing it with a debug key...



-do-debug:

[zipalign] Running zip align on final apk...

[echo] Debug Package: /home/x/android/something/bin/something-debug.apk



debug:

[propertyfile] Creating new property file: /home/x/android/something/bin/build.prop

[propertyfile] Updating property file: /home/x/android/something/bin/build.prop

[propertyfile] Updating property file: /home/x/android/something/bin/build.prop

[propertyfile] Updating property file: /home/x/android/something/bin/build.prop



install:

[echo] Installing /home/x/android/something/bin/something-debug.apk onto default emulator or device...

[exec] 66 KB/s (4410 bytes in 0.065s)

[exec] pkg: /data/local/tmp/something-debug.apk

[exec] Success



BUILD SUCCESSFUL

Total time: 5 seconds







Here's the output from the second ant debug install after the edit:







$ ant debug install

Buildfile: /home/x/android/something/build.xml



-set-mode-check:



-set-debug-files:



-set-debug-mode:



-debug-obfuscation-check:



-setup:

[echo] Gathering info for something...

[setup] Android SDK Tools Revision 16

[setup] Project Target: Android 2.1

[setup] API level: 7

[setup]

[setup] ------------------

[setup] Resolving library dependencies:

[setup] No library dependencies.

[setup]

[setup] ------------------

[setup]

[setup] WARNING: No minSdkVersion value set. Application will install on all Android versions.



-build-setup:

[echo] Creating output directories if needed...



-pre-build:



-code-gen:

[echo] ----------

[echo] Handling aidl files...

[aidl] No AIDL files to compile.

[echo] ----------

[echo] Handling RenderScript files...

[renderscript] No RenderScript files to compile.

[echo] ----------

[echo] Handling Resources...

[aapt] No changed resources. R.java and Manifest.java untouched.



-pre-compile:



-compile:

[javac] Compiling 1 source file to /home/x/android/something/bin/classes



-post-compile:



-obfuscate:



-dex:

[dex] No new compiled code. No need to convert bytecode to dalvik format.



-crunch:

[crunch] Crunching PNG Files in source dir: /home/x/android/something/res

[crunch] To destination dir: /home/x/android/something/bin/res

[crunch] Crunched 0 PNG files to update cache



-package-resources:

[aapt] No changed resources or assets. something.ap_ remains untouched



-package:

[apkbuilder] No changes. No need to create apk.



-do-debug:

[zipalign] No changes. No need to run zip-align on the apk.

[echo] Debug Package: /home/x/android/something/bin/something-debug.apk



debug:

[propertyfile] Updating property file: /home/x/android/something/bin/build.prop

[propertyfile] Updating property file: /home/x/android/something/bin/build.prop

[propertyfile] Updating property file: /home/x/android/something/bin/build.prop

[propertyfile] Updating property file: /home/x/android/something/bin/build.prop



install:

[echo] Installing /home/x/android/something/bin/something-debug.apk onto default emulator or device...

[exec] 88 KB/s (4410 bytes in 0.048s)

[exec] pkg: /data/local/tmp/something-debug.apk

[exec] Success



BUILD SUCCESSFUL

Total time: 3 seconds







Notice that the -dex , -package , and -debug steps all seem to think that I didn't change anything.



Source: Tips4all

Comments

  1. I was asking about this in #android-dev, apparently there is a bug in sdk r16 which breaks the and steps:

    21:25 < pfn> I have that exact problem with sdk r16
    21:25 < pfn> the answer is to delete classes.dex and yourapp-debug.apk
    before every ant debug

    Unfortunately this fix doesn't seem to work so it seems we're stuck with having a clean build each time.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.