当前位置: 首页 > 知识库问答 >
问题:

原因:Android.View.InflateException

邴宏大
2023-03-14

我正试图打开我的应用程序,但这是一个错误的膨胀

日志:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.pokedex, PID: 10007
java.lang.RuntimeException: Unable to start activity 
ComponentInfo{com.example.pokedex/com.example.pokedex.ui.main.MainActivity}: 
android.view.InflateException: Binary XML file line #14 in com.example.pokedex:layout/main_activity: 
Binary XML file line #14 in com.example.pokedex:layout/main_activity: Error inflating class 
androidx.fragment.app.FragmentContainerView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
    at 
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7656)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
 Caused by: android.view.InflateException: Binary XML file line #14 in 
com.example.pokedex:layout/main_activity: Binary XML file line #14 in 
com.example.pokedex:layout/main_activity: Error inflating class 
androidx.fragment.app.FragmentContainerView
 Caused by: android.view.InflateException: Binary XML file line #14 in 
com.example.pokedex:layout/main_activity: Error inflating class 
androidx.fragment.app.FragmentContainerView
 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void 
android.widget.TextView.setOnClickListener(android.view.View$OnClickListener)' on a null object 
reference
    at com.example.pokedex.ui.entrada.EntradaFragment.onCreate(EntradaFragment.kt:31)
    at androidx.fragment.app.Fragment.performCreate(Fragment.java:2936)
    at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:472)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:278)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177)
    at 
androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2094)
    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1990)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3122)
    at androidx.fragment.app.FragmentManager.dispatchCreate(FragmentManager.java:3045)
    at androidx.fragment.app.Fragment.onCreate(Fragment.java:1867)
    at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.java:264)
    at androidx.fragment.app.Fragment.performCreate(Fragment.java:2936)
    at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:472)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:278)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177)
    at 
androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2094)
    at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1959)
    at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:311)
    at androidx.fragment.app.FragmentContainerView.<init>(FragmentContainerView.java:176)
    at 
  androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView
(FragmentLayoutInflaterFactory.java:52)
    at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135)
    at 
androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:313)
    at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:292)
    at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1067)
E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:995)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1121)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1124)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:680)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
    at com.example.pokedex.ui.main.MainActivity.onCreate(MainActivity.kt:41)
    at android.app.Activity.performCreate(Activity.java:8000)
    at android.app.Activity.performCreate(Activity.java:7984)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
    at 
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7656)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

它拉出错误的片段行:

 reg_novo_user.setOnClickListener {
        val intent = Intent(activity, RegistroActivity::class.java)
        startActivity(intent)
    }

这段代码在一个条目片段中,我正在使用firebase实现一个登录

就在我的startActivity下面,我有一个“finish()”,但由于我在一个片段中,我必须删除它,我不知道如果没有这个方法,问题是否会出现

共有1个答案

东方智敏
2023-03-14

看起来RegistroActivity正在尝试初始化一个片段,但失败了。

原因:java.lang.NullPointerException:尝试对空对象调用虚拟方法“void android.widget.textview.SetonClickListener(android.view.view$OnClickListener

此错误消息行表示您试图在尚未初始化的textview上设置侦听器。尝试在onViewCreated方法中初始化侦听器。

应该管用

 类似资料:
  • 当我试图使用Spring-Boot-Test在Spring-Boot1.5.3版本中运行控制器测试时,我发现了以下错误:java.lang.ClassNotFoundException:javax.servlet.ServletException 我正在运行ContactsManagementControllerIntegrationTest.java类,使用(eclipse)右键单击文件并以ju

  • 问题内容: 我有2个作业,这些作业在Sql Server数据库中读取并产生数据。作业偶尔会因System.Transactions.TransactionInDoubtException而崩溃。确切的堆栈跟踪为: 我在Google上搜索了一下,找到了有关MSDTC的信息,但是我认为这不是问题,因为事务应该是本地的,因为作业只能在单个数据库上工作。以下查询: 显示数据库上没有死锁,因此死锁不可能是原

  • 是否达到了同时会话/事务的数量?有人有什么想法吗?

  • 这是我的片段: Java中的inputText片段: 原因:java.lang.IllegalStateException:Fragment de.company.android.inputtext.InputTextFragment没有创建视图。在Android.app.fragmentManagerimpl.oncreateView(fragmentManager.java:2253),在An

  • 问题内容: 由于当前在Spring中对Hibernate 4的支持不足,我不得不将Hibernate从版本4降级到版本3(具体来说是3.3.2GA),现在该项目在尝试使用hbm2ddl生成架构时无法构建。这个错误太模糊了,谷歌并没有带来太多收益。 这是我的pom.xml: 跑步 失败于 完整的堆栈跟踪为: 希望有人可以对此有所启发! 问题答案: 在尝试使havennate模型使maven引导数据库

  • 问题内容: 我有这个小代码,用于将我的jsp连接到我的mysql数据库。 我已将连接器添加到我的构建路径中: 但我仍然收到此错误: java.lang.ClassNotFoundException:com.mysql.jdbc.Driver 有人可以帮我吗? 问题答案: 构建路径用于编译目的(假设您没有将mysql连接器jar包含在软件包中的代码)。 如果这是Web应用程序,请将其添加到lib文件