【问题标题】:Android Didn't find classAndroid 找不到课程
【发布时间】:2016-04-28 06:37:35
【问题描述】:

我正在学习 Gif 教程,并在我的 wear/java/com.example.marcus.prog 文件夹中创建了一个名为“GIFView”的自定义类,但我无法从我的 XML 布局中引用该类。我尝试了各种组合,但我不断收到两个关于找不到类的错误。

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.marcus.prog/com.example.marcus.prog.AttackScreen}: android.view.InflateException: Binary XML file line #20: Error inflating class com.example.marcus.prog.GIFView

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.marcus.prog.GIFView" on path: DexPathList[[zip file "/system/framework/com.google.android.wearable.jar", zip file "/data/app/com.example.marcus.prog-4/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

我的 XML 文件看起来像

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:deviceIds="wear"
android:orientation="vertical"
>
<prog.GIFView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   />

谢谢

【问题讨论】:

  • 你在布局中引用的包和类名是什么GIFView?

标签: java android xml


【解决方案1】:

在您的布局文件中使用com.example.marcus.prog.GIFView 而不是prog03wear.GIFView。

【讨论】:

  • 对不起。这只是写问题时的一个错字
【解决方案2】:

在你的 xml 中试试这个xmlns:app="http://schemas.android.com/apk/res-auto"

【讨论】:

    猜你喜欢
    • 2017-01-20
    • 2014-12-19
    • 2016-12-02
    • 2014-09-29
    • 1970-01-01
    • 1970-01-01
    • 2019-09-10
    • 2023-03-07
    • 1970-01-01
    相关资源
    最近更新 更多