Android 添加外部lbrary项目中定义的视图类
我已经创建了一个新的GLView组件,用于不同的项目。在正确构建库之后,我尝试将其添加到测试应用程序中的xml布局中,但它似乎不起作用,因为它引发了classnotfound异常Android 添加外部lbrary项目中定义的视图类,android,android-custom-view,Android,Android Custom View,我已经创建了一个新的GLView组件,用于不同的项目。在正确构建库之后,我尝试将其添加到测试应用程序中的xml布局中,但它似乎不起作用,因为它引发了classnotfound异常 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:lib="http://schemas.android.com
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lib="http://schemas.android.com/apk/res-auto"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@android:color/darker_gray">
<com.exapmple.library.CustomView
android:id="@+id/glsurfaceview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
如何将库附加到项目 作为jar库还是作为库项目
我想问题出在错误的配置中。jar文件可能放在“lib”文件夹而不是“libs”文件夹中。这个答案有用吗?库就在那里,可以从代码中的任何地方调用。布局xml文件是问题所在。库项目。它可以从代码中的任何地方调用,因此已正确导入。XML文件需要lib的名称空间定义。
public class CustomView extends GLSurfaceView