Android第二天--基于Snake的示例建立和运行程序 delin17发表于-2012-2-7 14:36:00

第一步:简单创建工程;File->NewProject->Other跳出对话框,选择Android后,Next。选择Create Project from existing sourc. 然后选择SDK下Sample下对应的Snake目录。然后点Next到完成。

第二步:创建AVD(Android Virtual Device)。windows->AVD Manager。跳出对话框后添加,然后在中间选择相应的选项来对应你将来真实的产品。完成后点击Create AVD.这个需要一定的时间。注意:系统默认AVD是存放在C:\Documents and Settings\WindowsUserName\.android下面。如需要修改:请在windows中添加环境变量:ANDROID_SDK_HOME = 你要保存的目录。

第三步:运行配置参数。Run->Run configuration->Run/Debug Configuration会跳出一个对话框。根据自己的需要对其进行配置。

第四步:运行程序。 注意运行和启动模拟器的时间有点长,在我机器上感觉是这样。我在运行程序中遇到两个问题。

1 提示API版本不对。

问题原因是在AndroidManifest.xml中没有对版本定义。请通过eclipse将Min SDk version改成你对应的Version就好了,另也可以通过编辑这个文件来实现:在文件中添加下一行。添加在application对的前面。

<uses-sdk android:minSdkVersion="15"/> 15为我所对应的版本号

我修改后整个文件如下:

<!-- Declare the contents of this Android application. The namespace
attribute brings in the Android platform namespace, and the package
supplies a unique name for the application. When writing your
own application, the package name must be changed from "com.example.*"
to come from a domain that you own or have control over. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.snake">
<uses-sdk android:minSdkVersion="15"/>
<application android:label="Snake on a Phone">
<activity android:name="Snake"
android:theme="@android:style/Theme.NoTitleBar"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

2: 由于先前版本不对,导致安装未完全,修改好后没有办法再安装同一个apk。需要将先前的完全卸载。于是需要进入shell模式。怎么进入shell。我在模拟上没有找到。我是这样实现的:在windows的命令行中转入到android SDK对应的目录下运行相应的可执行文件。例如运行adb devices可以查询到模拟器。adb uninstall 应用程序(adb uninstall com.example.android.snake) 可以删除模拟器中的应用程序。注意:这些操作都必须在模拟器运行时才有效。

更多相关文章

  1. [Android]实现静默安装APK的两种方法
  2. Android开发1――查找所需要出示权限的内容
  3. html移动应用开发技术分享
  4. [Android]实现静默安装APK的两种方法
  5. android平台下UITesting环境配置
  6. Android应用程序通过JNI控制LED
  7. Android上的单元测试
  8. Android开发1――查找所需要出示权限的内容
  9. android 使用代码方式创建自定义progressBar——自定义控件学习(

随机推荐

  1. Android使用Json和ksoap2调用WebService(
  2. Android中EditText光标在4.0中的bug及解
  3. Android显示原理
  4. Android(安卓)模拟器
  5. 开发随笔-移动开发小结
  6. Android中ListView通过ContextMenu删除当
  7. 关于lottie的那点事
  8. Android之Picasso
  9. 如何成功运行和导入别人的android studio
  10. android 隐藏手机底部虚拟按键