gpt4 book ai didi

android - Arcore fragment 在启动时崩溃

转载 作者:行者123 更新时间:2023-11-29 00:53:34 26 4
gpt4 key购买 nike

刚开始使用 ARCore。我想在飞机上显示一个简单的 3d 模型。我使用的是 ARCore 1.10.0 版。当我启动应用程序时,应用程序崩溃并显示以下堆栈跟踪:

这是我的布局

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<fragment
android:id="@+id/ar_fragment"
android:name="com.google.ar.sceneform.ux.ArFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<include
android:id="@+id/overlay"
layout="@layout/overlay"
app:showOverlay="@{showOverlay}" />

</FrameLayout>

我使用数据绑定(bind)来扩充布局。我不知道我做错了什么。看起来找不到 ArFragment。

2019-07-23 14:05:15.209 12108-12108/com.icapps.arcapps E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.icapps.arcapps, PID: 12108
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.icapps.arcapps/com.icapps.arcapps.activity.products.PlantDetailActivity}: android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3037)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class fragment
Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.ar.sceneform.ux.ArFragment: calling Fragment constructor caused an exception
at androidx.fragment.app.Fragment.instantiate(Fragment.java:532)
at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
at androidx.fragment.app.FragmentManagerImpl$6.instantiate(FragmentManagerImpl.java:2850)
at androidx.fragment.app.FragmentManagerImpl.onCreateView(FragmentManagerImpl.java:3195)
at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:134)
at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:357)
at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:336)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:545)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:303)
at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:284)
at com.icapps.arcapps.activity.products.PlantDetailActivity.onCreate(PlantDetailActivity.kt:39)
at android.app.Activity.performCreate(Activity.java:7149)
at android.app.Activity.performCreate(Activity.java:7140)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3017)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
2019-07-23 14:05:15.210 12108-12108/com.icapps.arcapps E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at androidx.fragment.app.Fragment.instantiate(Fragment.java:514)
... 33 more
Caused by: java.lang.BootstrapMethodError: Exception from call site #38 bootstrap method
at com.google.ar.sceneform.ux.BaseArFragment.<init>(BaseArFragment.java:97)
at com.google.ar.sceneform.ux.ArFragment.<init>(ArFragment.java:35)
... 36 more
Caused by: java.lang.ClassCastException: Bootstrap method returned null
... 38 more
2019-07-23 14:05:15.211 12108-12108/com.icapps.arcapps E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.icapps.arcapps, PID: 12108
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.icapps.arcapps/com.icapps.arcapps.activity.products.PlantDetailActivity}: android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3037)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class fragment
Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.ar.sceneform.ux.ArFragment: calling Fragment constructor caused an exception
at androidx.fragment.app.Fragment.instantiate(Fragment.java:532)
at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
at androidx.fragment.app.FragmentManagerImpl$6.instantiate(FragmentManagerImpl.java:2850)
at androidx.fragment.app.FragmentManagerImpl.onCreateView(FragmentManagerImpl.java:3195)
at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:134)
at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:357)
at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:336)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:545)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:303)
at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:284)
at com.icapps.arcapps.activity.products.PlantDetailActivity.onCreate(PlantDetailActivity.kt:39)
at android.app.Activity.performCreate(Activity.java:7149)
at android.app.Activity.performCreate(Activity.java:7140)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3017)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
2019-07-23 14:05:15.212 12108-12108/com.icapps.arcapps E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at androidx.fragment.app.Fragment.instantiate(Fragment.java:514)
... 33 more
Caused by: java.lang.BootstrapMethodError: Exception from call site #38 bootstrap method
at com.google.ar.sceneform.ux.BaseArFragment.<init>(BaseArFragment.java:97)
at com.google.ar.sceneform.ux.ArFragment.<init>(ArFragment.java:35)
... 36 more
Caused by: java.lang.ClassCastException: Bootstrap method returned null
... 38 more```

最佳答案

我忘了添加编译选项

android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

关于android - Arcore fragment 在启动时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57163946/

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