gpt4 book ai didi

java - 无法解析 java.lang.ClassNotFoundException : Didn't find class "com.example.android.camera2basic.AutoFitTextureView" in android studio?

转载 作者:行者123 更新时间:2023-12-02 02:25:53 32 4
gpt4 key购买 nike

我正在尝试解决这个恼人的错误,并且我已经尝试了所有可能的选项。我浏览了之前的答案并尝试使缓存无效并重新启动。我还确保我在 gradle 中的支持依赖项是正确的,但由于某种原因,当我在手机上运行应用程序时,它崩溃并出现以下错误。

 Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.example.android.camera2basic.AutoFitTextureView
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.example.android.camera2basic.AutoFitTextureView
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.android.camera2basic.AutoFitTextureView" on path: DexPathList[[zip file "/data/app/com.example.surajit.camera2apiexample-2/base.apk", zip file "/data/app/com.example.surajit.camera2apiexample-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.surajit.camera2apiexample-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.surajit.camera2apiexample-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.surajit.camera2apiexample-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.surajit.camera2apiexample-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.surajit.camera2apiexample-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.surajit.camera2apiexample-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.surajit.camera2apiexample-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.surajit.camera2apiexample-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.surajit.camera2apiexample-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.surajit.camera2apiexample-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.surajit.camera2apiexample-2/lib/arm, /system/lib, /vendor/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:609)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at com.example.surajit.camera2apiexample.Camera2BasicFragment.onCreateView(Camera2BasicFragment.java:455)
at android.app.Fragment.performCreateView(Fragment.java:2352)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:995)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1171)
at android.app.BackStackRecord.run(BackStackRecord.java:815)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1578)
at android.app.FragmentController.execPendingActions(FragmentController.java:371)
at android.app.Activity.performStart(Activity.java:6689)
12-12 17:00:55.442 8215-8215/? E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2687)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
12-12 17:00:58.120 804-903/? E/PROXIMITY: ProximitySensor: unknown event (type=3, code=0)

构建.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.surajit.camera2apiexample"
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}


dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:support-v13:27.0.2'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support:appcompat-v7:27.0.2'
}

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.surajit.camera2apiexample">
<uses-permission android:name="android.permission.CAMERA"/><uses-permission android:name="android.permission.FLASHLIGHT"/><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><uses-feature android:name="android.hardware.camera2.full"/>
<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">
<activity android:name=".CameraActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

</manifest>

请帮帮我。我真的很困惑这个问题。

最佳答案

这通常是因为您在 View 中使用了错误的包名称。您正在尝试将 View 包含在:

<com.example.android.camera2basic.AutoFitTextureView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
...
/>

如果我们将其与您的 AndroidManifest.xml 包名称进行比较,则可能不是正确的包名称,即 com.example.surajit.camera2apiexample:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.surajit.camera2apiexample">

...

</manifest>

因此,将 com.example.android.camera2basic.AutoFitTextureView 更改为 AutoFitTextureView 类所在的 View 包名称。可能是这样的:

<com.example.surajit.camera2apiexample.AutoFitTextureView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
...
/>

关于java - 无法解析 java.lang.ClassNotFoundException : Didn't find class "com.example.android.camera2basic.AutoFitTextureView" in android studio?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47774578/

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