Android Studio无法启动活动性ComponentInfo

案头见蠹鱼,犹胜凡俦侣。这篇文章主要讲述Android Studio无法启动活动性ComponentInfo相关的知识,希望能为你提供帮助。
[当我尝试运行该应用程序时,我在下面收到此错误,并且我不知道是什么导致了此错误。
也许项目名称,活动名称有一些错误,我真的不知道该怎么办。

E/androidRuntime: FATAL EXCEPTION: main Process: com.example.homeactivity, PID: 5486 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.homeactivity/com.example.homeactivity.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) 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 'java.lang.Class java.lang.Object.getClass()' on a null object reference at com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx.getBottomNavigationItemViews(BottomNavigationViewEx.java:569) at com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx.setTextVisibility(BottomNavigationViewEx.java:244) at com.example.homeactivity.MainActivity.onCreate(MainActivity.kt:12) at android.app.Activity.performCreate(Activity.java:6679) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)


这里是我的AndroidManifest.xml,如果您想看一下的话
< ?xml version="1.0" encoding="utf-8"?> < manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.example.homeactivity"> < application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" tools:ignore="GoogleAppIndexingWarning"> < activity android:name=".MainActivity"> < intent-filter> < action android:name="android.intent.action.MAIN" /> < category android:name="android.intent.category.LAUNCHER" /> < /intent-filter> < /activity> < /application> < /manifest>

也,这是我的MainActivity.kt:
package com.example.homeactivity import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import kotlinx.android.synthetic.main.activity_main.* class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) bottom_navigation_view.setTextVisibility(false) bottom_navigation_view.enableItemShiftingMode(false) bottom_navigation_view.enableShiftingMode(false) bottom_navigation_view.enableAnimation(false) for (i in 0 until bottom_navigation_view.menu.size()){ bottom_navigation_view.setIconTintList(i, null) } } }

这是我的“应用”:
apply plugin: 'com.android.application'apply plugin: 'kotlin-android'apply plugin: 'kotlin-android-extensions'android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { applicationId "com.example.homeactivity" minSdkVersion 21 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } }dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.core:core-ktx:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'implementation 'com.google.android.material:material:1.0.0' implementation 'com.github.ittianyu:BottomNavigationViewEx:1.2.4' }

答案我知道了,错误出在执行中:
implementation 'com.ittianyu:BottomNavigationViewEx:1.2.4'

【Android Studio无法启动活动性ComponentInfo】我只需要添加“ GitHub” xD
implementation 'com.github.ittianyu:BottomNavigationViewEx:1.2.4'


    推荐阅读