Android App startet nicht

N

Nuk3_Hive

Neues Mitglied
0
Hallo,

Ich Hab angefangen eine App zu programmieren und nun beim ersten start kommt immer eine Fehlermeldung ("Speech To Text" wurde beendet.) Meine Frage wodran liegt das?

Hier die MainActvity:
Code:
package com.example.sascha.projektschule;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.view.Menu;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.Locale;


@SuppressWarnings("ConstantConditions")
public class MainActivity extends Activity {

    public TextView txtSpeechInput;
    public ImageButton btnSpeak;
    public final int REQ_CODE_SPEECH_INPUT = 100;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);



        txtSpeechInput = (TextView) findViewById(R.id.txtSpeechInput);
        btnSpeak = (ImageButton) findViewById(R.id.btnSpeak);

        // hide the action bar
        getActionBar().hide();

        btnSpeak.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                promptSpeechInput();
            }
        });

    }

    /**
     * Showing google speech input dialog
     * */
    private void promptSpeechInput() {
        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
                getString(R.string.speech_prompt));
        try {
            startActivityForResult(intent, REQ_CODE_SPEECH_INPUT);
        } catch (ActivityNotFoundException a) {
            Toast.makeText(getApplicationContext(),
                    getString(R.string.speech_not_supported),
                    Toast.LENGTH_SHORT).show();
        }
    }

    /**
     * Receiving speech input
     * */
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        switch (requestCode) {
            case REQ_CODE_SPEECH_INPUT: {
                if (resultCode == RESULT_OK && null != data) {

                    ArrayList<String> result = data
                            .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
                    txtSpeechInput.setText(result.get(0));
                }
                break;
            }

        }
    }

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

}

Der ADB log:
Code:
PropertyFetcher: AdbCommandRejectedException getting properties for device 00ecbdde: device offline
PropertyFetcher: AdbCommandRejectedException getting properties for device 00ecbdde: device unauthorized. Please check the confirmation dialog on your device.
PropertyFetcher: AdbCommandRejectedException getting properties for device 00ecbdde: device unauthorized. Please check the confirmation dialog on your device.
PropertyFetcher: AdbCommandRejectedException getting properties for device 00ecbdde: device unauthorized. Please check the confirmation dialog on your device.
DeviceMonitor: ExecutionException getting info for device 00ecbdde
ddmlib: Eine bestehende Verbindung wurde softwaregesteuert
durch den Hostcomputer abgebrochen
java.io.IOException: Eine bestehende Verbindung wurde softwaregesteuert
durch den Hostcomputer abgebrochen
	at sun.nio.ch.SocketDispatcher.write0(Native Method)
	at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51)
	at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
	at sun.nio.ch.IOUtil.write(IOUtil.java:65)
	at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)
	at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
	at com.android.ddmlib.Client.sendAndConsume(Client.java:675)
	at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:342)
	at com.android.ddmlib.Client.requestAllocationStatus(Client.java:521)
	at com.android.ddmlib.DeviceMonitor.createClient(DeviceMonitor.java:847)
	at com.android.ddmlib.DeviceMonitor.openClient(DeviceMonitor.java:815)
	at com.android.ddmlib.DeviceMonitor.processIncomingJdwpData(DeviceMonitor.java:775)
	at com.android.ddmlib.DeviceMonitor.deviceClientMonitorLoop(DeviceMonitor.java:664)
	at com.android.ddmlib.DeviceMonitor.access$100(DeviceMonitor.java:46)
	at com.android.ddmlib.DeviceMonitor$3.run(DeviceMonitor.java:592)


Die .xml Datein sind alle Richtig

Wenn ihr noch eine Information braucht bitte bescheid sagen

Vielen Dank im eure für ihre Hilfe


mfg Sascha
 
was mir so einfällt dazu:
im Log steht
Device offline bzw. unauthorized
benutzt du einen Emulator oder ein "echtes" gerät ?
Usb-Debugmodus an ? (Einstellungen (Anwendungen) prüfen)
evtl. Wackelkontakt am Kabel (falls Hardware genutzt)
zumindest scheint dein PC die Verbindung zu kappen bzw. gar nicht erst aufzubauen
 
Erstmal danke für die Schnelle Antwort ich nutze ein echtes gerät und hab usb-debuging an die app ist ja auch so auf dem handy und dort stoppt sie auch
 
Ich würde auch als erstes mal das Kabel tauschen =)

lg. Dagobert
 
Hallo,
Ich habe mir Heute schnell ein neues gekauft aber es geht trotzdem noch nicht


mfg Sascha
 
Das bleibt es steht alles gleich da
 
Ich verstehe deine Antwort nicht :confused2:

Hast du dein Gerät autorisiert als der Dialog kam oder nicht?
 
Da kommt nichts zu Autorisieren. Android Studio hat ja mein Handy erkannt.

Der ursprüngliche Beitrag von 10:50 Uhr wurde um 10:58 Uhr ergänzt:

Ich habe mir noch einmal den Logcat herraus kopiert. Ich hoffe der Hilft jetzt Weiter


Code:
04-02 10:54:36.066  25061-25061/com.example.sascha.projektschule D/ActivityThread handleBindApplication:com.example.sascha.projektschule
04-02 10:54:36.066  25061-25061/com.example.sascha.projektschule D/ActivityThread setTargetHeapUtilization:0.75
04-02 10:54:36.066  25061-25061/com.example.sascha.projektschule D/ActivityThread setTargetHeapMinFree:2097152
04-02 10:54:36.116  25061-25061/com.example.sascha.projektschule D/AndroidRuntime Shutting down VM
04-02 10:54:36.116  25061-25061/com.example.sascha.projektschule W/dalvikvm threadid=1: thread exiting with uncaught exception (group=0x41e93ce0)
04-02 10:54:36.116  25061-25061/com.example.sascha.projektschule E/AndroidRuntime FATAL EXCEPTION: main
    Process: com.example.sascha.projektschule, PID: 25061
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sascha.projektschule/com.example.sascha.projektschule.MainActivity}: java.lang.NullPointerException
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2212)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at com.example.sascha.projektschule.MainActivity.onCreate(MainActivity.java:36)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
************at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
************at android.app.ActivityThread.access$800(ActivityThread.java:144)
************at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
************at android.os.Handler.dispatchMessage(Handler.java:102)
************at android.os.Looper.loop(Looper.java:136)
************at android.app.ActivityThread.main(ActivityThread.java:5146)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:515)
************at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
************at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
************at dalvik.system.NativeStart.main(Native Method)
 
Jetzt hast du ja auch nen Fehler... und nicht nur ne Meldung dass das device offline gegangen ist...

Du hast ne NPE in Zeile 36 deiner Main Activity....
Steht da doch drin :razz:

Was ist Zeile 36 und iwo hier im Forum gibt es auch nen Thread der beschreibt was NPEs sind und wie man dagegen vorgeht...

lg. Dagobert
 
Sehr vielen dank für deine Hilfe

Muss ich das closen?
 
Nope, aber was war nun der Fehler?

lg. Dagobert
 
// hide the action bar
getActionBar().hide();
hat nicht geklappt aber jetzt geht alles
 

Ähnliche Themen

B
Antworten
4
Aufrufe
491
bb321
B
FabianDev
Antworten
5
Aufrufe
557
swa00
swa00
D
Antworten
23
Aufrufe
2.542
Data2006
D
Zurück
Oben Unten