三星设备上的android应用崩溃并显示SIGABRT错误

时间:2018-07-24 15:33:54

标签: android firebase picasso android-bitmap

我正在运行FirebaseRecyclerAdapter,并通过onBindViewHolder方法将用户的个人资料图片加载到Picasso中。当我在运行Android 6.0的Le Eco 2设备上运行该应用程序时,它运行得很好。

但是,当我在Samsung J7 Prime 2上运行我的应用程序时,在logcat中出现以下错误:

07-24 19:44:29.841 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: MSG_WINDOW_FOCUS_CHANGED 0
07-24 19:44:29.844 20565-20587/com.myapp.www V/FA: Recording user engagement, ms: 34127
07-24 19:44:29.846 20565-20587/com.myapp.www V/FA: Connecting to remote service
07-24 19:44:29.848 20565-20587/com.myapp.www V/FA: Activity paused, time: 985889282
07-24 19:44:29.854 20565-20587/com.myapp.www D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=34127, firebase_screen_class(_sc)=DisplayPostsActivity, firebase_screen_id(_si)=-1674957241664244677}]
07-24 19:44:29.881 20565-20587/com.myapp.www V/FA: Connection attempt already in progress
07-24 19:44:29.881 20565-20587/com.myapp.www D/FA: Connected to remote service
07-24 19:44:29.882 20565-20587/com.myapp.www V/FA: Processing queued up service tasks: 2
07-24 19:44:29.953 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: mHardwareRenderer.destroy()#1
07-24 19:44:29.962 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x5 surface={isValid=false 0} surfaceGenerationChanged=true
07-24 19:44:30.027 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: mHardwareRenderer.destroy()#1
07-24 19:44:30.038 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=false 0} surfaceGenerationChanged=false
07-24 19:44:30.039 20565-20565/com.myapp.www D/InputTransport: Input channel destroyed: fd=81
07-24 19:44:34.895 20565-20587/com.myapp.www V/FA: Inactivity, disconnecting from the service
07-24 19:46:37.623 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: mHardwareRenderer.destroy()#1
07-24 19:46:37.626 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=false 0} surfaceGenerationChanged=false
07-24 19:46:37.649 20565-23426/com.myapp.www V/FA: Connecting to remote service
07-24 19:46:37.655 20565-23425/com.myapp.www I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
07-24 19:46:37.655 20565-23425/com.myapp.www I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
07-24 19:46:37.659 20565-23426/com.myapp.www V/FA: Activity resumed, time: 986017088
07-24 19:46:37.659 20565-20565/com.myapp.www V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
07-24 19:46:37.659 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x3 surface={isValid=true -969377792} surfaceGenerationChanged=true
07-24 19:46:37.660 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: mHardwareRenderer.initialize() mSurface={isValid=true -969377792} hwInitialized=true
07-24 19:46:37.666 20565-20594/com.myapp.www D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000,  [1080x1920]-format:1
07-24 19:46:37.680 20565-20565/com.myapp.www W/Activity: AppLock checkAppLockState locked:false verifying:false pkgName = com.myapp.www isInMultiWindowMode:false showWhenLocked:false
07-24 19:46:37.704 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: MSG_WINDOW_FOCUS_CHANGED 1
07-24 19:46:37.704 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true -969377792}
07-24 19:46:37.706 20565-20565/com.myapp.www V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@c51d7a9 nm : com.myapp.www ic=null
07-24 19:46:37.706 20565-20565/com.myapp.www I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
07-24 19:46:37.708 20565-20565/com.myapp.www D/InputTransport: Input channel constructed: fd=82
07-24 19:46:37.711 20565-23426/com.myapp.www D/FA: Connected to remote service
07-24 19:46:37.712 20565-23426/com.myapp.www V/FA: Processing queued up service tasks: 1
07-24 19:46:39.503 20565-20570/com.myapp.www I/art: Do partial code cache collection, code=43KB, data=59KB
07-24 19:46:39.503 20565-20570/com.myapp.www I/art: After code cache collection, code=42KB, data=58KB
07-24 19:46:39.503 20565-20570/com.myapp.www I/art: Increasing code cache capacity to 256KB
07-24 19:46:42.396 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: ViewPostImeInputStage processPointer 0
07-24 19:46:42.482 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: ViewPostImeInputStage processPointer 1
07-24 19:46:42.520 20565-20565/com.myapp.www D/ScrollView: initGoToTop
07-24 19:46:42.639 20565-20565/com.myapp.www D/ScrollView:  onsize change changed 
07-24 19:46:42.641 20565-20565/com.myapp.www D/ScrollView: initGoToTop
07-24 19:46:42.738 20565-20565/com.myapp.www D/ScrollView:  onsize change changed 
07-24 19:46:42.773 20565-20572/com.myapp.www W/art: Suspending all threads took: 29.264ms
07-24 19:46:42.795 20565-20594/com.myapp.www W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (3438x8658, max=8192x8192)
07-24 19:46:42.813 20565-20594/com.myapp.www W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (3438x8658, max=8192x8192)
07-24 19:46:42.814 20565-23426/com.myapp.www V/FA: Inactivity, disconnecting from the service
07-24 19:46:42.817 20565-20565/com.myapp.www D/ScrollView: initGoToTop
07-24 19:46:42.867 20565-20594/com.myapp.www W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (3438x8658, max=8192x8192)
07-24 19:46:42.868 20565-20594/com.myapp.www W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (3438x8658, max=8192x8192)
07-24 19:46:42.868 20565-20594/com.myapp.www W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (3438x8658, max=8192x8192)
07-24 19:46:42.868 20565-20594/com.myapp.www A/OpenGLRenderer: failed storing bitmap shader data
07-24 19:46:42.869 20565-20594/com.myapp.www A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 20594 (RenderThread)

                                                        [ 07-24 19:46:42.870  2316: 2316 W/         ]
                                                        debuggerd: handling request: pid=20565 uid=10192 gid=10192 tid=20594

我正在使用Picasso从对Firebase存储的引用提供的URL中加载图像。这种方法在Le Eco设备上对我来说效果很好。

我尝试根据此处的一些答案在AndroidManifest.xml中设置 android:hardwareAccelerated = false android:largeHeap = true 。它可以工作,但是却使该应用程序变得非常紧张,从而破坏了拥有一个平滑应用程序的目的。另外,如果它在我的其他设备上运行,那么问题应该出在其他地方,对吧?

Firebase中存储的图像被重新缩放为300x300,并在上传之前进行压缩,并且大小小于10kb ,因此出现“位图太大而无法上传”的错误完全没有道理。

编辑: 这是RecyclerView中使用的cardview的XML布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:cardview="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="48dp"
            cardview:cardCornerRadius="4dp"
            cardview:cardElevation="4dp">

            <include layout="@layout/post_shimmer"/>
            <include layout="@layout/image_shimmer"/>

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <de.hdodenhof.circleimageview.CircleImageView
                        android:id="@+id/user_image_recycle"
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:layout_marginStart="16dp"
                        android:layout_marginTop="16dp"
                        android:clickable="true"
                        />

                    <TextView
                        android:id="@+id/post_type_recycle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginTop="16dp"
                        android:layout_toRightOf="@+id/user_image_recycle"
                        android:textStyle="italic" />

                    <TextView
                        android:id="@+id/post_title_recycle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/post_type_recycle"
                        android:layout_marginStart="16dp"
                        android:layout_toRightOf="@+id/user_image_recycle"
                        android:maxLines="1"
                        android:textColor="@android:color/black"
                        android:textSize="18sp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/user_name_recycle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/post_title_recycle"
                        android:layout_marginStart="16dp"
                        android:layout_toRightOf="@+id/user_image_recycle"
                        android:textColor="#0094BD"
                        android:clickable="true"
                        android:textSize="16sp" />

                    <ImageView
                        android:id="@+id/post_divider"
                        android:layout_width="match_parent"
                        android:layout_height="2dp"
                        android:layout_below="@+id/user_image_recycle"
                        android:layout_marginEnd="16dp"
                        android:layout_marginStart="16dp"
                        android:layout_marginTop="16dp"
                        android:background="@android:color/black" />

                    <!-- It is CRUCIAL to keep the layout width to wrap_content otherwise
                    the text will not be selectable after Suggest change has been clicked
                    on once. This is an Android bug.
                    -->
                    <TextView
                        android:id="@+id/post_text_recycle"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/post_divider"
                        android:layout_marginEnd="16dp"
                        android:layout_marginStart="16dp"
                        android:layout_marginTop="16dp"
                        android:autoLink="web"
                        android:fontFamily="serif"
                        android:textColor="@android:color/black"
                        android:textColorHighlight="@android:color/holo_blue_light"
                        android:textIsSelectable="true"
                        android:textSize="16sp" />

                </RelativeLayout>
        </android.support.v7.widget.CardView>
    </ScrollView>
</RelativeLayout>

这是我使用毕加索设置ImageView的onBindViewHolder方法中的代码:

final StorageReference imageRef = storageReference.child("images/" + uid).child("profile");
                        imageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                            @Override
                            public void onSuccess(Uri uri) {
                                Picasso.get().load(uri)
                                        .noFade()
                                        .into(holder.profile, new Callback() {
                                            @Override
                                            public void onSuccess() {

                                            }

                                            @Override
                                            public void onError(Exception e) {

                                                holder.profile.setImageDrawable(getResources().getDrawable(R.drawable.profile, null));
                                            }
                                        });
                            }
                        }).addOnFailureListener(new OnFailureListener() {
                            @Override
                            public void onFailure(@NonNull Exception e) {
                                holder.profile.setImageDrawable(getResources().getDrawable(R.drawable.profile, null));
                            }
                        });

编辑2 : 我从应用程序中删除了所有毕加索参考。它仍然崩溃。我实际上没有在应用程序中的其他任何地方加载任何位图。这怎么可能?

我已经尝试解决了四个小时,但似乎找不到合适的解决方案。

感谢您的帮助!

2 个答案:

答案 0 :(得分:0)

看到错误-too large to be uploaded into a texture,建议您在上传或下载时调整图片大小

毕加索.get()是什么? Picasso.get()您在此处未传递任何活动或上下文

此外,.into(holder.profile)应该是您的图像视图 我建议您尝试下面的代码

位图yourBitmap; 调整位图大小= Bitmap.createScaledBitmap(yourBitmap,newWidth,newHeight,true);

Picasso.with(your_context_here)
                .load(resized)
                 .noFade()
                .centerCrop().fit()
                .into(imageView, new Callback() {
                    @Override
                    public void onSuccess() {
                     }

                    @Override
                    public void onError() {
                    }
                });

答案 1 :(得分:0)

hardwareaccelerated=false解决方案始终可以正常工作,但是,这大大降低了我的应用程序运行速度。 我设法从此文档中找到本地修补程序:

https://developer.android.com/guide/topics/graphics/hardware-accel

基本上,我仅针对ViewHolder中的CircleImageView将硬件加速设置为 。这是代码:

private PostViewHolder(View itemView) {
            super(itemView);

            profile = (CircleImageView) itemView.findViewById(R.id.user_image_recycle);
            profile.setLayerType(View.LAYER_TYPE_SOFTWARE,null);
}

profile.setLayerType(View.LAYER_TYPE_SOFTWARE,null)允许仅针对图像关闭硬件加速。此后,其他所有工作都正常。该视图仍然有些抖动,但不是很明显。图像加载!是的!