Simple Eclipse library project for jar

I use this library project: https://github.com/JakeWharton/Android-ViewPagerIndicator To work in my project, I created a new project based on the source code provided by git and added a link to it in my final project. Everything is working fine. I use it in my final project, for example:

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

I would like to avoid this link to the library project and use a simple jar in my Final project. I took the jar created in my library project and added it to the Final Project in the Java Build Path. When I run it, I get an error message:

 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 

Is it possible to achieve what I want?

+3
source share
4 answers

The current version (15.0.1) of the Android developer tools does not allow combining projects containing resources (for example, layouts, user attributes, etc.) as a simple .jar .

According to the documentation on the library documentation :

However, the library project differs from the standard Android application project in that you cannot compile it directly into your own .apk and run it on your Android device. Likewise, you cannot export a library project to a standalone JAR file, just like for a true library. Instead, you should compile the library indirectly by referencing the library in the dependent application and creating the application.

ADT is currently attaching .jar library projects in Eclipse for linking purposes to bypass previously configured purely project references. However, this has no resources associated with it.

The page page on the ADT Tools website does not mean that support for this will be in ADT 16 either (with ADT 16 preview 2). The current rumor is that it will break into version 17 of the tools, which still remain good. I can’t refer to this because it mostly hears - from Twitter and into the Android developer’s chat room.

You are currently using it as a library project.

Believe me, no one wants to link these projects as .jar more than me :)

+6
source

I created the TitlePageIndicator dynamically and the exception does not throw:

 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ViewPagerAdapter adapter = new ViewPagerAdapter(this); ViewPager pager = new ViewPager(this); pager.setAdapter(adapter); TitlePageIndicator indicator = new TitlePageIndicator(this); indicator.setViewPager(pager); LinearLayout body = (LinearLayout) findViewById(R.id.body); body.addView(indicator); body.addView(pager); 

}

+1
source

I do not use the jar file, but I had the same error message and fixed it in Eclipse: Right-click the project, open "Properties"> "Android", in the "Library" field, click "Add" and select "ViewPagerIndicator" .

0
source

I also got the error of inflating the layout ... I know this is a pretty old post, but I'm sending my answer in the hope that someone is stuck with the same error, can solve it ... I followed all the steps that are included in the blog ... but the error I made was my library file, it was a very long path (C: / Users // Downloads / Jakewhartan ... yada, yada yada / Jakewhartan ..... / libs), and in that there was a problem ... I moved it to a smaller path, for example, F: / workdpace / mylibs, and it worked .......

NOW I TAKE A NOTE THAT THE WINDOWS DO NOT SUPPORT THE CORRECT LONG WAYS ..

0
source

All Articles