Piasy/SafelyAndroid

java.lang.StackOverflowError

wankey opened this issue · 4 comments

这个问题在多部4.0.4机型上出现

java.lang.StackOverflowError
at android.content.pm.PackageItemInfo.(PackageItemInfo.java:252)
at android.content.pm.ApplicationInfo.(ApplicationInfo.java:589)
at android.content.pm.ApplicationInfo.(ApplicationInfo.java:34)
at android.content.pm.ApplicationInfo$1.createFromParcel(ApplicationInfo.java:581)
at android.content.pm.ApplicationInfo$1.createFromParcel(ApplicationInfo.java:579)
at android.content.pm.ComponentInfo.(ComponentInfo.java:150)
at android.content.pm.ActivityInfo.(ActivityInfo.java:570)
at android.content.pm.ActivityInfo.(ActivityInfo.java:29)
at android.content.pm.ActivityInfo$1.createFromParcel(ActivityInfo.java:562)
at android.content.pm.ActivityInfo$1.createFromParcel(ActivityInfo.java:560)
at android.content.pm.ResolveInfo.(ResolveInfo.java:285)
at android.content.pm.ResolveInfo.(ResolveInfo.java:35)
at android.content.pm.ResolveInfo$1.createFromParcel(ResolveInfo.java:275)
at android.content.pm.ResolveInfo$1.createFromParcel(ResolveInfo.java:273)
at android.os.Parcel.createTypedArrayList(Parcel.java:1616)
at android.content.pm.IPackageManager$Stub$Proxy.queryIntentActivities(IPackageManager.java:1878)
at android.app.ApplicationPackageManager.queryIntentActivities(ApplicationPackageManager.java:488)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.isIntentSafe(StartActivityDelegate.java:268)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:215)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:201)
at com.huiti.framework.base.BaseActivity.startActivity(BaseActivity.java:36)
at com.github.piasy.safelyandroid.activity.StartActivityDelegate.startActivitySafely(StartActivityDelegate.java:219)

以上堆栈翻译:
BaseActivity重写了startActivity()方法,并在其中调用 StartActivityDelegate.startActivitySafely();
StartActivityDelegate.startActivitySafely()检查到目标Intent可以跳转,调用BaseActivity.startActivity();
BaseActivity重写了startActivity()方法,并在其中调用 StartActivityDelegate.startActivitySafely();
StartActivityDelegate.startActivitySafely()检查到目标Intent可以跳转,调用BaseActivity.startActivity();
……

Piasy commented

啊,完全忘记了这里还有个 issue :(

不要在重写的 startActivity 里面调用即可。

@Piasy 奇怪的是只在4.0.4机型中有问题,其它版本都ok的

@wankey 以下是源码:

    public static boolean startActivitySafely(@NonNull android.support.v4.app.Fragment fragment,
            @NonNull Intent intent, Bundle options) {
        if (isIntentSafe(fragment.getActivity().getPackageManager(), intent)) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                fragment.startActivity(intent, options);
            } else {
                fragment.startActivity(intent);
            }
            return true;
        }
        return false;
    }

所以,JELLY_BEAN 以下版本表现一致。也就是话说,你这个情况,JELLY_BEAN 以下版本的手机都有问题