Android-Bug收集

Posted 独立开发者

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android-Bug收集相关的知识,希望对你有一定的参考价值。

  1. java.lang.IllegalStateException: RecyclerView has no LayoutManager
    at android.support.v7.widget.RecyclerView.generateLayoutParams(RecyclerView.java:3256)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:499)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:415)

解决方式:给RecycleView设置LayoutManger,recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
如果有对RecycleView添加HeaderView,该设置请放到添加加载Header布局之前


2.

FATAL EXCEPTION: main
 Process: com.fotoable.torchflashlight, PID: 5764
 java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.coolspan.torchflashlight-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.coolspan.torchflashlight-1, /vendor/lib, /system/lib]]
     at android.app.ActivityThread.installProvider(ActivityThread.java:4793)
     at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385)
     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325)
     at android.app.ActivityThread.access$1500(ActivityThread.java:135)
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
     at android.os.Handler.dispatchMessage(Handler.java:102)
     at android.os.Looper.loop(Looper.java:136)
     at android.app.ActivityThread.main(ActivityThread.java:5017)
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:515)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
     at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.fotoable.torchflashlight-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.coolspan.torchflashlight-1, /vendor/lib, /system/lib]]
     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
     at android.app.ActivityThread.installProvider(ActivityThread.java:4778)
     at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385)?
     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325)?
     at android.app.ActivityThread.access$1500(ActivityThread.java:135)?
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)?
     at android.os.Handler.dispatchMessage(Handler.java:102)?
     at android.os.Looper.loop(Looper.java:136)?
     at android.app.ActivityThread.main(ActivityThread.java:5017)?
     at java.lang.reflect.Method.invokeNative(Native Method)?
     at java.lang.reflect.Method.invoke(Method.java:515)?
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)?
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)?
     at dalvik.system.NativeStart.main(Native Method)?

解决方法:可能是添加MultiDex分包,但未初始化的原因,在Application中初始化即可。

 @Override
    protected void attachBaseContext(Context base) 
        super.attachBaseContext(base);
        MultiDex.install(base);
    

3.
此问题是使用系统DownloadManager导致的
因为我设置了下载通知不可见;

request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);

java.lang.SecurityException: Invalid value for visibility: 2
     at android.os.Parcel.readException(Parcel.java:1546)
     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
     at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
     at android.content.ContentResolver.insert(ContentResolver.java:1260)
     at android.app.DownloadManager.enqueue(DownloadManager.java:1336)

解决方法:
添加权限即可

  <!--DownloadManager下载时不显示Notification-->
    <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />

4.
问题:使用 Collections.sort导致出现的异常

java.lang.IllegalArgumentException: Comparison method violates its general contract!
     at java.util.TimSort.mergeLo(TimSort.java:743)
     at java.util.TimSort.mergeAt(TimSort.java:479)
     at java.util.TimSort.mergeCollapse(TimSort.java:406)
     at java.util.TimSort.sort(TimSort.java:210)
     at java.util.TimSort.sort(TimSort.java:169)
     at java.util.Arrays.sort(Arrays.java:2010)
     at java.util.Collections.sort(Collections.java:1883)

代码:

Collections.sort(appInfoList, new Comparator<AppInfo>() 
                @Override
                public int compare(AppInfo o1, AppInfo o2) 
                    int value = (int) (o1.getLastUpdateTime() - o2.getLastUpdateTime());
                    int state = 0;
                    if (value > 0) 
                        state = 1;
                     else if (value < 0) 
                        state = -1;
                    
                    Log.e("AppList", "value:::::" + state);
                    return state;
                
            );

解决方法:
网上说设置:
System.setProperty(“java.util.Arrays.useLegacyMergeSort”, “true”);
好像不好使啊。

解决后的代码是,类型转换导致:

long value = (o1.getLastUpdateTime() - o2.getLastUpdateTime());

5.
异常:使用了PagerAdapter出现的问题

FATAL EXCEPTION: main
                                                   Process: com.xxx.youtube.music, PID: 22803
                                                   java.lang.UnsupportedOperationException: Required method instantiateItem was not overridden
                                                       at android.support.v4.view.PagerAdapter.instantiateItem(PagerAdapter.java:178)
                                                       at android.support.v4.view.PagerAdapter.instantiateItem(PagerAdapter.java:111)

出错代码:

        @Override
        public Object instantiateItem(ViewGroup container, int position) 
            View itemView = View.inflate(context, R.layout.view_home_banner_item, null);
            ImageView coverIv = (ImageView) itemView.findViewById(R.id.cover_iv);
            int rid = bannerList.get(position % bannerList.size());
            coverIv.setImageResource(rid);
            container.addView(itemView);
            return super.instantiateItem(container, position);
        

解决方法:

return super.instantiateItem(container, position);

改为:

return itemView;

不认真导致的错误

以上是关于Android-Bug收集的主要内容,如果未能解决你的问题,请参考以下文章

渗透测试中信息收集都收集啥信息

JVM垃圾收集器-ParNew收集器

JVM垃圾收集器-ParNew收集器

垃圾收集器(垃圾收集算法的实现)

垃圾收集器(垃圾收集算法的实现)

JVM垃圾收集器-Serial Old收集器,Parallel Old收集器