[英]unfortunately ,app has stopped
当我使用genymotion运行我的应用程序时,出现一条消息“不幸的是,应用程序已停止”,无论何时我在手机上使用它时,它都能正常工作,因此我的应用程序可以在某些设备上运行,而不能在其他设备上运行,这是我的主要活动代码
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");
}
}
这是代码错误
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
任何帮助,将不胜感激。
您正在收到SecurityException : Neither user 10051 nor current process has android.permission.WAKE_LOCK
。
如果您的Target API为23或更高版本,请确保添加运行时权限以及Android Manifest中的权限。
从Android 6.0(API级别23)开始,用户在应用程序运行时(而不是在安装应用程序时)授予应用程序权限。
有关更多信息,请参见此处 。
确保您的AndroidManifest.xml文件中包含以下行:
<uses-permission android:name="android.permission.WAKE_LOCK" />
并在运行时请求权限。 有关更多信息,请参见此处
尝试使用与原始设备相同的API级别创建一个新的genymotion虚拟设备,并在该设备上运行您的应用程序。 如果可以,请删除原始图片,因为其图像可能已损坏。 您将不会丢失任何东西,也不值得花费时间尝试对其进行修复。我要在您的错误日志中指出的行在这里:
This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.
这些的解决方案是:
此问题已在此处报告, 版本214182:appcompat-v7 24.0.0与栅格化矢量不兼容。
开发人员之一提到:
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.
解决方法是通过以下官方链接更新您的Gradle。 适用于Gradle的Android插件发行说明。
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.