我真的不知道发生了什么。在Android Studio上,每件事情都运行良好,但是当我尝试在手机上运行应用程序时,会出现此错误。
AndroidRuntime: FatalException:
Process: com.example.vb.textreader, PID: 29524
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.vb.textreader/com.example.vb.textreader.ocrcapture}: android.view.InflateException: Binary XML file line #10: Error inflating class com.example.vb.textreader.CameraSourcePreview
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394)
at android.app.ActivityThread.access$800(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5276)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.example.vb.textreader.CameraSourcePreview
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:508)
at android.view.LayoutInflater.inflate(LayoutInflater.java:418)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.vb.textreader.ocrcapture.onCreate(ocrcapture.java:67)
at android.app.Activity.performCreate(Activity.java:6041)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1109)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2285)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394)
at android.app.ActivityThread.access$800(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5276)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.vb.textreader.CameraSourcePreview" on path: DexPathList[[zip file "/data/app/com.example.vb.textreader-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.view.LayoutInflater.createView(LayoutInflater.java:575)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:747)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:508)
at android.view.LayoutInflater.inflate(LayoutInflater.java:418)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.vb.textreader.ocrcapture.onCreate(ocrcapture.java:67)
at android.app.Activity.performCreate(Activity.java:6041)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1109)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2285)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394)
at android.app.ActivityThread.access$800(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5276)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Suppressed: java.lang.ClassNotFoundException: Didn't find class "com.example.vb.textreader.CameraSourcePreview" on path: DexPathList[[dex file "/data/data/com.example.vb.textreader/files/instant-run/dex/slice-support-annotations-23.4.0_932ddf769cdf6f7ff910db3bda1b13074bfa8aca-classes.dex", dex file "/data/data/com.example.vb.textreader/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.example.vb.textreader/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.example.vb.textreader/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.example.vb.textreader/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.example.vb.textreader/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.example.vb.textreader/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.example.vb.textreader/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.example.vb.textreader/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.example.vb.textreader/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.example.vb.textreader/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.example.vb.textreader/files/instant-run/dex/slice-internal_impl-23.4.0_ed28e3a48cbb17d2b91d4065fb1975ae0dafdc68-classes.dex", dex file "/data/data/com.example.vb.textreader/fil
我正在尝试在Android上创建一个OCR应用程序。在Android Studio中查看的代码中没有错误。非常感谢任何帮助。
XML代码
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
<com.example.vb.textreader.proprietary.CameraSourcePreview
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.example.vb.textreader.GraphicOverlay
android:id="@+id/graphicOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.example.vb.textreader.proprietary.CameraSourcePreview>
答案 0 :(得分:0)
似乎有一个自定义视图 com.example.vb.textreader.CameraSourcePreview ,它在导致问题的XML布局文件中使用。
检查它的属性和实现。如果它依赖于库,请检查build.gradle中的依赖项。
答案 1 :(得分:0)
您似乎正在尝试使用com.example.vb.textreader.CameraSourcePreview
,它必须是您实施的自定义视图。我想到的一件事是检查自定义视图是否完全位于该位置。
答案 2 :(得分:0)
我不确定提供的解决方案是否与您的问题有关
尝试compile 'com.android.support:design:*****'
代替com.android.support:appcompat-v7:*****