所以现在我正在尝试运行默认的 Hello World!来自developers.android.com 的应用程序。我已经为我的 SGSII 安装了 USB 驱动程序,它显示为我可以用来运行应用程序的设备。当我选择它时,这就是控制台中出现的内容。这个,仅此而已:
[2013-02-03 23:41:14 - FirstApp] Android Launch!
[2013-02-03 23:41:14 - FirstApp] adb is running normally.
[2013-02-03 23:41:14 - FirstApp] Performing com.sweatyreptile.chee.firstapp.MainActivity activity launch
[2013-02-03 23:41:14 - FirstApp] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2013-02-03 23:41:16 - FirstApp] Uploading FirstApp.apk onto device '3afd08de'
[2013-02-03 23:41:16 - FirstApp] Installing FirstApp.apk...
[2013-02-03 23:41:45 - FirstApp] Success!
[2013-02-03 23:41:45 - FirstApp] Starting activity com.sweatyreptile.chee.firstapp.MainActivity on device 3afd08de
设备上似乎没有发生任何事情。
编辑:就像我说的,我只是想运行通过创建一个新的 android 应用程序项目生成的默认应用程序。
编辑2:所以我第一次尝试就可以在平板电脑上运行该应用程序,但手机仍然无法使用。这可能与手机植根于自定义 rom 而平板电脑有库存有关吗?
代码:
MainActivity.java:
package com.sweatyreptile.chee.firstapp;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sweatyreptile.chee.firstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.sweatyreptile.chee.firstapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
</RelativeLayout>