当前位置 : 主页 > 手机开发 > android >

android – 简单的Eclipse库项目到jar

来源:互联网 收集:自由互联 发布时间:2021-06-11
我使用这个Library项目: https://github.com/JakeWharton/Android-ViewPagerIndicator 为了使它在我的项目中工作,我基于git提供的源代码创建了一个新项目,并在我的Final项目中添加了一个Reference.一切正
我使用这个Library项目: https://github.com/JakeWharton/Android-ViewPagerIndicator
为了使它在我的项目中工作,我基于git提供的源代码创建了一个新项目,并在我的Final项目中添加了一个Reference.一切正常.我在我的最终项目中使用它,如:

<com.viewpagerindicator.TitlePageIndicator
        android:id="@+id/indicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

我想避免这个Library项目引用,并在我的Final项目中使用一个简单的jar.我已经在我的库项目中生成了jar并添加到Java Build Path中的Final项目中.
当我运行它时,我收到一个错误:

12-09 10:57:34.714: E/AndroidRuntime(10492): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test/com.test.SettingsActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class com.viewpagerindicator.TitlePageIndicator

有可能实现我想要的吗?

Android Developer Tools的当前版本(15.0.1)不允许将包含资源(例如布局,自定义属性等)的项目捆绑为简单的.jar.

按照the library project documentation:

However, a library project differs from an standard Android application project in that you cannot compile it directly to its own .apk and run it on an Android device. Similarly, you cannot export the library project to a self-contained JAR file, as you would do for a true library. Instead, you must compile the library indirectly, by referencing the library in the dependent application and building that application.

ADT目前在Eclipse中附加了一个.jar的图书馆项目,用于链接目的,以解决以前不稳定的纯项目参考.但是,它没有捆绑任何资源.

ADT工具网站的download page并未表明对此的支持也将进入ADT 16(从ADT 16预览2开始).目前的传闻是,这将进入第17版的工具,这仍然是一个很好的方法.我不能引用这个,因为它主要是听说 – 来自Twitter和Android开发者聊天室.

目前,您仍然无法将其用作库项目.

相信我,没有人想把这些项目捆绑为.jars比我做的更多:)

网友评论