我的主项目中有一个 XML 布局文件,其中包含以下内容:
<com.quietlycoding.android.picker.NumberPicker
android:id="@+id/belegposition_belegpositionpickerpause"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
这个包位于我添加到构建路径中的另一个项目中。包名称是 100% 正确的。我还通过在编译器确实识别的 .java 文件中的导入对此进行了测试。
但是,当 XML 文件在运行时被夸大时,我得到了这个错误:
02-03 01:56:58.824: E/dalvikvm(4213): Could not find class 'com.quietlycoding.android.picker.NumberPicker', referenced from method de.innosoft.android.activity.BelegPositionen$ArrayAdapterBelegPosition.getView
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): Didn't find class "com.quietlycoding.android.picker.NumberPicker" on path: /system/framework/android.test.runner.jar:/data/app/de.innosoft.android-1.apk
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): java.lang.ClassNotFoundException: Didn't find class "com.quietlycoding.android.picker.NumberPicker" on path: /system/framework/android.test.runner.jar:/data/app/de.innosoft.android-1.apk
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at de.innosoft.android.activity.BelegPositionen$ArrayAdapterBelegPosition.getView(BelegPositionen.java:107)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.ListView.measureHeightOfChildren(ListView.java:1246)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.ListView.onMeasure(ListView.java:1158)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.View.measure(View.java:15513)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.View.measure(View.java:15513)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.View.measure(View.java:15513)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.View.measure(View.java:15513)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.View.measure(View.java:15513)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.Choreographer.doFrame(Choreographer.java:532)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.os.Handler.handleCallback(Handler.java:725)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.os.Handler.dispatchMessage(Handler.java:92)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.os.Looper.loop(Looper.java:137)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.app.ActivityThread.main(ActivityThread.java:5191)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at java.lang.reflect.Method.invokeNative(Native Method)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at java.lang.reflect.Method.invoke(Method.java:511)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at dalvik.system.NativeStart.main(Native Method)
不能从 XML 文件中引用外部项目包吗?还是我只是忘记了根 XML 元素的特定属性?
编辑:我正在使用一个外部项目,因为我不想用所有这些外部东西(drawables 等)污染我的主要项目文件夹。不幸的是,该库不是作为 JAR 提供的。