Seltsamer Crash

L

Liamissimo

Neues Mitglied
0
Hey,
sobald ich auch nur etwas Code einfüge crasht es. IMMER. Ich bin ein Neuling in Android/Java aber habe schon gute C Kenntnisse, nur treibt mich das an meine Gedulds-Grenzen. Toast, Vibrator oder auch nur ein Bildwechsel -> Crash beim Startup
Code:
package com.vibdroid;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Vibrator;
import android.text.InputFilter.LengthFilter;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    	final ImageButton andvib = (ImageButton)findViewById(R.id.vib_but);
        andvib.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				Drawable ne = null;
				ne = getResources().getDrawable(R.drawable.icon);
			    andvib.setImageDrawable(ne);
			}
		});
    }
}

Habe sogar schon eine funktionierende andere App, Copy&Paste bringt auch nichts.
 
Lolcat posten!
 
Wenn du so nett fragst, immer doch:
Code:
03-08 06:05:38.216: ERROR/vold(26): Error opening switch name path '/sys/class/switch/test' (No such file or directory)
03-08 06:05:38.216: ERROR/vold(26): Error bootstrapping switch '/sys/class/switch/test' (No such file or directory)
03-08 06:05:38.216: ERROR/vold(26): Error opening switch name path '/sys/class/switch/test2' (No such file or directory)
03-08 06:05:38.216: ERROR/vold(26): Error bootstrapping switch '/sys/class/switch/test2' (No such file or directory)
03-08 06:05:52.436: ERROR/BatteryService(51): usbOnlinePath not found
03-08 06:05:52.436: ERROR/BatteryService(51): batteryVoltagePath not found
03-08 06:05:52.436: ERROR/BatteryService(51): batteryTemperaturePath not found
03-08 06:05:52.456: ERROR/SurfaceFlinger(51): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
03-08 06:05:58.336: ERROR/EventHub(51): could not get driver version for /dev/input/mouse0, Not a typewriter
03-08 06:05:58.336: ERROR/EventHub(51): could not get driver version for /dev/input/mice, Not a typewriter
03-08 06:05:58.666: ERROR/System(51): Failure starting core service
03-08 06:05:58.666: ERROR/System(51): java.lang.SecurityException
03-08 06:05:58.666: ERROR/System(51):     at android.os.BinderProxy.transact(Native Method)
03-08 06:05:58.666: ERROR/System(51):     at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
03-08 06:05:58.666: ERROR/System(51):     at android.os.ServiceManager.addService(ServiceManager.java:72)
03-08 06:05:58.666: ERROR/System(51):     at com.android.server.ServerThread.run(SystemServer.java:176)
03-08 06:05:58.676: ERROR/AndroidRuntime(51): Crash logging skipped, no checkin service
03-08 06:06:09.152: ERROR/ActivityThread(100): Failed to find provider info for android.server.checkin
03-08 06:06:11.752: ERROR/vold(26): Cannot start volume '/sdcard' (volume is not bound)
03-08 06:06:11.902: ERROR/MediaPlayerService(30): Couldn't open fd for content://settings/system/notification_sound
03-08 06:06:11.912: ERROR/MediaPlayer(51): Unable to to create media player
03-08 06:06:12.831: ERROR/ActivityThread(100): Failed to find provider info for android.server.checkin
03-08 06:06:13.061: ERROR/ActivityThread(100): Failed to find provider info for android.server.checkin
03-08 06:06:18.181: ERROR/AndroidRuntime(120): ERROR: thread attach failed
03-08 06:06:26.772: ERROR/AndroidRuntime(173): ERROR: thread attach failed
03-08 06:06:28.595: ERROR/AndroidRuntime(218): Uncaught handler: thread main exiting due to uncaught exception
03-08 06:06:28.625: ERROR/AndroidRuntime(218): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vibdroid/com.vibdroid.MainActivity}: java.lang.ClassCastException: android.widget.ImageView
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at android.os.Looper.loop(Looper.java:123)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at android.app.ActivityThread.main(ActivityThread.java:4363)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at java.lang.reflect.Method.invokeNative(Native Method)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at java.lang.reflect.Method.invoke(Method.java:521)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at dalvik.system.NativeStart.main(Native Method)
03-08 06:06:28.625: ERROR/AndroidRuntime(218): Caused by: java.lang.ClassCastException: android.widget.ImageView
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at com.vibdroid.MainActivity.onCreate(MainActivity.java:21)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     ... 11 more
03-08 06:06:28.645: ERROR/dalvikvm(218): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
03-08 06:17:21.406: ERROR/AndroidRuntime(224): Uncaught handler: thread main exiting due to uncaught exception
03-08 06:17:21.426: ERROR/AndroidRuntime(224): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vibdroid/com.vibdroid.MainActivity}: java.lang.ClassCastException: android.widget.ImageView
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at android.os.Looper.loop(Looper.java:123)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at android.app.ActivityThread.main(ActivityThread.java:4363)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at java.lang.reflect.Method.invokeNative(Native Method)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at java.lang.reflect.Method.invoke(Method.java:521)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at dalvik.system.NativeStart.main(Native Method)
03-08 06:17:21.426: ERROR/AndroidRuntime(224): Caused by: java.lang.ClassCastException: android.widget.ImageView
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at com.vibdroid.MainActivity.onCreate(MainActivity.java:21)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
03-08 06:17:21.426: ERROR/AndroidRuntime(224):     ... 11 more
03-08 06:17:21.436: ERROR/dalvikvm(224): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
 
Schau mal in der zeile 21 nach, was genau du kastest ;)
( Es hilft, logs durchzulesen - da steht es nämlich im Klartext drin )

Java ist nun mal so schlau, gleich zu bomben wenn du etwas falsches kastest -
und nicht wie C erst wenn der Pointer ins leere geht
 
Update: Wieder nur Crash, auch wenn ich allen Code gelöscht habe und nun steht nur der Standard-Projektstart Code drin und ein onClickListener, eine PNG Grafik und ein ImageView als Button. Logcat ist der selbe wie oben...
Ein Wechsel von SDK Target 4 (1.6) auf 2.1 hat es gelöst ;)
Auch wenn ich nicht über den Logcat zeile 21 drauf gekommen bin, da steht nur er kann den MediaPlayer nicht starten.
 
Zuletzt bearbeitet:
Ich meinte nicht im Logcat, sondern in deiner onCreate() Methode von MainActivity
 
Hm, was ist an dem Button und onClickListener falsch?
 
Das wahr wohl kein ImageButton, das aus der View-Hierarchie geladen wurde
Code:
03-08 06:06:28.625: ERROR/AndroidRuntime(218): Caused by: java.lang.ClassCastException: android.widget.ImageView
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at com.vibdroid.MainActivity.onCreate(MainActivity.java:21)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
03-08 06:06:28.625: ERROR/AndroidRuntime(218):     ... 11 more
 

Ähnliche Themen

L
Antworten
0
Aufrufe
615
LOSTexe
L
Q
  • quidproquo
2
Antworten
26
Aufrufe
4.618
swa00
swa00
Murdock1
Antworten
3
Aufrufe
616
missspelled
missspelled
Zurück
Oben Unten