1、打開Eclipse,選擇File->new->Android Project,如附圖所示窗口:
2、選擇Create project from existing source單選框,然後點擊->Browse..., 找到想要查看的android例子目錄:
備註:一般android例子位於android的SDK安裝目錄中的samples下面的各個android版本目錄,例如:android-sdk-windows/samples/android-8
3、選擇好後,工程名和android開發版本都會自動選擇上,點擊 finish,即可;
常見問題:
錯誤信息:
[2011-04-22 16:26:16 - Home] ------------------------------
[2011-04-22 16:26:16 - Home] Android Launch!
[2011-04-22 16:26:16 - Home] adb is running normally.
[2011-04-22 16:26:16 - Home] No Launcher activity found!
[2011-04-22 16:26:16 - Home] The launch will only sync the application package on the device!
[2011-04-22 16:26:16 - Home] Performing sync
[2011-04-22 16:26:16 - Home] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'android1'
[2011-04-22 16:26:16 - Home] WARNING: Application does not specify an API level requirement!
[2011-04-22 16:26:16 - Home] Device API version is 8 (Android 2.2)
[2011-04-22 16:26:20 - Home] Application already deployed. No need to reinstall.
[2011-04-22 16:26:20 - Home] /Home/bin/Home.apk installed on device
[2011-04-22 16:26:20 - Home] Done!
[2011-04-22 16:29:01 - Home] ------------------------------
問題分析:根據紅色提示,說明沒有找到可運行的Activity
解決辦法:
打開AndroidManifest.xml清單文件,找到" <action android:name="android.intent.action.MAIN" />"位置,
將"<category android:name="android.intent.category.LAUNCHER" />”添加進去即可.
如下所示:
<activity android:name="Home"
android:theme="@style/Theme"
android:launchMode="singleInstance"
android:stateNotNeeded="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
附圖: