2015-10-08 41 views
1

我是新的android應用程序開發(從昨天我纔開始學習android)。不幸的是已經停止應用程序的Android運行時與模擬器

然後當我運行模擬器,它給 「不幸的是已停止」 的消息,請幫我解決這個錯誤

MainActivity.cs

using System; 
using Android.App; 
using Android.Content; 
using Android.Runtime; 
using Android.Views; 
using Android.Widget; 
using Android.OS; 

namespace MediaPlayer.Android 
{ 
public class MainActivity : Activity 
{ 

    protected override void OnCreate(Bundle bundle) 
    { 
     base.OnCreate(bundle); 

     try 
     { 
      SetContentView(Resource.Layout.Main); 
     } 
     catch (Exception e) 
     { 
     } 

    } 
} 
} 

main.axml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:id="@+id/linearLayout2" 
android:background="@drawable/background"> 
<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="64.2dp" 
    android:id="@+id/linearLayout1" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:layout_marginTop="5dp" 
    android:layout_marginBottom="5dp"> 
    <Button 
     android:text="Button" 
     android:layout_width="72.7dp" 
     android:layout_height="match_parent" 
     android:id="@+id/btn_add" 
     android:layout_marginLeft="0.0dp" 
     android:layout_marginRight="3.6dp" 
     android:background="@drawable/mix" /> 
    <Button 
     android:text="Button" 
     android:layout_width="72.7dp" 
     android:layout_height="match_parent" 
     android:id="@+id/btn_search" 
     android:layout_marginLeft="0.0dp" 
     android:layout_marginRight="3.6dp" 
     android:background="@drawable/search" /> 
    <Button 
     android:text="Button" 
     android:layout_width="72.7dp" 
     android:layout_height="match_parent" 
     android:id="@+id/btn_setup" 
     android:layout_marginLeft="0.0dp" 
     android:layout_marginRight="3.6dp" 
     android:background="@drawable/cog" /> 
    <Button 
     android:text="Button" 
     android:layout_width="72.7dp" 
     android:layout_height="match_parent" 
     android:id="@+id/btn_mix" 
     android:layout_marginLeft="0.0dp" 
     android:layout_marginRight="3.6dp" 
     android:background="@drawable/settings" /> 
    <Button 
     android:text="Button" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:id="@+id/btn_volumn" 
     android:layout_marginLeft="0.0dp" 
     android:layout_marginRight="3.6dp" 
     android:background="@drawable/volum" /> 
</LinearLayout> 
<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="50.9dp" 
    android:id="@+id/linearLayout4" 
    android:layout_marginBottom="5dp" 
    android:layout_marginTop="5dp"> 
    <TextView 
     android:text="Toi la Text" 
     android:layout_width="322.6dp" 
     android:layout_height="match_parent" 
     android:id="@+id/nameSong" /> 
    <Button 
     android:text="Button" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:id="@+id/btn_feedback" 
     android:background="@drawable/feedback" /> 
</LinearLayout> 
<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="276.5dp" 
    android:id="@+id/imageView1" 
    android:background="@drawable/monkey" 
    android:layout_marginRight="0.0dp" 
    android:layout_marginTop="5dp" 
    android:layout_marginBottom="5dp" /> 
<LinearLayout 
    android:orientation="horizontal" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:layout_width="match_parent" 
    android:layout_height="46.5dp" 
    android:id="@+id/linearLayout5" 
    android:layout_marginBottom="5dp" /> 
<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="65.1dp" 
    android:id="@+id/linearLayout3"> 
    <Button 
     android:text="Button" 
     android:layout_width="72.7dp" 
     android:layout_height="match_parent" 
     android:id="@+id/btn_mix" 
     android:layout_marginLeft="0.0dp" 
     android:layout_marginRight="3.6dp" 
     android:background="@drawable/mix" /> 
    <Button 
     android:text="Button" 
     android:layout_width="72.7dp" 
     android:layout_height="match_parent" 
     android:id="@+id/btn_gobot" 
     android:layout_marginRight="4.8dp" 
     android:background="@drawable/gobot" /> 
    <Button 
     android:text="Button" 
     android:layout_width="72.7dp" 
     android:layout_height="match_parent" 
     android:id="@+id/btn_play" 
     android:layout_marginRight="6.0dp" 
     android:background="@drawable/smiley" /> 
    <Button 
     android:text="Button" 
     android:layout_width="72.7dp" 
     android:layout_height="match_parent" 
     android:id="@+id/btn_gotop" 
     android:layout_marginRight="4.8dp" 
     android:background="@drawable/gotop" /> 
    <Button 
     android:text="Button" 
     android:layout_width="72.7dp" 
     android:layout_height="match_parent" 
     android:id="@+id/refresh" 
     android:background="@drawable/refresh" /> 
</LinearLayout> 
</LinearLayout> 

日誌

10-08 01:50:30.429 D/AndroidRuntime(3064): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 
10-08 01:50:30.439 D/AndroidRuntime(3064): CheckJNI is ON 
10-08 01:50:30.559 D/dalvikvm(3064): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init 
10-08 01:50:30.829 D/dalvikvm(3064): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods 
10-08 01:50:31.519 E/memtrack(3064): Couldn't load memtrack module (No such file or directory) 
10-08 01:50:31.519 E/android.os.Debug(3064): failed to load memtrack module: -2 
10-08 01:50:33.869 E/memtrack(3076): Couldn't load memtrack module (No such file or directory) 
10-08 01:50:33.869 E/android.os.Debug(3076): failed to load memtrack module: -2 
10-08 01:50:41.419 E/memtrack(3094): Couldn't load memtrack module (No such file or directory) 
10-08 01:50:41.419 E/android.os.Debug(3094): failed to load memtrack module: -2 
10-08 01:50:41.789 D/AndroidRuntime(3094): Calling main entry com.android.commands.pm.Pm 
10-08 01:50:41.869 W/ActivityManager( 357): No content provider found for permission revoke: file:///data/local/tmp/MediaPlayer.Android-Signed.apk 
10-08 01:50:41.939 W/ActivityManager( 357): No content provider found for permission revoke: file:///data/local/tmp/MediaPlayer.Android-Signed.apk 
10-08 01:50:49.109 E/memtrack(3116): Couldn't load memtrack module (No such file or directory) 
10-08 01:50:49.109 E/android.os.Debug(3116): failed to load memtrack module: -2 
10-08 01:50:49.649 E/libEGL ( 54): called unimplemented OpenGL ES API 
10-08 01:50:49.659 E/libEGL ( 54): called unimplemented OpenGL ES API 
10-08 01:50:49.659 E/libEGL ( 54): called unimplemented OpenGL ES API 
10-08 01:50:49.659 E/libEGL ( 54): called unimplemented OpenGL ES API 
10-08 01:50:49.659 E/SurfaceFlinger( 54): glCheckFramebufferStatusOES error 1488669638 
10-08 01:50:49.659 E/SurfaceFlinger( 54): got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot 
10-08 01:50:49.659 E/libEGL ( 54): called unimplemented OpenGL ES API 
10-08 01:50:49.659 E/libEGL ( 54): called unimplemented OpenGL ES API 
10-08 01:50:49.729 W/WindowManager( 357): Screenshot failure taking screenshot for (218x272) to layer 21005 
10-08 01:50:50.879 E/AndroidRuntime(3127): FATAL EXCEPTION: main 
10-08 01:50:50.879 E/AndroidRuntime(3127): Process: MediaPlayer.Android, PID: 3127 
10-08 01:50:50.879 E/AndroidRuntime(3127): java.lang.RuntimeException: Unable to get provider mono.MonoRuntimeProvider: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_22 or Xamarin.Android.Platform! 
10-08 01:50:50.879 E/AndroidRuntime(3127): 
10-08 01:50:50.879 E/AndroidRuntime(3127): at android.app.ActivityThread.installProvider(ActivityThread.java:4777) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4309) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at android.app.ActivityThread.access$1500(ActivityThread.java:135) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at android.os.Handler.dispatchMessage(Handler.java:102) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at android.os.Looper.loop(Looper.java:136) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at android.app.ActivityThread.main(ActivityThread.java:5001) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at java.lang.reflect.Method.invokeNative(Native Method) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at java.lang.reflect.Method.invoke(Method.java:515) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at dalvik.system.NativeStart.main(Native Method) 
10-08 01:50:50.879 E/AndroidRuntime(3127): Caused by: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_22 or Xamarin.Android.Platform! 
10-08 01:50:50.879 E/AndroidRuntime(3127): at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:38) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at android.app.ActivityThread.installProvider(ActivityThread.java:4774) 
10-08 01:50:50.879 E/AndroidRuntime(3127): ... 12 more 
10-08 01:50:50.879 E/AndroidRuntime(3127): Caused by: android.content.pm.PackageManager$NameNotFoundException: Xamarin.Android.Platform 
10-08 01:50:50.879 E/AndroidRuntime(3127): at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:227) 
10-08 01:50:50.879 E/AndroidRuntime(3127): at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:32) 
10-08 01:50:50.879 E/AndroidRuntime(3127): ... 13 more 
10-08 01:50:58.029 D/AndroidRuntime(3145): 
10-08 01:50:58.029 D/AndroidRuntime(3145): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 
10-08 01:50:58.039 D/AndroidRuntime(3145): CheckJNI is ON 
10-08 01:50:58.139 D/AndroidRuntime(3149): 
10-08 01:50:58.139 D/AndroidRuntime(3149): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 
10-08 01:50:58.149 D/AndroidRuntime(3149): CheckJNI is ON 
10-08 01:50:58.439 D/dalvikvm(3149): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init 
10-08 01:50:58.819 D/dalvikvm(3145): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods 
10-08 01:50:58.969 D/dalvikvm(3149): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods 
10-08 01:50:59.639 E/WindowManager( 357): Starting window AppWindowToken{b40d66c8 token=Token{b3ebe528 ActivityRecord{b40495f8 u0 MediaPlayer.Android/mediaplayer.android.TrialSplashScreen t18}}} timed out 
10-08 01:51:00.269 I/Choreographer( 357): Skipped 110 frames! The application may be doing too much work on its main thread. 
10-08 01:51:00.609 E/memtrack(3145): Couldn't load memtrack module (No such file or directory) 
10-08 01:51:00.609 E/android.os.Debug(3145): failed to load memtrack module: -2 
10-08 01:51:00.849 E/memtrack(3149): Couldn't load memtrack module (No such file or directory) 
10-08 01:51:00.849 E/android.os.Debug(3149): failed to load memtrack module: -2 
10-08 01:51:01.579 D/AndroidRuntime(3145): Calling main entry com.android.commands.am.Am 
10-08 01:51:01.639 I/ActivityManager( 357): Force stopping MediaPlayer.Android appid=10061 user=0: from pid 3145 
10-08 01:51:01.659 I/ActivityManager( 357): Killing 3127:MediaPlayer.Android/u0a61 (adj 9): stop MediaPlayer.Android 
+1

模擬器不支持OpenGL,或者您已經實現了一個類並忘記實現其抽象方法。 – Devsil

+0

我不這麼認爲。因爲我沒有在我的代碼中實現所有的東西。 我在設計GUI。 –

+0

有人幫助我。 plzzz –

回答

1

首先,「不幸已經停止」是一個普遍的信息,意思是有一些一些未處理的異常。

現在,看着你的日誌,你可以找到你的程序有以下例外崩潰:

了java.lang.RuntimeException:無法找到應用 Mono.Android.Platform.ApiLevel_22或Xamarin.Android 。平臺!

這當然更有意義。 這裏(https://forums.xamarin.com/discussion/10159/can-no-longer-run-android-applications-using-xamarin-4-2-and-xamarin-android-4-10-1)你可以找到類似問題的討論。 解決方案提出有手動更改您的csproj文件: 從

<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>

<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> 

我想你應該試試這個。

+0

謝謝。它工作。 –

相關問題