使用android.support.v7.widget.ContentFrameLayout.setDecorPadding的某些设备上的应用程序崩溃 [英] Application crash on some devices with android.support.v7.widget.ContentFrameLayout.setDecorPadding

查看:428
本文介绍了使用android.support.v7.widget.ContentFrameLayout.setDecorPadding的某些设备上的应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mypackage/com.mypackage.activities.HomeActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.ContentFrameLayout.setDecorPadding(int, int, int, int)' on a null object reference
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2721)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2782)
       at android.app.ActivityThread.-wrap12(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1509)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6286)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.ContentFrameLayout.setDecorPadding(int, int, int, int)' on a null object reference
       at android.support.v7.app.AppCompatDelegateImplV9.applyFixedSizeWindow(AppCompatDelegateImplV9.java:537)
       at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:331)
       at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
       at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
       at com.watchlivetv.onlineradioapp.activities.HomeActivity.onCreate(HomeActivity.java:99)
       at android.app.Activity.performCreate(Activity.java:6778)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1121)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2675)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2782)
       at android.app.ActivityThread.-wrap12(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1509)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6286)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

我已经看到某些用户在控制台上崩溃.请从此处查看更多详细信息 http://crashes.to/s/c98e1c603ef

I have seen above a crash on a console for some user.please see more details from here http://crashes.to/s/c98e1c603ef

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

        Toolbar toolbar = (Toolbar) findViewById(R.id.mainToolBar);
        setSupportActionBar(toolbar);

        actionBar = toolbar.findViewById(R.id.zalunuActionBar);
        viewPager = findViewById(R.id.pager);
        actionBar.setTabListener(this);
        viewPager.setAdapter(new MainPagerAdapter(getFragmentManager()));
        viewPager.setOffscreenPageLimit(viewPager.getChildCount());
        viewPager.addOnPageChangeListener(this);

    }

在这里,我更新了mainActivity代码,其中有4个片段的viewpager.

Here,I have update mainActivity code there is viewpager with 4 fragment.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="false"
    tools:openDrawer="end">

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

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:fitsSystemWindows="true">

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

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

</android.support.v4.widget.DrawerLayout>

这是R.layout.activity_main

Here is R.layout.activity_main

<RelativeLayout 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:layout_width="match_parent"
    android:layout_height="match_parent">


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

        <android.support.v7.widget.Toolbar
            android:id="@+id/mainToolBar"
            style="@style/toolbar"
            app:contentInsetLeft="0dp"
            app:contentInsetStart="0dp">

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

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


    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/footerLayout"
        android:layout_below="@+id/appBarLayout" />


    <LinearLayout
        android:id="@+id/footerLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:gravity="center_horizontal"
        android:orientation="vertical">

        <RelativeLayout
            android:id="@+id/bannerLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />


    </LinearLayout>

</RelativeLayout>

我还在自己的应用程序中使用过Appodeal和Admob广告.因此,在此活动中也要完成该SDK的初始化.

I have also used Appodeal and Admob ads in my application.so initialization of that SDK is also done in this activity.

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven {
        url "https://maven.google.com"
    }
}

android {

    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "projectId"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 41
        versionName "5.0.5"
        multiDexEnabled true
        ndk {
            abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
        }
        signingConfig signingConfigs.config
        manifestPlaceholders = [onesignal_app_id               : OneSignalID,
                                onesignal_google_project_number: "REMOTE"]
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            lintOptions {
                disable 'MissingTranslation'
            }
            signingConfig signingConfigs.config
        }
        debug {
            signingConfig signingConfigs.config
            minifyEnabled false
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
        }
    }
    productFlavors {
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

}

crashlytics {
    enableNdk true
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation files('libs/org.apache.http.legacy.jar')
    implementation files('libs/twitter4j-core-4.0.2.jar')
    implementation project(':appiraterandroidmaster')
    implementation project(path: ':vitamio')
    implementation files('libs/appodeal-2.1.7.jar')
    implementation files('libs/YouTubeAndroidPlayerApi.jar')
    implementation files('libs/jdom2-2.0.6.jar')
    implementation('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
        transitive = true
    }
    implementation('com.crashlytics.sdk.android:crashlytics-ndk:2.0.0@aar') {
        transitive = true
    }
    implementation 'com.android.volley:volley:1.0.0'
    implementation 'com.android.support:support-v13:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.google.android.gms:play-services-ads:11.8.0'
    implementation 'com.google.android.gms:play-services-location:11.8.0'
    implementation 'com.google.android.gms:play-services-gcm:11.8.0'
    implementation 'com.google.firebase:firebase-appindexing:11.8.0'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
    implementation 'com.facebook.android:facebook-android-sdk:4.27.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.onesignal:OneSignal:3.6.5'
    implementation 'com.github.bumptech.glide:glide:4.3.1'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.github.rubensousa:gravitysnaphelper:1.3'
    implementation 'com.android.support:multidex:1.0.2'
    implementation 'com.github.clans:fab:1.6.4'
    /*admod mediation*/
    implementation 'com.facebook.android:audience-network-sdk:4.26.1'
    implementation 'com.google.ads.mediation:facebook:4.26.1.0'
    implementation 'com.applovin:applovin-sdk:7.6.0'
    implementation 'com.google.ads.mediation:applovin:7.6.0.0'
    implementation('com.vungle:publisher-sdk-android:5.3.0@aar') {
        transitive = true
    }
    implementation 'com.google.ads.mediation:vungle:5.3.0.0'
    implementation 'com.inmobi.monetization:inmobi-ads:7.0.0'
    implementation 'com.google.ads.mediation:inmobi:6.2.4.0'
    implementation 'com.adcolony:sdk:3.2.1'
    implementation 'com.android.support:support-annotations:27.0.2'
    implementation 'com.google.ads.mediation:adcolony:3.2.1.1'
    //    admob mediation end
    testImplementation 'junit:junit:4.12'
    implementation files('libs/OneAudience-sdk-release-6.0.0.0.jar')
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

推荐答案

该错误是由于支持库之间的冲突引起的.您同时使用了support.v4库和support.v7库.请仅使用一个支持库,此问题将得到解决.

The error is because of conflict between support libraries. You used support.v4 library and support.v7 library both. Please use only one support library then the problem will be fixed.

这篇关于使用android.support.v7.widget.ContentFrameLayout.setDecorPadding的某些设备上的应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆