简体   繁体   中英

unfortunately ,app has stopped

when i run my app using genymotion a message appear "unfortunately app has stoped " where ever when i use it on my phone it works normaly so my app works on some device and doesn't work on another this is the code of my main activity

public class Speedo extends Activity {
private final Handler mHandler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        if (msg != null) {
            if (msg.what == MessageHandler.MSG_NOT_CONNECTED) {
                textBluetoothStatus.setText("Not connected");
            } else if (msg.what == MessageHandler.MSG_CONNECTING) {
                textBluetoothStatus.setText("Connecting...");
            } else if (msg.what == MessageHandler.MSG_CONNECTED) {
                textBluetoothStatus.setText("Connected");
                mDeviceConnector.sendAsciiMessage("TEST");
            } else if (msg.what == MessageHandler.MSG_CONNECTION_FAILED) {
                textBluetoothStatus.setText("Connection failed");
            } else if (msg.what == MessageHandler.MSG_CONNECTION_LOST) {
                textBluetoothStatus.setText("Connection lost");
            } else if (msg.what == MessageHandler.MSG_LINE_READ) {
                Log.i("msg", msg.toString());
                cmd = msg.obj.toString();
                cmd = cmd.trim();
                textBluetooth.setText(cmd);
                }
        }
    }
};
    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
try {
                        Scanner in = new Scanner(((TextView) findViewById(R.id.bluetooth)).getText() + "").useDelimiter("[^0-9]+");
                       int bluetoothSpeed = in.nextInt();

                        GPSspeed = Integer.parseInt(edittext.getText() + "");
                        textSpeed.setText(GPSspeed + " km/h");
                        speedometer.setSpeed(GPSspeed);

                        if (bluetoothSpeed < GPSspeed && (bluetoothSpeed != lastBluetoothSpeed || GPSspeed != lastGPSspeed || lastBluetoothTime + 120 <= System.currentTimeMillis() / 1000L)) {
                          lastBluetoothSpeed = bluetoothSpeed;
                            lastGPSspeed = Integer.parseInt(edittext.getText() + "");
                            lastBluetoothTime = System.currentTimeMillis() / 1000L;
                            if(!player.isPlaying()) {
                               player.start();
                                sendsms ();
                            }
                            wakeLock.acquire();
                            handler.postDelayed(runnable, 120000);
                        }
                    }
                    catch (NumberFormatException e) {
                        Snackbar.make(findViewById(android.R.id.content), "Number format error", Snackbar.LENGTH_LONG).show();
                    }
                    catch (NoSuchElementException e) {
                        Snackbar.make(findViewById(android.R.id.content), "Bluetooth format error", Snackbar.LENGTH_LONG).show();
                    }
                }
            });

            alert.show();
        }
    });
 private class MyLocationListener implements LocationListener {
    Integer counter = 0;

    public void onLocationChanged(Location loc) {
        Log.i("GPS", "updated");
 GPSspeed = speed.intValue();
            textSpeed.setText(GPSspeed + " km/h");
            speedometer.setSpeed(GPSspeed);
            try {
                Scanner in = new Scanner(cmd).useDelimiter("[^0-9]+");
                bluetoothSpeed = in.nextInt();
                if (GPSspeed > bluetoothSpeed  && (bluetoothSpeed !=               lastBluetoothSpeed || GPSspeed != lastGPSspeed )) {
                    lastBluetoothSpeed = bluetoothSpeed;
                    lastGPSspeed = GPSspeed;
                    lastBluetoothTime = System.currentTimeMillis() / 1000L;
                    sendsms ();
                    //mDeviceConnector.sendAsciiMessage("1");
                    if(!player.isPlaying()) {
                        player.start();

                    }
                   // handler.postDelayed(runnable, 120000);
                    // wakeLock.acquire();
                }

                else if(bluetoothSpeed != lastBluetoothSpeed){
                    lastBluetoothSpeed = bluetoothSpeed;
                    sendsms ();
                }
                else if (lastBluetoothSpeed != -1 && GPSspeed     >lastBluetoothSpeed && GPSspeed != lastGPSspeed ) {
                    lastBluetoothTime = System.currentTimeMillis() / 1000L;
                    sendsms ();
                  //  mDeviceConnector.sendAsciiMessage("1");

                    if(!player.isPlaying()) {
                        player.start();

                    }
//       handler.postDelayed(runnable, 120000);
//                      wakeLock.acquire();
                }
                else {
                  //  mDeviceConnector.sendAsciiMessage("0");
                }
            } catch (Exception e) {
                e.printStackTrace();                                               Log.e(getResources().getString(R.string.app_name),"your_error_exception",e);
            }
           mDeviceConnector.sendAsciiMessage(GPSspeed + "");


        } else {
            textSpeed.setText("0 km/h");
         }
     }

and this is the code error

  07-16 13:20:54.952 831-831/? E/AndroidRuntime: FATAL EXCEPTION: main
                                           java.lang.RuntimeException:   Unable to start receiver com.jakewharton.smsbarrage.transaction.EventReceiver: java.lang.SecurityException: Neither user 10051 nor current process has android.permission.WAKE_LOCK.
                                               at android.app.ActivityThread.handleReceiver(ActivityThread.java:2236)
                                               at android.app.ActivityThread.access$1500(ActivityThread.java:130)
                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271)
                                               at android.os.Handler.dispatchMessage(Handler.java:99)
                                               at android.os.Looper.loop(Looper.java:137)
                                               at android.app.ActivityThread.main(ActivityThread.java:4745)
                                               at java.lang.reflect.Method.invokeNative(Native Method)
                                               at java.lang.reflect.Method.invoke(Method.java:511)
                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                               at     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                               at dalvik.system.NativeStart.main(Native Method)
                                            Caused by: java.lang.SecurityException: Neither user 10051 nor current process has android.permission.WAKE_LOCK.
                                               at android.os.Parcel.readException(Parcel.java:1425)
                                               at android.os.Parcel.readException(Parcel.java:1379)
                                               at android.os.IPowerManager$Stub$Proxy.acquireWakeLock(IPowerManager.java:288)
                                               at android.os.PowerManager$WakeLock.acquireLocked(PowerManager.java:309)
                                               at android.os.PowerManager$WakeLock.acquire(PowerManager.java:288)
                                               at com.jakewharton.smsbarrage.transaction.EventReceiver.beginStartingService(EventReceiver.java:42)
                                               at com.jakewharton.smsbarrage.transaction.EventReceiver.onReceive(EventReceiver.java:31)
                                               at android.app.ActivityThread.handleReceiver(ActivityThread.java:2229)
                                               at android.app.ActivityThread.access$1500(ActivityThread.java:130) 
                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271) 
                                               at android.os.Handler.dispatchMessage(Handler.java:99) 
                                               at android.os.Looper.loop(Looper.java:137) 
                                               at android.app.ActivityThread.main(ActivityThread.java:4745) 
                                               at java.lang.reflect.Method.invokeNative(Native Method) 
                                               at java.lang.reflect.Method.invoke(Method.java:511) 
                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
                                               at dalvik.system.NativeStart.main(Native Method) 
07-16 13:21:02.008 123-205/? E/SocketStream: readFully was waiting for 687488 bytes, got 10220 
07-16 13:21:02.008 123-205/? E/SocketStream: readFully was waiting for 677268 bytes, got 16192 
07-16 13:21:02.008 123-205/? E/SocketStream: readFully was waiting for 661076 bytes, got 4248 
07-16 13:21:19.996 436-919/? E/BinaryDictionaryGetter: Could not find a dictionary pack
07-16 13:21:19.996 436-919/? E/ActivityThread: Failed to find provider info  for com.android.inputmethod.latin.dictionarypack
07-16 13:21:22.848 123-205/? E/SocketStream: readFully was waiting for 687488 bytes, got 16192 
07-16 13:21:22.860 123-205/? E/SocketStream: readFully was waiting for 671296 bytes, got 16192 
07-16 13:21:29.916 436-985/? E/ActivityThread: Failed to find provider info for com.android.inputmethod.latin.dictionarypack
07-16 13:21:29.956 436-985/? E/BinaryDictionaryGetter: Could not find a dictionary pack
07-16 13:21:32.412 123-205/? E/SocketStream: readFully was waiting for 687488 bytes, got 16192 
07-16 13:21:32.424 123-205/? E/SocketStream: readFully was waiting for 671296 bytes, got 16192 
07-16 13:39:36.892 1121-1121/? E/AndroidRuntime: FATAL EXCEPTION: main
                                             java.lang.RuntimeException:   Unable to start activity ComponentInfo{com.example.toshiba.GpsBluetooth/com.example.toshiba.GpsBluetooth.Speedo}: android.view.InflateException: Binary XML file line #8: Error inflating class android.support.v7.widget.Toolbar
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
                                                 at android.app.ActivityThread.access$600(ActivityThread.java:130)
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
                                                 at android.os.Handler.dispatchMessage(Handler.java:99)
                                                 at android.os.Looper.loop(Looper.java:137)
                                                 at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                 at java.lang.reflect.Method.invokeNative(Native Method)
                                                 at java.lang.reflect.Method.invoke(Method.java:511)
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                 at dalvik.system.NativeStart.main(Native Method)
                                              Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class android.support.v7.widget.Toolbar
                                                 at android.view.LayoutInflater.createView(LayoutInflater.java:613)
                                                 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                                                 at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
                                                 at android.app.Activity.setContentView(Activity.java:1867)
                                                 at com.example.toshiba.GpsBluetooth.Speedo.onCreate(Speedo.java:134)
                                                 at android.app.Activity.performCreate(Activity.java:5008)
                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
                                                 at android.app.ActivityThread.access$600(ActivityThread.java:130) 
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
                                                 at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                 at android.os.Looper.loop(Looper.java:137) 
                                                 at android.app.ActivityThread.main(ActivityThread.java:4745) 
                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
                                                 at java.lang.reflect.Method.invoke(Method.java:511) 
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
                                                 at dalvik.system.NativeStart.main(Native Method) 
                                              Caused by: java.lang.reflect.InvocationTargetException
                                                 at java.lang.reflect.Constructor.constructNative(Native Method)
                                                 at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                                                 at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                                                 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
                                                 at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256) 
                                                 at android.app.Activity.setContentView(Activity.java:1867) 
                                                 at com.example.toshiba.GpsBluetooth.Speedo.onCreate(Speedo.java:134) 
                                                 at android.app.Activity.performCreate(Activity.java:5008) 
                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
                                                 at android.app.ActivityThread.access$600(ActivityThread.java:130) 
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
                                                 at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                 at android.os.Looper.loop(Looper.java:137) 
                                                 at android.app.ActivityThread.main(ActivityThread.java:4745) 
                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
                                                 at java.lang.reflect.Method.invoke(Method.java:511) 
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
                                                 at dalvik.system.NativeStart.main(Native Method) 
                                              Caused by: java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.
                                                 at  android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:692)
                                                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
                                                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181)
                                                 at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:67)
                                                 at android.support.v7.widget.Toolbar.<init>(Toolbar.java:298)
                                                 at android.support.v7.widget.Toolbar.<init>(Toolbar.java:229)
                                                 at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                 at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
                                                 at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
                                                 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
                                                 at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256) 
                                                 at android.app.Activity.setContentView(Activity.java:1867) 
                                                 at com.example.toshiba.GpsBluetooth.Speedo.onCreate(Speedo.java:134) 
                                                 at android.app.Activity.performCreatat android.app ctivityOnCreate(Instrumentation.java:1079) 
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
                                                 at android.app.ActivityThread.access$600(ActivityThread.java:130) 
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
                                                 at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                 at android.os.Looper.loop(Looper.java:137) 
                                                 at android.app.ActivityThread.main(ActivityThread.java:4745) 
                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
                                                 at java.lang.reflect.Method.invoke(Method.java:511) 
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
                                                 at dalvik.system.NativeStart.main(Native Method) 
07-16 13:39:37.160 123-205/? E/SocketStream: readFully was waiting for 687488 bytes, got 16192 
07-16 13:39:37.160 123-205/? E/SocketStream: readFully was waiting for 671296 bytes, got 16192   
07-16 13:57:28.840 123-205/? E/SocketStream: readFully was waiting for 23616 bytes, got 16192 
07-16 13:57:29.184 1196-1196/? E/AndroidRuntime: FATAL EXCEPTION: main

Any help would be appreciated.

You're getting a SecurityException : Neither user 10051 nor current process has android.permission.WAKE_LOCK .

If your Target API is 23 or higher, be sure to add Runtime Permissions as well as the ones in your Android Manifest.

Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app.

Refer here for more information.

Make sure you have this line inside your AndroidManifest.xml file :

<uses-permission android:name="android.permission.WAKE_LOCK" />

and request the permission at runtime. For more info see here

Try creating a new virtual device of genymotion with the same API level that your original one had and run your app on that one. If that's OK just delete the original one as its image may be corrupted. You won't lose anything and it's not worth spending time on trying to fix it.the line which i want to point in your error logcat is here:-

This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.

Solution for these is :-

This issue was alread reported here Issue 214182: appcompat-v7 24.0.0 is incompatible with rasterized vectors.

One of the developer mention:

What version of the Gradle plugin are you using?

As of v2.0 of the Gradle plugin, library resources are never rasterized so this should never happen.

The workaround for this is to update your Gradle by following this official link. Android Plugin for Gradle Release Notes.

buildscript {
  ...
  dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM