我有两款Android项目,一个“库项目”包含自定义布局,并含有使用该布局的应用程序的“应用程序项目”。指定Android项目的依赖关系(在Eclipse)
除了可视化布局编辑器抛出一个ClassNotFoundException(我认为它是插件中的一个bug)之外,似乎一切都可以构建和执行,但是当我尝试开始利用我定义的属性在xml中的自定义布局,我不能再构建。那是;这个工程:
<?xml version="1.0" encoding="utf-8"?>
<se.fnord.android.layout.PredicateLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="asdfasdf"
/>
</se.fnord.android.layout.PredicateLayout>
然而,这并不:
<?xml version="1.0" encoding="utf-8"?>
<se.fnord.android.layout.PredicateLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fnord="http://schemas.android.com/apk/res/se.fnord.android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
fnord:layout_horizontalSpacing="1px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="asdfasdf"
/>
</se.fnord.android.layout.PredicateLayout>
构建失败,从AAPT的消息:
错误没有发现在包'属性 'layout_horizontalSpacing' 资源标识符se.fnord.android'
资源标识符ex ist在R文件中,attrs.xml包含库项目,如果我直接在应用程序项目中放置布局代码和资源,一切正常。 layout_horizontalSpacing属性(和layout_verticalSpacing)是PredicateLayout.LayoutParam类中用于指定到下一个小部件的距离的自定义属性。
到目前为止,我已经尝试通过指定的项目引用标准的Eclipse方式和构建路径项目的依赖。我还被告知尝试应用程序清单中的标签,但这并没有帮助。
所以,我需要什么,在XML文件工作的参考呢?
我不知道这是否是相关的,但 '库' 清单如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="se.fnord.android"
android:versionCode="1" android:versionName="1.0.0">
</manifest>
的 '应用' 清单是这样的:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="se.fnord.appname"
android:versionCode="1" android:versionName="1.0.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".AppName"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
(在 'PredicateLayout' ,顺便说一句,是一个清理版本this)。
另请参阅http://stackoverflow.com/questions/8581627/android-activity-under-eclipse-adt-with-project-dependencies-failed-resolving-x http://stackoverflow.com/questions/9838069/ jar-file-issue-with-adt-r17 – jfritz42 2012-03-27 21:33:36