Android 应用程序因 SIG 9 而崩溃

标签 android process kill-process

我知道,通常你会告诉我检查日志(在崩溃之前,看看我是否遗漏了什么)。 .没什么,因为当我尝试开始一项新 Activity 时,应用程序无论如何都会崩溃。仅有的两个有效 Activity 是 SplashScreenSignIn

为了找出问题所在,我做了一些简单的事情

public class SplashScreen extends AppCompatActivity{
private final static String TAG = SplashScreen.class.getSimpleName();
private final static int DELAY = 2000;

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash_screen);

    startActivity(new Intent(this, Root.class));
    finish();
}

和 Root.class

public class Root extends AppCompatActivity {
private final static String TAG = Root.class.getSimpleName();
private long backPressedTime = 0;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    Log.i(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    Log.i(TAG, "super.onCreate");
    setContentView(R.layout.trending);
    Log.i(TAG, "setContentView");
}

所以我设置了一些日志,看起来我转到了第二个日志。第三个 setcontentView 没有显示在控制台中。问题更奇怪,因为无论我尝试开始上什么课,它都会发生。

提及:

  • 检查了日志,没有任何异常(警告 03-13 13:52:33.302 23233-23233/com.example.codkom.shirtex W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable ...

  • 在应用程序上工作了几天,并在我的个人设备上进行了测试(工作没有问题,即使现在它确实如此)但在任何其他设备上都没有..

  • 如果算的话,我使用 multidex,我覆盖了我的 Application 类并按照文档执行了 Multidex.install(context);(这样说是因为我猜测这可能是由 Multidex 引起的,但在没有 multidex 的情况下在 API 21+ 上进行了测试,结果没问题(因为 API 21+ 自行处理 multidex)

  • 我的项目中有 7 个 Activity ,其中 3 个出现问题

我已经到了不知道还能做什么的地步.. 所以这就是我带着这个问题来到这里的原因。

要求: enter image description here

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<!-- The main content view -->
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/cl_"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:animateLayoutChanges="true"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <android.support.design.widget.AppBarLayout
        android:background="@drawable/overlay"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            app:layout_scrollFlags="enterAlways|scroll"
            app:navigationIcon="@drawable/ic_hamburger_menu">

        </android.support.v7.widget.Toolbar>

    </android.support.design.widget.AppBarLayout>

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/standard_15_dp"
        android:id="@+id/fab_"
        android:backgroundTint="@color/blue"
        app:fabSize="normal"
        android:src="@drawable/ic_plus"
        app:layout_anchor="@id/content_frame"
        app:layout_anchorGravity="center|bottom"
        app:layout_behavior="com.example.codkom.shirtex.ScrollAwareFABBehavior"/>

</android.support.design.widget.CoordinatorLayout>

<!-- The navigation drawer -->
<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start">

    <include layout="@layout/mainmenu_activity"/>

</android.support.design.widget.NavigationView>

在 list 中

<application
    android:name=".application.ShirTexApp"
    android:allowBackup="true"
    android:icon="@drawable/ic_app_logo"
    android:configChanges="orientation|keyboardHidden|screenSize"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.AppCompat"
    android:fullBackupContent="true">
<activity android:name=".activities.Root" android:theme="@style/Theme.AppCompat.Light.NoActionBar" android:windowSoftInputMode="adjustPan"/>
</application>

最佳答案

看来,您正在为图像使用矢量可绘制对象。 Vector Drawables 不支持低于 5.0 的版本。要在 5.0 以下和所有设备中制作支持矢量绘图,请按照以下步骤操作。

第 1 步:

首先不得不提到gradle中。 提供支持库

implementation 'com.android.support:appcompat-v7:23.2.0'

启用 Vecor Drawable 支持

android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
   }  
}

第 2 步:

在设计 XML 时,直接使用 ImageViews 时应该使用 srcCompat 而不是 Vector Drawables 的 src

<ImageView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  app:srcCompat="@drawable/ic_add" />

在支持Views的leftDrawable、rightDrawable等组件的drawable时,需要将vector包裹在drawable中。

ic_action_wrapped.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/ic_action_search_vector"/>
</selector>

第 3 步: 当您在运行时加载矢量图像时,您必须像那样加载图像。

AppCompatResources.getDrawable(mContext,R.drawable.ic_action_search_vector);

对于 Application 类或您的 Activity 中的某些设备。

static {
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    }

在你的情况下 基于日志,Toolbar 或 FloatingActionButton 有矢量图像变化并检查。

谷歌文档:official android docs

Stack Overflow 也有很多矢量绘图的引用。

希望对您有所帮助。

关于Android 应用程序因 SIG 9 而崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49255864/

相关文章:

android - ACRA 自定义日志报告器

android - 应用程序 :transformClassesAndResourcesWithProguardForRelease

Python 进程完成

windows - "fuser -k <folder>"的 Windows 批处理等价物是什么?

android - 在进程死亡时以编程方式处理取消注册 BroadcastReceiver

linux - 如何查找和停止/终止从 shell 脚本启动的进程?

java - 如何设置 ScrollView 的X Y和高度宽度

android - 为应用程序小部件实现 onclick 监听器

java - 在Java中使用cmd复制文件的问题

python - 如何为每个目录创建一个进程?