Android App崩溃,无法解决问题

时间:2018-05-13 00:02:03

标签: android android-6.0-marshmallow

我有2部手机,1部运行v8.0的samsung S8和运行v6.0的LG G4。我已经插入同一台计算机并构建应用程序并在手机上运行它。一切看起来都不错三星,所有安装和LG看起来都不错,直到我按下第一个活动的菜单按钮。

我的第一个活动加载了一个片段,它将3点菜单放在右上角。我在菜单中只有一个项目,它打开一个新活动,其中包含可供选择的项目列表。在LG按下这个3点菜单时,应用程序崩溃,但在S8上,它打开菜单,允许我选择1项并打开下一个活动。

寻找有关这方面的任何想法。

我得到的错误:

I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
I/AudioManagerEx: AudioManagerEx created
I/ListPopupWindow: Could not find method setEpicenterBounds(Rect) on PopupWindow. Oh well.
W/ResourceType: Failure getting entry for 0x7f07013a (t=6 e=314) (error -75)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.czdev.booktimeline, PID: 15910
                  android.content.res.Resources$NotFoundException: Resource ID #0x7f07013a
                      at android.content.res.Resources.getValue(Resources.java:1401)
                      at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:332)
                      at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:197)
                      at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:190)
                      at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
                      at android.support.v7.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:425)
                      at android.support.v7.view.menu.ListMenuItemView.initialize(ListMenuItemView.java:116)
                      at android.support.v7.view.menu.MenuAdapter.getView(MenuAdapter.java:100)
                      at android.support.v7.view.menu.MenuPopup.measureIndividualMenuWidth(MenuPopup.java:160)
                      at android.support.v7.view.menu.StandardMenuPopup.tryShow(StandardMenuPopup.java:153)
                      at android.support.v7.view.menu.StandardMenuPopup.show(StandardMenuPopup.java:187)
                      at android.support.v7.view.menu.MenuPopupHelper.showPopup(MenuPopupHelper.java:290)
                      at android.support.v7.view.menu.MenuPopupHelper.tryShow(MenuPopupHelper.java:175)
                      at android.support.v7.widget.ActionMenuPresenter$OpenOverflowRunnable.run(ActionMenuPresenter.java:803)
                      at android.os.Handler.handleCallback(Handler.java:739)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:148)
                      at android.app.ActivityThread.main(ActivityThread.java:5525)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Application terminated.

这是我的Gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.oss.licenses.plugin'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "<com.android.application>"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 25
        versionName "0.8"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.android.gms:play-services-oss-licenses:15.0.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:support-vector-drawable:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'

}
repositories {
    mavenCentral()
}

这是我的第一个片段:

public class HomeFrag extends Fragment {

    View rootView;

    public HomeFrag() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_home, container, false);

        Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
        toolbar.setTitle(R.string.app_name);

        ((MainActivity) Objects.requireNonNull(getActivity())).setSupportActionBar(toolbar);
        setHasOptionsMenu(true);

        return rootView;
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.main_menu, menu);
        super.onCreateOptionsMenu(menu, inflater);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.menu_action_info) {
            startActivity(new Intent(getContext(), InfoMenu.class));
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

这是我的菜单:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto" >
    <item
        android:id="@+id/menu_action_info"
        android:icon="@drawable/ic_info_outline_white_24dp"
        android:orderInCategory="100"
        android:title="@string/menu_info_action"
        app:showAsAction="never" />
</menu>

任何想法都会很棒。

0 个答案:

没有答案