我怎么能理解Android的崩溃错误和纠正。 (编辑 - 解决了!) [英] how can I understand Android crash errors and rectify them. (edited - Solved!)

查看:580
本文介绍了我怎么能理解Android的崩溃错误和纠正。 (编辑 - 解决了!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是堆栈跟踪的一个例子,如何解决从这个应用程序?有没有在谷歌市场上任何其他工具,帮助我?


  

java.lang.IllegalStateException:未知网址:
  内容://媒体/外部/音频/ albumart / -1的
  android.os.Parcel.readException(Parcel.java:1255)在
  android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
  在
  android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
  在
  android.content.ContentProviderProxy.insert(ContentProviderNative.java:450)
  在android.content.ContentResolver.insert(ContentResolver.java:587)在
  com.multi.board.series9button.function2(series9button.java:155)在
  com.multi.board.series9button.onContextItemSelected(series9button.java:95)
  在android.app.Activity.onMenuItemSelected(Activity.java:2206)在
  com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback.onMenuItemSelected(PhoneWindow.java:2781)
  在
  com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:158)
  在
  com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
  在
  com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:137)
  在
  com.android.internal.app.AlertController $ AlertParams $ 3.onItemClick(AlertController.java:876)
  在android.widget.AdapterView.performItemClick(AdapterView.java:284)
  在android.widget.ListView.performItemClick(ListView.java:3382)在
  android.widget.AbsListView $ PerformClick.run(AbsListView.java:1696)在
  android.os.Handler.handleCallback(Handler.java:587)在
  android.os.Handler.dispatchMessage(Handler.java:92)在
  android.os.Looper.loop(Looper.java:144)在
  android.app.ActivityThread.main(ActivityThread.java:4937)在
  java.lang.reflect.Method.invokeNative(本机方法)的
  java.lang.reflect.Method.invoke(Method.java:521)在
  com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:868)
  在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)在
  dalvik.system.NativeStart.main(本机方法)


希望你能帮助

感谢

MRC

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
编辑:

其实,我把它叫做功能2!这就是编程差。这里是函数。问题是,我不能让这个崩溃我的手机或其他任何我想......


 公共无效函数2(INT ID){
      Toast.makeText(这一点,设置为通知,


  
  

Toast.LENGTH_SHORT).show();
            串SD卡=
  。Environment.getExternalStorageDirectory()getAbsolutePath();

 字符串路径= SD卡+/ multi10 /+ Global.currentboard +


  
  

/ series9;

 文件k =新的文件(路径,Global.currentsound);                  ContentValues​​值=新ContentValues​​();
                  values​​.put(MediaStore.MediaColumns.DATA,


  
  

k.getAbsolutePath());
                        values​​.put(MediaStore.MediaColumns.TITLE,
  MultiboardNotif);
                        values​​.put(MediaStore.MediaColumns.MIME_TYPE,
  音频/ MPEG);
                        values​​.put(MediaStore.Audio.Media.ARTIST,未知
  艺术家);
                        values​​.put(MediaStore.Audio.Media.IS_RINGTONE,
  假);
                        values​​.put(MediaStore.Audio.Media.IS_NOTIFICATION,
  真正);
                        values​​.put(MediaStore.Audio.Media.IS_ALARM,FALSE);
                        values​​.put(MediaStore.Audio.Media.IS_MUSIC,FALSE);

 乌里URI =


  
  

MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath());


  
  

getContentResolver()。删除(URI,MediaStore.MediaColumns.TITLE += \\
  +MultiboardNotif+\\,NULL);
                    乌里newUri = getContentResolver()插入(URI,价值观);

  RingtoneManager.setActualDefaultRingtoneUri(
                    series9button.this,
                    RingtoneManager.TYPE_NOTIFICATION,
                    newUri);  }


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

议决
~~~~~~~~~~~~~

好吧,我现在明白了崩溃的错误,现在是如何工作的!这是我如何解决我的问题:

我设置铃声从我存储我的声音在对SD卡的目录声音时对某些手机有问题。

我添加一个文件来告诉媒体扫描仪无法扫描的文件在我的目录,并将它们添加到数据库中。

因此​​,要克服这个当设置为铃声/通知/报警按钮是pressed我将文件复制到SD卡中的目录名为 \\\\铃声 \\\\通知 \\\\报警和code我用previously工作正常,从该位置。


解决方案

在Android的崩溃错误你指的其实是一个Java堆栈跟踪。谷歌搜索因为这是肯定会带来了很多成果。让我给你,虽然几个指针:


  • 当异常被抛出未抓到这样的堆栈跟踪转储到错误流。

  • 第一行包含异常的类名(在你的案件 java.lang.IllegalStateException ),其次是例外(未知的URL的消息:内容: //媒体/外部/音频/ albumart / -1)。这告诉你发生了什么。

  • 堆栈跟踪的其余部分包含在它发生的信息。由于函数调用对方,你会看到几个功能相反的顺序,他们被称为,每行一个。在您的例子:

    • 发生在类除外 android.os.Parcel 方法 readException()文件 Parcel.java 在行 1255

    • 该方法是由 android.database.DatabaseUtils 调用方法 readExceptionFromParcel()文件 DatabaseUtils.java 在行 160

    • ......


您将最有可能有兴趣在最新的(最上面的)方法,来自于你的code,因为在时代的99%,是什么原因导致的错误呼叫。你的情况,这是 com.multi.board.series9button.function2(series9button.java:155)(您间preT,作为函数2 ()从类 com.multi.board.series9button 155

祝你好运!

This is an example of one of the stack traces, how do I fix my application from this? are there any other tools in google marketplace that help me with this?

java.lang.IllegalStateException: Unknown URL: content://media/external/audio/albumart/-1 at android.os.Parcel.readException(Parcel.java:1255) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114) at android.content.ContentProviderProxy.insert(ContentProviderNative.java:450) at android.content.ContentResolver.insert(ContentResolver.java:587) at com.multi.board.series9button.function2(series9button.java:155) at com.multi.board.series9button.onContextItemSelected(series9button.java:95) at android.app.Activity.onMenuItemSelected(Activity.java:2206) at com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback.onMenuItemSelected(PhoneWindow.java:2781) at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:158) at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855) at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:137) at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:876) at android.widget.AdapterView.performItemClick(AdapterView.java:284) at android.widget.ListView.performItemClick(ListView.java:3382) at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:144) at android.app.ActivityThread.main(ActivityThread.java:4937) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) at dalvik.system.NativeStart.main(Native Method)

Hope you can help

Thanks

MrC

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EDIT:

I actually called it function 2! what poor programming that is. Here is the function. The problem is I couldn't get this to crash on my phone or any other I tried....

public void function2(int id){
      Toast.makeText(this, "Set as notification",

Toast.LENGTH_SHORT).show(); String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath();

            String path = sdcard + "/multi10/" + Global.currentboard +

"/series9";

                  File k = new File(path, Global.currentsound);

                  ContentValues values = new ContentValues();
                  values.put(MediaStore.MediaColumns.DATA,

k.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, "MultiboardNotif"); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mpeg"); values.put(MediaStore.Audio.Media.ARTIST, "Unknown artist"); values.put(MediaStore.Audio.Media.IS_RINGTONE, false); values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true); values.put(MediaStore.Audio.Media.IS_ALARM, false); values.put(MediaStore.Audio.Media.IS_MUSIC, false);

                  Uri uri =

MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath());

getContentResolver().delete(uri,MediaStore.MediaColumns.TITLE + "=\"" + "MultiboardNotif" +"\"", null); Uri newUri = getContentResolver().insert(uri, values);

                  RingtoneManager.setActualDefaultRingtoneUri(
                    series9button.this,
                    RingtoneManager.TYPE_NOTIFICATION,
                    newUri);

  }

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RESOLVED ~~~~~~~~~~~~~

Well I now understand how the crash errors work now! and this is how I resolved my issue:

I had a problem on some phones when setting the ringtone as a sound from the directory I store my sounds in on the sdcard.

I add a file to tell the media scanner not to scan the files in my directories and add them to the database.

So to get round this when the set as ringtone/notification/alarm button is pressed I copy the file to a directory on the sdcard called \\ringtones or \\notifications or \\alarms and the code I used previously works fine from that location.

解决方案

The "Android crash error" you are referring to is actually a JAVA stack trace. Googling for that is sure to bring up a lot of results. Let me give you a few pointers though:

  • such a stack trace is dumped to the error stream when an exception is thrown that is not caught.
  • The first line contains the class name of the exception (in your case java.lang.IllegalStateException) followed by the message of the exception ("Unknown URL: content://media/external/audio/albumart/-1"). This tells you WHAT happened.
  • The rest of the stack trace contains info on WHERE it happened. Since functions call each other, you will see several functions in the reverse order that they were called, one per line. In your example:
    • exception occurred in class android.os.Parcel method readException() in file Parcel.java at line 1255
    • that method was called by android.database.DatabaseUtils method readExceptionFromParcel() in file DatabaseUtils.java at line 160
    • ......

You will most likely be interested in the LATEST (topmost) method call that comes FROM YOUR CODE, since in 99% of the times is what causes the error. in your case, that's com.multi.board.series9button.function2(series9button.java:155) (you interpret that as function2() from the class com.multi.board.series9button line 155).

Good luck!

这篇关于我怎么能理解Android的崩溃错误和纠正。 (编辑 - 解决了!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆