gpt4 book ai didi

android - 使用 android.support.v7.widget.ContentFrameLayout.setDecorPadding 在某些设备上应用程序崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:53:23 28 4
gpt4 key购买 nike

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

@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 个 fragment 的 viewpager。

<?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

<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 的初始化也在该 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 库。请仅使用一个支持库,然后问题将得到解决。

关于android - 使用 android.support.v7.widget.ContentFrameLayout.setDecorPadding 在某些设备上应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47842279/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com