Java Android应用程序启动后崩溃,无任何错误

Java Android应用程序启动后崩溃,无任何错误,java,android,android-fragments,Java,Android,Android Fragments,我的android应用程序有问题。它以前工作得很好,但一开始就崩溃了,没有任何错误,我也不知道为什么。我在我的类中注释了(//)很多代码,只留下了一些对工作很重要的东西,但仍然存在同样的问题。我有一个主活动和两个片段 当我创建片段时,它会自动创建文件夹布局并将java类放在那里。 片段java类(列表,集合): 主要活动类别: public class MainActivity extends AppCompatActivity { /** * The {@link and

我的android应用程序有问题。它以前工作得很好,但一开始就崩溃了,没有任何错误,我也不知道为什么。我在我的类中注释了(//)很多代码,只留下了一些对工作很重要的东西,但仍然存在同样的问题。我有一个主活动和两个片段

当我创建片段时,它会自动创建文件夹布局并将java类放在那里。 片段java类(列表,集合):

主要活动类别:

public class MainActivity extends AppCompatActivity {

    /**
     * The {@link android.support.v4.view.PagerAdapter} that will provide
     * fragments for each of the sections. We use a
     * {@link FragmentPagerAdapter} derivative, which will keep every
     * loaded fragment in memory. If this becomes too memory intensive, it
     * may be best to switch to a
     * {@link android.support.v4.app.FragmentStatePagerAdapter}.
     */
    private SectionsPagerAdapter mSectionsPagerAdapter;

    /**
     * The {@link ViewPager} that will host the section contents.
     */
    private ViewPager mViewPager;

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

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        // Create the adapter that will return a fragment for each of the three
        // primary sections of the activity.
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

        // Set up the ViewPager with the sections adapter.
        mViewPager = (ViewPager) findViewById(R.id.container);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
        tabLayout.setupWithViewPager(mViewPager);

        FloatingActionButton addButton = (FloatingActionButton) findViewById(R.id.add);
        addButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });

    }

    /**
     * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
     * one of the sections/tabs/pages.
     */
    public class SectionsPagerAdapter extends FragmentPagerAdapter {

        SectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            switch(position) {
                case 0:
                    return new Set();
                case 1:
                    return new List();
                default:
                    return null;
            }
        }

        @Override
        public int getCount() {
            // Show 3 total pages.
            return 2;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch (position) {
                case 0:
                    return "ZADÁVÁNÍ";
                case 1:
                    return "SEZNAM";
            }
            return null;
        }
    }
}
活动_main.xml(自动生成):


fragments.xml文件:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".layout.List">

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

        <TextView
            android:text="List"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textView6" />

        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </GridLayout>
</FrameLayout>

从您的日志输出中,我看到了这一行:

01-01 15:01:58.206 7457-7457/cz.sudoman281.kubirovacikalkulacka W/系统:类加载器引用的未知路径: /data/app/cz.sudoman281.kubirovacikalkulacka-1/lib/arm64

我猜您的本机库有问题,请仔细检查Make或cmakebuid文件,确保您从Java类正确加载了本机库


另一件事是,如果您在使用Android Nougat的设备/模拟器上运行应用程序,您可能需要检查您的本机库是否未链接到非NDK库,如下所述:

从您的日志输出中,我看到了以下行:

01-01 15:01:58.206 7457-7457/cz.sudoman281.kubirovacikalkulacka W/系统:类加载器引用的未知路径: /data/app/cz.sudoman281.kubirovacikalkulacka-1/lib/arm64

我猜您的本机库有问题,请仔细检查Make或cmakebuid文件,确保您从Java类正确加载了本机库


另一件事是,如果您在使用Android Nougat的设备/模拟器上运行应用程序,您可能需要检查您的本机库是否未链接到非NDK库,如下所述:

当应用程序启动时,logcat筛选器并不总是显示日志。在集成库时,我遇到了类似的问题。这就是我发现问题所在的原因


在调试模式下启动应用程序,在
onCreate
方法的第一行设置断点,并继续执行(F8),直到出现崩溃。

启动应用程序时,logcat筛选器并不总是显示日志。在集成库时,我遇到了类似的问题。这就是我发现问题所在的原因


在调试模式下启动应用程序,在
onCreate
方法的第一行设置断点,并保持单步切换(F8)直到你得到崩溃。

使用LogCat检查与崩溃相关的Java堆栈跟踪:在返回
1
而不是
2
@commonware后尝试,我得到的只是:@ρ∑ρєK仍然不工作:/这不是Java堆栈跟踪。请注意,有时Android Studio的过滤器会变得有点咄咄逼人,所以请确保您没有按应用程序进行过滤。如果没有堆栈跟踪,则不会崩溃。请使用LogCat检查与崩溃相关的Java堆栈跟踪:在返回
1
而不是
2
@commonware后重试。我只得到以下信息:@ρѕρєK仍不工作:/n这不是Java堆栈跟踪。请注意,有时Android Studio的过滤器会变得有点咄咄逼人,所以请确保您没有按应用程序进行过滤。如果您没有得到堆栈跟踪,则不会崩溃。谢谢您的回答:)我不确定Make和CMake是什么:/This is my build.gradle:。我正在运行android 6。我不确定,请尝试将compile SDK和build tools版本降低到24,看看会发生什么。感谢您的回答:)我不确定Make和CMake是什么:/这是我的build.gradle:。我正在运行android 6。我不确定,试着将编译SDK和构建工具版本降低到24,看看会发生什么。
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="cz.sudoman281.kubirovacikalkulacka.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/appbar_padding_top"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/AppTheme.PopupOverlay">

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

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

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

    <android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".layout.List">

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

        <TextView
            android:text="List"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textView6" />

        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </GridLayout>
</FrameLayout>