简体   繁体   English

无法在真实设备中运行应用

[英]trouble running app in real device

for the last month i have try to finish an app for mi android cel, when i finally finish i run using the virtual device and it work like i charm, how ever when i try to run using a real device the app starts but then show a black screen this is the first app y try using a real device and have no idea the reason for why in virtual device it works and not in a real device can anyone tell where i can find a reason for since the logcat in eclipse is not explicit of why it wont work. 对于上个月我已经尝试完成一个应用程序的mi android cel,当我终于完成我运行使用虚拟设备,它的工作就像我的魅力,当我尝试使用真实设备运行应用程序启动,但然后显示黑屏这是第一个尝试使用真实设备的应用程序,并且不知道为什么在虚拟设备中它工作而不是在真实设备中的原因任何人都可以告诉我在哪里可以找到原因因为日食中的logcat不是明确为什么它不会工作。

this is the logcat when it wont works: 这是logcat,当它不起作用时:

10-12 13:39:07.578: D/dalvikvm(9995): Late-enabling CheckJNI
10-12 13:39:07.593: I/dalvikvm(9995): Turning on JNI app bug workarounds for target SDK version 9...
10-12 13:39:08.188: D/dalvikvm(9995): GC_CONCURRENT freed 138K, 3% free 9507K/9735K, paused 2ms+2ms
10-12 13:39:08.488: D/AndroidRuntime(9995): Shutting down VM
10-12 13:39:08.488: W/dalvikvm(9995): threadid=1: thread exiting with uncaught exception (group=0x40c671f8)
10-12 13:39:08.498: E/AndroidRuntime(9995): FATAL EXCEPTION: main
10-12 13:39:08.498: E/AndroidRuntime(9995): java.lang.NumberFormatException: Invalid double: "350,32"
10-12 13:39:08.498: E/AndroidRuntime(9995):     at java.lang.StringToReal.invalidReal(StringToReal.java:63)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at java.lang.StringToReal.parseDouble(StringToReal.java:269)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at java.lang.Double.parseDouble(Double.java:295)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at java.lang.Double.valueOf(Double.java:332)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at com.example.mezcla2.MainActivity$9.hoja1_Tb1(MainActivity.java:484)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at com.example.mezcla2.MainActivity$9.onItemSelected(MainActivity.java:444)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at android.widget.AdapterView.fireOnSelected(AdapterView.java:882)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at android.widget.AdapterView.access$200(AdapterView.java:48)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:848)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at android.os.Handler.handleCallback(Handler.java:605)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at android.os.Looper.loop(Looper.java:137)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at android.app.ActivityThread.main(ActivityThread.java:4518)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at java.lang.reflect.Method.invokeNative(Native Method)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at java.lang.reflect.Method.invoke(Method.java:511)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
10-12 13:39:08.498: E/AndroidRuntime(9995):     at dalvik.system.NativeStart.main(Native Method)

I suspect you are not allowing for the number formatting of different locales. 我怀疑你不允许不同语言环境的数字格式。

For example, in the UK a number would be written as 350.32 but in Spain it would be 350,32 例如,在英国,一个数字将被写为350.32,但在西班牙则为350,32

Trying to use a specific number format when it is not supported by the locale would throw the exception you are experiencing. 当语言环境不支持时,尝试使用特定的数字格式会抛出您遇到的异常。

Your device is likely using a locale that is not supported for the number you have used but your emulator is not. 您的设备可能使用的语言环境不支持您使用的数字,但您的模拟器不支持。

The error is being thrown in an anonymous inner class (hoja1_Tb1) in your MainActivity. 在MainActivity中的匿名内部类(hoja1_Tb1)中抛出错误。 Line 484 484行

EDIT: 编辑:

Logcat Analysis: Logcat分析:

Looking back through the logcat for code that is in your classes and not in a built in class. 回顾一下logcat中代码中的代码,而不是内置类中的代码。

com.example.mezcla2.MainActivity$9.onItemSelected(MainActivity.java:444) com.example.mezcla2.MainActivity $ 9.onItemSelected(MainActivity.java:444)

then 然后

com.example.mezcla2.MainActivity$9.hoja1_Tb1(MainActivity.java:484) com.example.mezcla2.MainActivity $ 9.hoja1_Tb1(MainActivity.java:484)

Then the code attempts to convert "something" to a Double. 然后代码尝试将“something”转换为Double。

This tells us that you have an inner class calling "onItemSelected" which then calls "hoja1_Tb1" at line 484 这告诉我们你有一个调用“onItemSelected”的内部类,然后在第484行调用“hoja1_Tb1”

Then you get the actual error. 然后你得到实际的错误。 Something at this location is trying to use a number that is not a valid number for the locale you are using. 此位置的某些内容正在尝试使用的数字不是您正在使用的区域设置的有效数字。

The best thing you can do is learn how to read and interpret logcat. 您可以做的最好的事情是学习如何阅读和解释logcat。 You have no hope of producing anything in code if you cannot find where you are going wrong. 如果你找不到错误的地方,你就没有希望在代码中产生任何东西。

First of all you must make sure that your physical device(phone) is enabled for the running android apps in areal device. 首先,您必须确保为区域设备中运行的Android应用程序启用了物理设备(手机)。 steps:- 脚步:-

  1. Go to your phone and go to settings. 转到手机并转到设置。
  2. Instead of general settings Go to ALL. 而不是一般设置转到ALL。
  3. Touch Developers option while your device is connected to the computer. 在设备连接到计算机时触摸开发人员选项。
  4. Then Enable USB debugging. 然后启用USB调试。
  5. Then run the app. 然后运行应用程序。 again then you will see your device. 然后你会看到你的设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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