2015-01-02 132 views
2

我正在学习android作为初学者的应用程序开发。该应用程序未在仿真器上运行。错误说:无法在模拟器上运行Android应用程序

不幸的是,Appname已停止。

我已经经历了类似的主题在这里解决,但我仍然无法找到问题。从logcat日志看起来有一个超时问题,但通过eclipse - > window - > preferences - > Android - > DDMS将超时值增加到50秒,它仍然显示相同的错误。 有什么帮助吗?

MainActivity.java

package com.example.myfirstapp; 

import android.support.v7.app.ActionBarActivity; 
import android.os.Bundle; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 


public class MainActivity extends ActionBarActivity implements OnClickListener{ 

private Button theButton; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    theButton = (Button)findViewById(R.id.myButton); 
    theButton.setOnClickListener(this); 
} 

public void onClick(View v){ 
    if(v.getId()==theButton.getId()){ 
     theButton.setText("Ouch"); 
    } 
} 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.main, menu); 
    return true; 
} 

@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    // Handle action bar item clicks here. The action bar will 
    // automatically handle clicks on the Home/Up button, so long 
    // as you specify a parent activity in AndroidManifest.xml. 
    int id = item.getItemId(); 
    if (id == R.id.action_settings) { 
     return true; 
    } 
    return super.onOptionsItemSelected(item); 
} 
} 

AndroidManifest.xml中

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.myfirstapp" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="20" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name=".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> 

logcat的

01-02 11:39:23.260: W/WearableConn(485): Error writing to device, error: failed to  connect to /10.0.2.2 (port 5601): connect failed: ETIMEDOUT (Connection timed out) 
01-02 11:39:23.310: I/WearableConn(485): Socket closed 
01-02 11:39:23.360: I/WearableConn(485): Waiting 2.0 seconds to retry connection 
01-02 11:39:25.400: I/WearableConn(485): Connecting via TCP to /10.0.2.2:5601 
01-02 11:39:25.480: D/dalvikvm(455): GC_EXPLICIT freed 888K, 30% free 3283K/4632K, paused 4ms+5ms, total 48ms 
01-02 11:39:33.190: I/Choreographer(455): Skipped 36 frames! The application may be doing too much work on its main thread. 
01-02 11:39:33.220: I/ActivityManager(354): START u0 {act=android.intent.action.MAIN flg=0x10000000 cmp=com.example.myfirstapp/.MainActivity} from pid 455 on display 0 
01-02 11:39:33.260: D/LightsService(354): Excessive delay setting light: 63ms 
01-02 11:39:33.410: D/gralloc(49): Registering a buffer in the process that created it. This may cause memory ordering problems. 
01-02 11:39:33.410: E/libEGL(49): called unimplemented OpenGL ES API 
01-02 11:39:33.420: E/libEGL(49): called unimplemented OpenGL ES API 
01-02 11:39:33.420: W/WindowManager(354): Screenshot failure taking screenshot for (123x221) to layer 21000 
01-02 11:39:33.420: E/libEGL(49): called unimplemented OpenGL ES API 
01-02 11:39:33.420: E/libEGL(49): called unimplemented OpenGL ES API 
01-02 11:39:33.420: E/SurfaceFlinger(49): glCheckFramebufferStatusOES error -1331883460 
01-02 11:39:33.420: E/SurfaceFlinger(49): got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot 
01-02 11:39:33.420: E/libEGL(49): called unimplemented OpenGL ES API 
01-02 11:39:33.420: E/libEGL(49): called unimplemented OpenGL ES API 
01-02 11:39:33.460: I/Choreographer(354): Skipped 46 frames! The application may be doing too much work on its main thread. 
01-02 11:39:33.590: D/LightsService(354): Excessive delay setting light: 61ms 
01-02 11:39:33.620: I/ActivityManager(354): Start proc com.example.myfirstapp for activity com.example.myfirstapp/.MainActivity: pid=745 uid=10018 gids={50018} 
01-02 11:39:33.640: D/dalvikvm(745): Not late-enabling CheckJNI (already on) 
01-02 11:39:33.670: E/HostWithRpcCallback(455): Failed to send RPC 
01-02 11:39:33.670: E/HostWithRpcCallback(455): com.google.android.wearable.gmsclient.WearableException: sendRpcAsync failed: Status{statusCode=unknown status code: 4000, resolution=null} 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at com.google.android.wearable.gmsclient.GoogleApiClientHelper.throwIfFailed(GoogleApiClientHelper.java:98) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at com.google.android.wearable.gmsclient.MessageManager$1$1.getResult(MessageManager.java:81) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at com.google.android.wearable.gmsclient.MessageManager$1$1.getResult(MessageManager.java:78) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at com.google.android.clockwork.actions.WearableHostWithRpcCallback$SendRpcCallbackWithId.onSendRpc(WearableHostWithRpcCallback.java:292) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at com.google.android.wearable.gmsclient.MessageManager$1.onResult(MessageManager.java:78) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at com.google.android.wearable.gmsclient.MessageManager$1.onResult(MessageManager.java:75) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at com.google.android.gms.common.api.BaseImplementation$CallbackHandler.deliverResultCallback(Unknown Source) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at com.google.android.gms.common.api.BaseImplementation$CallbackHandler.handleMessage(Unknown Source) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at android.os.Handler.dispatchMessage(Handler.java:102) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at android.os.Looper.loop(Looper.java:136) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at android.app.ActivityThread.main(ActivityThread.java:5026) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at java.lang.reflect.Method.invokeNative(Native Method) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at java.lang.reflect.Method.invoke(Method.java:515) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 
01-02 11:39:33.670: E/HostWithRpcCallback(455):  at dalvik.system.NativeStart.main(Native Method) 
01-02 11:39:34.030: D/AndroidRuntime(745): Shutting down VM 
01-02 11:39:34.030: W/dalvikvm(745): threadid=1: thread exiting with uncaught exception (group=0xb4a22d70) 
01-02 11:39:34.040: E/AndroidRuntime(745): FATAL EXCEPTION: main 
01-02 11:39:34.040: E/AndroidRuntime(745): Process: com.example.myfirstapp, PID: 745 
01-02 11:39:34.040: E/AndroidRuntime(745): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myfirstapp/com.example.myfirstapp.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar. 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.app.ActivityThread.access$800(ActivityThread.java:138) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.os.Handler.dispatchMessage(Handler.java:102) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.os.Looper.loop(Looper.java:136) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.app.ActivityThread.main(ActivityThread.java:5026) 
01-02 11:39:34.040: E/AndroidRuntime(745): at java.lang.reflect.Method.invokeNative(Native Method) 
01-02 11:39:34.040: E/AndroidRuntime(745): at java.lang.reflect.Method.invoke(Method.java:515) 
01-02 11:39:34.040: E/AndroidRuntime(745): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 
01-02 11:39:34.040: E/AndroidRuntime(745): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 
01-02 11:39:34.040: E/AndroidRuntime(745): at dalvik.system.NativeStart.main(Native Method) 
01-02 11:39:34.040: E/AndroidRuntime(745): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar. 
01-02 11:39:34.040: E/AndroidRuntime(745): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:277) 
01-02 11:39:34.040: E/AndroidRuntime(745): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2889) 
01-02 11:39:34.040: E/AndroidRuntime(745): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3154) 
01-02 11:39:34.040: E/AndroidRuntime(745): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:305) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.app.Activity.setContentView(Activity.java:1930) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77) 
01-02 11:39:34.040: E/AndroidRuntime(745): at com.example.myfirstapp.MainActivity.onCreate(MainActivity.java:18) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.app.Activity.performCreate(Activity.java:5242) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
01-02 11:39:34.040: E/AndroidRuntime(745): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161) 
01-02 11:39:34.040: E/AndroidRuntime(745): ... 11 more 
01-02 11:39:34.100: W/ActivityManager(354): Force finishing activity com.example.myfirstapp/.MainActivity 
01-02 11:39:34.120: W/InputMethodManagerService(354): Window already focused, ignoring focus gain of: [email protected] attribute=null, token = [email protected] 
01-02 11:39:34.350: I/Choreographer(354): Skipped 95 frames! The application may be doing too much work on its main thread. 
01-02 11:39:34.470: I/Choreographer(354): Skipped 32 frames! The application may be doing too much work on its main thread. 
01-02 11:39:34.570: I/Choreographer(354): Skipped 34 frames! The application may be doing too much work on its main thread. 
01-02 11:39:34.620: I/Choreographer(354): Skipped 35 frames! The application may be doing too much work on its main thread. 
01-02 11:39:34.630: W/ActivityManager(354): Activity pause timeout for ActivityRecord{b4eb1738 u0 com.example.myfirstapp/.MainActivity t4 f} 
01-02 11:39:34.690: I/Choreographer(354): Skipped 56 frames! The application may be doing too much work on its main thread. 
01-02 11:39:34.730: I/Choreographer(354): Skipped 34 frames! The application may be doing too much work on its main thread. 
01-02 11:39:34.830: E/HostWithRpcCallback(455): Failed to send RPC 
01-02 11:39:34.830: E/HostWithRpcCallback(455): com.google.android.wearable.gmsclient.WearableException: sendRpcAsync failed: Status{statusCode=unknown status code: 4000, resolution=null} 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at com.google.android.wearable.gmsclient.GoogleApiClientHelper.throwIfFailed(GoogleApiClientHelper.java:98) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at com.google.android.wearable.gmsclient.MessageManager$1$1.getResult(MessageManager.java:81) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at com.google.android.wearable.gmsclient.MessageManager$1$1.getResult(MessageManager.java:78) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at com.google.android.clockwork.actions.WearableHostWithRpcCallback$SendRpcCallbackWithId.onSendRpc(WearableHostWithRpcCallback.java:292) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at com.google.android.wearable.gmsclient.MessageManager$1.onResult(MessageManager.java:78) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at com.google.android.wearable.gmsclient.MessageManager$1.onResult(MessageManager.java:75) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at com.google.android.gms.common.api.BaseImplementation$CallbackHandler.deliverResultCallback(Unknown Source) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at com.google.android.gms.common.api.BaseImplementation$CallbackHandler.handleMessage(Unknown Source) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at android.os.Handler.dispatchMessage(Handler.java:102) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at android.os.Looper.loop(Looper.java:136) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at android.app.ActivityThread.main(ActivityThread.java:5026) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at java.lang.reflect.Method.invokeNative(Native Method) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at java.lang.reflect.Method.invoke(Method.java:515) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 
01-02 11:39:34.830: E/HostWithRpcCallback(455):  at dalvik.system.NativeStart.main(Native Method) 
01-02 11:39:35.640: I/Process(745): Sending signal. PID: 745 SIG: 9 
01-02 11:39:35.660: I/ActivityManager(354): Process com.example.myfirstapp (pid 745) has died. 
01-02 11:39:35.750: W/InputMethodManagerService(354): Window already focused, ignoring focus gain of: [email protected] attribute=null, token = [email protected] 
01-02 11:39:35.800: I/Choreographer(354): Skipped 166 frames! The application may be doing too much work on its main thread. 
01-02 11:39:35.880: D/dalvikvm(354): GC_FOR_ALLOC freed 502K, 13% free 4406K/5048K, paused 63ms, total 69ms 
01-02 11:39:35.890: I/Choreographer(354): Skipped 40 frames! The application may be doing too much work on its main thread. 
+1

4.4W的Android Wear SDK改变你的SDK –

回答

2

你的错误LO gs清楚地说出了以下错误:

Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar. 

4.4W是Android Wear SDK。只是不要在Android SDK的磨损并在AndroidManifest.xml文件更改目标SDK版本19这里

清单里面显示标签添加此标签,如果不存在已经

<uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="19" /> 

别将Android Level 20作为Android虚拟设备使用。改为使用API​​级别19和平台4.4.2。

+0

我改变了SDK版本... – Ankur

+0

它是否解决问题了吗? –

+0

是的,它与SdkVersion 19合作 – Ankur

0

我面对这个问题,并解决: Open the android SDK manager and remove Android wear sdk and its package completely and try to run you android application.

相关问题