- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
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/
我是 C 语言新手,我编写了这个 C 程序,让用户输入一年中的某一天,作为返回,程序将输出月份以及该月的哪一天。该程序运行良好,但我现在想简化该程序。我知道我需要一个循环,但我不知道如何去做。这是程序
我一直在努力找出我的代码有什么问题。这个想法是创建一个小的画图程序,并有红色、绿色、蓝色和清除按钮。我有我能想到的一切让它工作,但无法弄清楚代码有什么问题。程序打开,然后立即关闭。 import ja
我想安装screen,但是接下来我应该做什么? $ brew search screen imgur-screenshot screen
我有一个在服务器端工作的 UDP 套接字应用程序。为了测试服务器端,我编写了一个简单的 python 客户端程序,它发送消息“hello world how are you”。服务器随后应接收消息,将
我有一个 shell 脚本,它运行一个 Python 程序来预处理一些数据,然后运行一个 R 程序来执行一些长时间运行的任务。我正在学习使用 Docker 并且我一直在运行 FROM r-base:l
在 Linux 中。我有一个 c 程序,它读取一个 2048 字节的文本文件作为输入。我想从 Python 脚本启动 c 程序。我希望 Python 脚本将文本字符串作为参数传递给 c 程序,而不是将
对于一个类,我被要求编写一个 VHDL 程序,该程序接受两个整数输入 A 和 B,并用 A+B 替换 A,用 A-B 替换 B。我编写了以下程序和测试平台。它完成了实现和行为语法检查,但它不会模拟。尽
module Algorithm where import System.Random import Data.Maybe import Data.List type Atom = String ty
我想找到两个以上数字的最小公倍数 求给定N个数的最小公倍数的C++程序 最佳答案 int lcm(int a, int b) { return (a/gcd(a,b))*b; } 对于gcd,请查看
这个程序有错误。谁能解决这个问题? Error is :TempRecord already defines a member called 'this' with the same paramete
当我运行下面的程序时,我在 str1 和 str2 中得到了垃圾值。所以 #include #include #include using namespace std; int main() {
这是我的作业: 一对刚出生的兔子(一公一母)被放在田里。兔子在一个月大时可以交配,因此在第二个月的月底,每对兔子都会生出两对新兔子,然后死去。 注:在第0个月,有0对兔子。第 1 个月,有 1 对兔子
我编写了一个程序,通过对字母使用 switch 命令将十进制字符串转换为十六进制,但是如果我使用 char,该程序无法正常工作!没有 switch 我无法处理 9 以上的数字。我希望你能理解我,因为我
我是 C++ 新手(虽然我有一些 C 语言经验)和 MySQL,我正在尝试制作一个从 MySQL 读取数据库的程序,我一直在关注这个 tutorial但当我尝试“构建”解决方案时出现错误。 (我正在使
仍然是一个初学者,只是尝试使用 swift 中的一些基本函数。 有人能告诉我这段代码有什么问题吗? import UIKit var guessInt: Int var randomNum = arc
我正在用 C++11 编写一个函数,它采用 constant1 + constant2 形式的表达式并将它们折叠起来。 constant1 和 constant2 存储在 std::string 中,
我用 C++ 编写了这段代码,使用运算符重载对 2 个矩阵进行加法和乘法运算。当我执行代码时,它会在第 57 行和第 59 行产生错误,非法结构操作(两行都出现相同的错误)。请解释我的错误。提前致谢:
我是 C++ 的初学者,我想编写一个简单的程序来交换字符串中的两个字符。 例如;我们输入这个字符串:“EXAMPLE”,我们给它交换这两个字符:“E”和“A”,输出应该类似于“AXEMPLA”。 我在
我需要以下代码的帮助: 声明 3 个 double 类型变量,每个代表三角形的三个边中的一个。 提示用户为第一面输入一个值,然后 将用户的输入设置为您创建的代表三角形第一条边的变量。 将最后 2 个步
我是新来的,如果问题不好请见谅 任务:将给定矩阵旋转180度 输入: 1 4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 输出: 16 15 14 13 12 11
我是一名优秀的程序员,十分优秀!