我是android开发的初学者,我尝试制作一个小应用程序。它工作正常,但是,然后我开始摆弄 AndroidManifest 文件,但无论如何我必须从我已经创建的备份中恢复它。但现在应用程序启动但只是为了显示第一个活动,然后它说“不幸的是,应用程序标题已停止”。我尝试了以下方法: 1. 试图在 AndroidMainfest 中查找错误。2. Project->Clean 3. 搜索stackoverflow 但似乎没有任何效果
这是我的控制台
[2013-06-28 12:18:07 - start] Uploading start.apk onto device 'emulator-5554'
[2013-06-28 12:18:08 - start] Installing start.apk...
[2013-06-28 12:18:14 - start] Success!
[2013-06-28 12:18:14 - start] Failed to install start.apk on device 'emulator-5554': device not found
[2013-06-28 12:18:14 - start] com.android.ddmlib.InstallException: device not found
[2013-06-28 12:18:14 - start] Launch canceled!
和我的清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.start"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="14" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:configChanges="orientation|keyboardHidden|screenSize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".StartingPointActivity"
android:configChanges="orientation|keyboardHidden|screenSize" >
<intent-filter>
<action android:name="com.davinci.STARTINGPOINTACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:configChanges="orientation|keyboardHidden|screenSize" >
<intent-filter>
<action android:name="com.davinci.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
我的 logcat 输出
06-26 20:36:41.007: D/dalvikvm(2673): Not late-enabling CheckJNI (already on)
06-26 20:36:41.567: E/Trace(2673): error opening trace file: No such file or directory (2)
06-26 20:36:42.377: D/dalvikvm(2673): GC_FOR_ALLOC freed 58K, 7% free 2497K/2676K, paused 29ms, total 33ms
06-26 20:36:42.377: I/dalvikvm-heap(2673): Grow heap (frag case) to 3.563MB for 1058416-byte allocation
06-26 20:36:42.507: D/dalvikvm(2673): GC_FOR_ALLOC freed 2K, 5% free 3528K/3712K, paused 123ms, total 123ms
06-26 20:36:42.797: D/dalvikvm(2673): GC_CONCURRENT freed 1K, 5% free 3528K/3712K, paused 6ms+32ms, total 290ms
06-26 20:36:43.317: D/gralloc_goldfish(2673): Emulator without GPU emulation detected.
06-26 20:36:45.407: D/dalvikvm(2673): GC_FOR_ALLOC freed 13K, 4% free 3637K/3772K, paused 32ms, total 38ms
06-26 20:36:45.407: I/dalvikvm-heap(2673): Grow heap (frag case) to 4.274MB for 635812-byte allocation
06-26 20:36:45.487: D/dalvikvm(2673): GC_CONCURRENT freed 3K, 4% free 4255K/4396K, paused 4ms+3ms, total 72ms
06-26 20:36:45.487: D/dalvikvm(2673): WAIT_FOR_CONCURRENT_GC blocked 16ms
06-26 20:36:45.777: E/ArrayAdapter(2673): You must supply a resource ID for a TextView
06-26 20:36:45.777: D/AndroidRuntime(2673): Shutting down VM
06-26 20:36:45.787: W/dalvikvm(2673): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
06-26 20:36:45.927: E/AndroidRuntime(2673): FATAL EXCEPTION: main
06-26 20:36:45.927: E/AndroidRuntime(2673): java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:386)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ListView.makeAndAddView(ListView.java:1831)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ListView.fillDown(ListView.java:674)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ListView.fillFromTop(ListView.java:735)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ListView.layoutChildren(ListView.java:1652)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.AbsListView.onLayout(AbsListView.java:1994)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.View.layout(View.java:14008)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.View.layout(View.java:14008)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.View.layout(View.java:14008)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.View.layout(View.java:14008)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1892)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1711)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.Choreographer.doFrame(Choreographer.java:532)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.os.Handler.handleCallback(Handler.java:725)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.os.Handler.dispatchMessage(Handler.java:92)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.os.Looper.loop(Looper.java:137)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-26 20:36:45.927: E/AndroidRuntime(2673): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 20:36:45.927: E/AndroidRuntime(2673): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 20:36:45.927: E/AndroidRuntime(2673): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-26 20:36:45.927: E/AndroidRuntime(2673): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-26 20:36:45.927: E/AndroidRuntime(2673): at dalvik.system.NativeStart.main(Native Method)
06-26 20:36:45.927: E/AndroidRuntime(2673): Caused by: java.lang.ClassCastException: android.widget.TwoLineListItem cannot be cast to android.widget.TextView
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:379)
06-26 20:36:45.927: E/AndroidRuntime(2673): ... 37 more
和 splash.java
package com.example.start;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splash extends Activity {
MediaPlayer song;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
song = MediaPlayer.create(Splash.this,R.raw.chimesound);
song.start();
Thread timer = new Thread()
{
public void run(){
try{
sleep(2000);
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent openStatingPointActivity = new Intent("com.davinci.MENU");
startActivity(openStatingPointActivity);
}
}
};
timer.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
song.release();
finish();
}
}
菜单.java
package com.example.start;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class Menu extends ListActivity{
String Classes[]= {"Ëxample1","StartingPointActivity","example1","example2","example3"};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_list_item_2, Classes));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
String activityName = Classes[position];
try
{
Class ourClass = Class.forName("com.example.start." + activityName);
Intent ourIntent = new Intent(Menu.this,ourClass);
startActivity(ourIntent);
}
catch (ClassNotFoundException e){
e.printStackTrace();
}
}
}
请帮忙 !