partire con un progetto pulito creata con:Ant non ricostruire applicazione Android con `debug formica install`
android create project -n something -t android-7 -p something -k com.example.something -a Something
Quando eseguo ant debug install
e aprire l'applicazione nel mio emulatore, vedo (come previsto)
Ecco dove va male. Ora cambio qualcosa di banale nell'applicazione. In questo esempio, ho intenzione di rimuovere la chiamata setContentView
dalla principale attività in modo che appaia simile al seguente:
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
}
}
Ora ricostruire l'applicazione con ant debug install
ed eseguirlo nell'emulatore. Vedo questo:
Questo è sbagliato. Ho appena rimosso il testo con la mia modifica precedente. Se faccio ant clean
prima ant debug install
, ottengo il risultato atteso:
Io non voglio avere a correre ant clean
prima di ogni volta che faccio funzionare ant debug install
. Come posso fare in modo che la form ricostruisca il programma senza eseguire ant clean
ogni volta?
Dettagli:
Ecco l'output del 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
Ecco l'uscita dal secondo ant debug install
dopo l'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
Si noti che i passi -dex
, -package
e -debug
sembrano tutti pensare che non ho cambiato nulla.
Esattamente lo stesso problema qui da quando sono passato a un nuovo computer portatile, cercando di capire che cosa è diversa .. Utilizzando SDK r16 con ant 1.8.2. – brk3
Qualcuno ha provato se questo si verifica ancora con l'ultimo aggiornamento r17? – brk3
Secondo bugtracker, è stato corretto nella nuova r17 http://code.google.com/p/android/issues/detail?id=22948 – HighCat