gpt4 book ai didi

java - 包含 GaugeView 库后的 Android ClassNotFoundException

转载 作者:行者123 更新时间:2023-12-01 14:37:35 26 4
gpt4 key购买 nike

我正在尝试使用 github 中的仪 TableView
随库提供的示例应用程序运行完美!

但是当我尝试将库包含到项目中(属性>构建路径>项目>(添加库项目))时,将 View 放入我的布局中并尝试在它抛出的代码中获取对 View 的引用类NotFoundException

以下是我通过 logcat 得到的错误:

E/AndroidRuntime(  542): FATAL EXCEPTION: main
E/AndroidRuntime( 542): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.guagetest/com.example.guagetest.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class org.codeandmagic.android.gauge.GaugeView
E/AndroidRuntime( 542): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
E/AndroidRuntime( 542): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
E/AndroidRuntime( 542): at android.app.ActivityThread.access$600(ActivityThread.java:122)
E/AndroidRuntime( 542): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
E/AndroidRuntime( 542): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 542): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 542): at android.app.ActivityThread.main(ActivityThread.java:4340)
E/AndroidRuntime( 542): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 542): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 542): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 542): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 542): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 542): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class org.codeandmagic.android.gauge.GaugeView
E/AndroidRuntime( 542): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
E/AndroidRuntime( 542): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
E/AndroidRuntime( 542): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
E/AndroidRuntime( 542): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/AndroidRuntime( 542): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
E/AndroidRuntime( 542): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
E/AndroidRuntime( 542): at android.app.Activity.setContentView(Activity.java:1835)
E/AndroidRuntime( 542): at com.example.guagetest.MainActivity.onCreate(MainActivity.java:16)
E/AndroidRuntime( 542): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime( 542): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime( 542): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
E/AndroidRuntime( 542): ... 11 more
E/AndroidRuntime( 542): Caused by: java.lang.ClassNotFoundException: org.codeandmagic.android.gauge.GaugeView
E/AndroidRuntime( 542): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime( 542): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime( 542): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime( 542): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
E/AndroidRuntime( 542): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
E/AndroidRuntime( 542): ... 21 more
W/ActivityManager( 77): Force finishing activity com.example.guagetest/.MainActivity

我不知道为什么找不到该类(class)。请有人帮忙。示例应用程序中是否需要执行任何特殊操作才能使其正常工作?

以下是我的布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >

<org.codeandmagic.android.gauge.GaugeView
android:id="@+id/gauge_view1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />


</LinearLayout>

这是我的 Activity :

package com.example.guagetest;

import org.codeandmagic.android.gauge.GaugeView;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

private GaugeView gauge;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gauge = (GaugeView) findViewById(R.id.gauge_view1);
gauge.setTargetValue(10);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

}

最佳答案

您没有发布任何代码,但即使在您的帖子中,您对特定单词的拼写也不一致,这一事实表明您需要检查代码中的拼写方式。仔细看这两个字:

String correct = "gauge";
String wrongWrongWrong = "guage";

关于java - 包含 GaugeView 库后的 Android ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16336550/

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