Android 应用程序在三星设备上崩溃并出现 SIGABRT 错误

Android app crashes with a SIGABRT error on Samsung device

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

但是,当我 运行 我的应用程序在 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 从 URL 中加载图像,该图像由对 Firebase 存储的引用提供。这个方法在我的 Le Eco 设备上很管用。

我尝试在 AndroidManifest.xml 根据这里的一些答案。它有效,但它使应用程序非常紧张,这违背了拥有流畅应用程序的目的。另外,如果它在我的其他设备上 运行ning,那么问题应该出在其他地方,对吗?

存储在 Firebase 中的图像重新缩放为 300x300 并在上传前压缩并且大小小于 10kb,因此"Bitmap too large to be uploaded" 错误完全没有意义。

编辑: 这是 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>

这是我使用 Picasso 设置 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: 我从应用程序中删除了所有 Picasso 引用。它仍然在崩溃。我实际上没有在应用程序的其他任何地方加载任何位图。这怎么可能?

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

感谢您的帮助!

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

毕加索.get()什么? Picasso.get() 您没有在此处传递任何 activity 或上下文

此外,.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() {
                    }
                });

hardwareaccelerated=false 解决方案总是有效,但是,它大大降低了我的应用程序的速度。 我设法从该文档中找到了本地修复程序:

Hardware acceleration

基本上,我只为 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)允许关闭硬件加速仅对图像。在此之后其他一切正常。视野仍然有些紧张,但不是很明显。图片加载!耶!