Setting up a project to create third-party libraries for Android

I am creating a library for Android that others can include in their own project. So far, I have been working on it as a regular Java project, with JDK 1.6 configured as a system library. This works very well in Eclipse when I add android.jar.

The problem occurs when I try to create my build script. I run Gradle and do a normal build and test cycle. My thoughts were that it doesn’t matter if I compile it using a regular JDK, since this is not a separate application. The benefits of creating a regular Java project are that Gradle supports this much better. My project also does not contain any interface. However, the problem is, of course, android.jar and the JDK contain many of the same classes, and I think this is what messed up my script compiler. All crashes when running tests (tests are in the same project in src / test / java).

My question is: how do I create this project, which should be included in Android projects as a third-party library? Should I create it as an Android project in Eclipse, although I only create a library that does not use any user interface features? In addition, should tests be in a separate project?

Thanks for all the answers!

+3
source share
2 answers

I'll start with a simple question regarding a test project. My experience is that it is better to have a separate test project. I have done this successfully in many Java ME projects where the problems are similar. For a test project, you only need to import the source code, not the libraries. Then there should be no problems with repeating classes.

. , Android.

+1

Android Gradle? ProGuard Android APK, . : https://github.com/jvoegele/gradle-android-plugin/wiki

+2

Source: https://habr.com/ru/post/1743570/


All Articles