如何调试我的应用程序的哪一部分导致它强制关闭(向后兼容性问题)

How to debug what part of my app is causing it to force close (backward compatibility problem)

这是我第一次尝试编写任何类型的代码,更不用说 android 应用程序了。我使用 28 的 compileSdkVersion、28 的 targetSdkVersion 和 23 的 minSdkVersion 创建了项目。该应用程序将仅在 Android Pie 上 运行 并在我尝试安装它的任何先前版本上崩溃。

一切都可以正确编译,并且在模拟器和我个人的phone(都在 Pie 上)上运行得非常好。我已经阅读了很多关于使用 Android 支持库的信息,但是,我还没有看到任何关于如何理解代码的哪些部分需要使用支持库和框架中的东西的信息。 Android Studio 可能在使用支持库中的东西的过程中向我发出了警告,但作为新手,我不知道这意味着什么,也不知道我的正确选择应该是什么。现在我明白了,我不知道如何回过头来寻找(然后修复)任何需要使用支持库的东西。

我导入了 com.android.support:appcompat-v7 并使用了 AppCompatActivity 而不是 Activity。简而言之,我使用 textViews、editTexts、spinners 和 TabHost(带有两个选项卡)。我认为 ActionBar 也可能是一个问题,但不知道如何查看是否是问题以及如何解决它。

剩下的代码是一堆if/then/else语句和一些switch语句的数学计算。

安装在 Android Pie 之前的任何 OS 上后打开应用程序时强制关闭。

来自 content_main.xml 的片段(布局):

<Spinner
    android:id="@+id/spnFromPool"
    android:layout_width="176dp"
    android:layout_height="34dp"
    android:layout_gravity="start"
    android:layout_weight="0.3"
    android:background="@drawable/bg_spinner"
    android:entries="@array/pool_type_array" />

bg_spinner.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/swimToolPrimary"/>
            <corners android:radius="10dp" />
            <stroke android:color="#000000" android:width="1dp" />
        </shape>
    </item>
    <item android:gravity="center_vertical|right" android:right="8dp">
        <layer-list>
            <item android:width="12dp" android:height="12dp"  android:gravity="center" android:bottom="10dp"
                tools:targetApi="m">
                <rotate
                    android:fromDegrees="45"
                    android:toDegrees="45">
                    <shape android:shape="rectangle">
                        <solid android:color="@color/swimToolSecondary" />
                        <stroke android:color="@color/swimToolSecondary" android:width="1dp"/>
                    </shape>
                </rotate>
            </item>
            <item android:width="20dp" android:height="10dp" android:bottom="21dp" android:gravity="center"
                tools:targetApi="m">
                <shape android:shape="rectangle">
                    <solid android:color="@color/swimToolPrimary"/>
                </shape>
            </item>
        </layer-list>
    </item>
</layer-list>

您可以在 android 工作室的日志中检查问题,方法是在 logcat 的 top-right 角中选择 "No Filters" 并过滤数据,您可以添加包名称您的应用程序在搜索栏中。