从使用:
创建的干净项目开始android create project -n something -t android-7 -p something -k com.example.something -a Something
当我运行ant debug install
并在我的模拟器中打开应用程序时,我看到(正如预期的那样)
这就是它变坏的地方。我现在在应用程序中改变了一些微不足道的东西。在此示例中,我将从主活动中删除setContentView
调用,因此它看起来像这样:
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
}
}
现在我使用ant debug install
重建应用程序并在模拟器中运行它。我明白这一点:
这是错误的。我刚刚删除了之前编辑的文本。如果我在ant clean
之前ant debug install
,我会得到预期的结果:
我不想在每次运行ant clean
之前运行ant debug install
。如何在不运行ant clean
的情况下让ant实际重建程序?
详细信息:
以下是初始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
以下是编辑后第二个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...
-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
请注意,-dex
,-package
和-debug
步骤似乎都认为我没有改变任何内容。
答案 0 :(得分:5)
我刚刚降级到SDK r15 - 其中没有这样的错误。
下载仍然存在:
http://dl.google.com/android/android-sdk_r15-linux.tgz
http://dl.google.com/android/android-sdk_r15-windows.zip
http://dl.google.com/android/installer_r15-windows.exe
http://dl.google.com/android/android-sdk_r15-macosx.zip
android的bugtracker中针对SDK r16 bug最相关的问题:
http://code.google.com/p/android/issues/detail?id=23141
答案 1 :(得分:3)
我在#android-dev中询问过这个问题,显然sdk r16中有一个错误,它会打破步骤:
21:25< PFN>我对sdk r16确实存在问题 21:25< PFN>答案是删除classes.dex和yourapp-debug.apk 在每次蚂蚁调试之前
不幸的是,这个修复似乎不起作用所以我们似乎每次都有一个干净的构建。
答案 2 :(得分:0)
您需要更新测试项目以反映更改,然后执行ant debug安装 1.~ / android-sdks / tools / android update test-project -m ../SampleProject/ -p ../SampleProjectTest/ 2. ant debug install
答案 3 :(得分:0)
以下是适合我的解决方案:
打开终端并编写以下内容 4.关闭Eclipse。
cd /home/user/workspace/.metadata/.plugins
rm -rf org.eclipse.core.resources