在旋转应用崩溃没有堆栈跟踪 [英] Application crashes on rotation without stackTrace

查看:107
本文介绍了在旋转应用崩溃没有堆栈跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很奇怪的问题,我的应用程序,它由一个活动和2片段(android.support.v4.app.Fragment)。

现在的问题是,当我转我的平板电脑:应用程序崩溃的时候了。

前几天,一切都工作正常,但我不得不改变包装名称,抛出了一些错误,但我设法予以纠正。 问题出现后,正确的,但我就是找不到在哪里是错误。 这里是我的logcat后得到正确应用程序被破坏,重新启动,恢复和创建的:

  10-08 17:00:14.930:D / dalvikvm(18155):GC_CONCURRENT释放394K,8%免费7792K / 8455K,暂停1毫秒+ 4ms的
10-08 17:00:14.930:D / AndroidRuntime(18155):关闭虚拟机
10-08 17:00:14.930:W / dalvikvm(18155):主题ID = 1:螺纹退出与未捕获的异常(组= 0x40bee1f8)
10-08 17:00:14.938:E / AndroidRuntime(18155):致命异常:主要
10-08 17:00:14.938:E / AndroidRuntime(18155):java.lang.IllegalStateException:没有活动
10-08 17:00:14.938:E / AndroidRuntime(18155):在android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1070)
10-08 17:00:14.938:E / AndroidRuntime(18155):在android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1065)
10-08 17:00:14.938:E / AndroidRuntime(18155):在android.support.v4.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:1854)
10-08 17:00:14.938:E / AndroidRuntime(18155):在android.support.v4.app.FragmentActivity.onResumeFragments(FragmentActivity.java:431)
10-08 17:00:14.938:E / AndroidRuntime(18155):在android.support.v4.app.FragmentActivity $ 1.handleMessage(FragmentActivity.java:90)
10-08 17:00:14.938:E / AndroidRuntime(18155):在android.os.Handler.dispatchMessage(Handler.java:99)
10-08 17:00:14.938:E / AndroidRuntime(18155):在android.os.Looper.loop(Looper.java:137)
10-08 17:00:14.938:E / AndroidRuntime(18155):在android.app.ActivityThread.main(ActivityThread.java:4514)
10-08 17:00:14.938:E / AndroidRuntime(18155):在java.lang.reflect.Method.invokeNative(本机方法)
10-08 17:00:14.938:E / AndroidRuntime(18155):在java.lang.reflect.Method.invoke(Method.java:511)
10-08 17:00:14.938:E / AndroidRuntime(18155):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:790)
10-08 17:00:14.938:E / AndroidRuntime(18155):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
10-08 17:00:14.938:E / AndroidRuntime(18155):在dalvik.system.NativeStart.main(本机方法)
 

该问题来自FragmentManager可是为什么,我不知道,因为我没有任何细节。 我想一个解决方案,我发现在这个网站获得更多的信息,通过捕获未捕获的异常,但结果我得到的是同样的logcat的一再重复,直到某种内存不足的错误发生(在logcat中太多的字符串)。

我的动态的布局是下列之一,它可以与Android的生命周期,而与屏幕旋转:

 < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:方向=横向
    机器人:ID =@ + ID / MAINVIEW
    工具:上下文=MyActivity。>

    <片段
        机器人:ID =@ + ID / missionFragment
        机器人:layout_width =350dip
        机器人:layout_height =match_parent
        机器人:layout_marginTop =机器人:ATTR / actionBarSize
        机器人:名称=com.xxx.xxx.MissionFragment>
    &所述; /片断>

    <片段
        机器人:ID =@ + ID / mapFragment
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        机器人:名称=com.xxx.xxx.MapFragment>
    &所述; /片断>

< / LinearLayout中>
 

清单是正确的有:

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=com.xxx.xxx
    安卓版code =1
    机器人:VERSIONNAME =1.0>

    <使用-SDK安卓的minSdkVersion =11/>

    <使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_FINE_LOCATION/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_MOCK_LOCATION/>
    <使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/>
    <使用-权限的Andr​​oid:名称=android.permission.RECORD_AUDIO/>
    <使用-权限的Andr​​oid:名称=android.permission.READ_CONTACTS/>

    <用途特征
        机器人:glEsVersion =0x00020000
        机器人:要求=真/>

    <应用
        机器人:图标=@可绘制/标志
        机器人:标签=@字符串/ APP_NAME>
        <活动
            机器人:MySIGActivityNAME =
            机器人:标签=@字符串/ APP_NAME
            机器人:windowSoftInputMode =stateHidden>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>

                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
    < /用途>

< /舱单>
 

如果任何人有哪里会出错来了什么想法,对这些机器人的生命周期方法,这将受到欢迎!

感谢。

更新1.1: 这是我的主要活动的onCreate方法:

  @覆盖
公共无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);

    上下文= getApplicationContext();
    currentEtape = 1;

    //设置操作栏。
    最后的动作条动作条= getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    //DésactiverL'affichage杜滴度DE L'应用等儿子ICONE
    actionBar.setDisplayShowHomeEnabled(真正的);
    actionBar.setDisplayShowTitleEnabled(真正的);

    的setContentView(R.layout.main);

    共享preferences preFS = GET preferences(0);
    trackingGPS = prefs.getBoolean(trackingGPS,假);
    如果(trackingGPS){
        TextView的viewTrackingActive =(TextView中)findViewById(R.id.textview_notif_tracking);
        viewTrackingActive.setText(this.getString(R.string.active));
        viewTrackingActive.setTextColor(Color.parseColor(#99CC00));
    }
    其他{
        TextView的viewTrackingDesactive =(TextView中)findViewById(R.id.textview_notif_tracking);
        viewTrackingDesactive.setText(this.getString(R.string.desactive));
        viewTrackingDesactive.setTextColor(Color.parseColor(#CC0000));
    }

    //用这些方法片段或活动课没有互动
    instanciateLayersDialog();
    instanciateBasemapDialog();

}
 

和onResume方法:

 公共无效onResume(){
            super.onResume();
            共享preferences preFS = GET preferences(0);
            trackingGPS = prefs.getBoolean(trackingGPS,假);
            的System.out.println(活动简历);
}
 

解决方案

我不知道这是否回答楼主的问题,但我有同样的问题,当我在我的主要活动有一个的onPause()方法看起来是这样的:

  @覆盖
公共无效的onPause(){
    super.onResume();

    ...做其他的东西...
}
 

正如你所看到的,这只是一个错字,但我花了一段时间来追查它,因为该错误消息不活动是如此的模糊。 (super.onResume应该是super.onPause,如果不是很明显。)

如果这不是您的具体问题,我相信它有事可做与原来的片段不被破坏掉了(通过适当的onPause()在我的情况下调用)。

I'm having a very strange problem with my app, which consists of an Activity and 2 Fragments (android.support.v4.app.Fragment).

The problem is when I rotate my tablet : the app crashes right away.

A few days before, everything was working fine, but I had to change packages name, that threw a few errors but I manage to correct them. Problem appeared right after that, but I just can't find where is the error. Here is the Logcat I get right after the app is destroyed, restarted, resumed and created :

10-08 17:00:14.930: D/dalvikvm(18155): GC_CONCURRENT freed 394K, 8% free 7792K/8455K,  paused 1ms+4ms
10-08 17:00:14.930: D/AndroidRuntime(18155): Shutting down VM
10-08 17:00:14.930: W/dalvikvm(18155): threadid=1: thread exiting with uncaught exception (group=0x40bee1f8)
10-08 17:00:14.938: E/AndroidRuntime(18155): FATAL EXCEPTION: main
10-08 17:00:14.938: E/AndroidRuntime(18155): java.lang.IllegalStateException: No activity
10-08 17:00:14.938: E/AndroidRuntime(18155):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1070)
10-08 17:00:14.938: E/AndroidRuntime(18155):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1065)
10-08 17:00:14.938: E/AndroidRuntime(18155):    at android.support.v4.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:1854)
10-08 17:00:14.938: E/AndroidRuntime(18155):    at android.support.v4.app.FragmentActivity.onResumeFragments(FragmentActivity.java:431)
10-08 17:00:14.938: E/AndroidRuntime(18155):    at android.support.v4.app.FragmentActivity$1.handleMessage(FragmentActivity.java:90)
10-08 17:00:14.938: E/AndroidRuntime(18155):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-08 17:00:14.938: E/AndroidRuntime(18155):    at android.os.Looper.loop(Looper.java:137)
10-08 17:00:14.938: E/AndroidRuntime(18155):    at android.app.ActivityThread.main(ActivityThread.java:4514)
10-08 17:00:14.938: E/AndroidRuntime(18155):    at java.lang.reflect.Method.invokeNative(Native Method)
10-08 17:00:14.938: E/AndroidRuntime(18155):    at java.lang.reflect.Method.invoke(Method.java:511)
10-08 17:00:14.938: E/AndroidRuntime(18155):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
10-08 17:00:14.938: E/AndroidRuntime(18155):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
10-08 17:00:14.938: E/AndroidRuntime(18155):    at dalvik.system.NativeStart.main(Native Method)

The problem comes from FragmentManager but why, I don't know, as I don't have any details. I tried a solution i found on this site to get more info, by catching uncaught exception, but the result i got was the same Logcat repeated again and again until some kind of out of memory error happened(too many strings in the logcat).

My Activity's layout is the following one, it works well with android lifecycle, but not with screen rotation :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:id = "@+id/mainview"
    tools:context=".MyActivity" >

    <fragment
        android:id="@+id/missionFragment"
        android:layout_width="350dip"
        android:layout_height="match_parent"
        android:layout_marginTop="?android:attr/actionBarSize"
        android:name="com.xxx.xxx.MissionFragment">       
    </fragment>

    <fragment
        android:id="@+id/mapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="com.xxx.xxx.MapFragment">
    </fragment>

</LinearLayout>

Manifest is right there :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xxx.xxx"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="11" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <application
        android:icon="@drawable/logo"
        android:label="@string/app_name" >
        <activity
            android:name=".MySIGActivity"
            android:label="@string/app_name"
            android:windowSoftInputMode="stateHidden" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

If anyone has any idea on where would the error come, on which android lifecycle method, that would be welcomed!

Thanks.

UPDATE 1.1: Here is onCreate method of my main Activity :

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    context = getApplicationContext();
    currentEtape = 1;

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    // Désactiver l'affichage du titre de l'application et son icône
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);

    setContentView(R.layout.main);  

    SharedPreferences prefs = getPreferences(0);
    trackingGPS = prefs.getBoolean("trackingGPS", false);
    if(trackingGPS){
        TextView viewTrackingActive = (TextView)findViewById(R.id.textview_notif_tracking);
        viewTrackingActive.setText(this.getString(R.string.active));
        viewTrackingActive.setTextColor(Color.parseColor("#99CC00"));
    }
    else{
        TextView viewTrackingDesactive = (TextView)findViewById(R.id.textview_notif_tracking);
        viewTrackingDesactive.setText(this.getString(R.string.desactive));
        viewTrackingDesactive.setTextColor(Color.parseColor("#CC0000"));
    }

    // No interaction with Fragment or Activity classes in these methods
    instanciateLayersDialog();
    instanciateBasemapDialog();

}

And onResume method :

public void onResume(){
            super.onResume();
            SharedPreferences prefs = getPreferences(0);
            trackingGPS = prefs.getBoolean("trackingGPS", false);
            System.out.println("activity resume");
}

解决方案

I'm not sure if this answers the problem of the original poster, but I had this same problem when I had an onPause() method in my main Activity that looked like this:

@Override
public void onPause() {
    super.onResume();

    ...do other stuff...
}

As you can see, it was just a typo, but it took me a while to track it down since the error message "No Activity" was so vague. ("super.onResume" should have been "super.onPause", if it's not obvious.)

If this is not your exact issue, I believe it had something to do with the original Fragment not getting destroyed (by the proper onPause() call in my case).

这篇关于在旋转应用崩溃没有堆栈跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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