10 libraries that every Android developer should know about

 3r33351. 3r3-31. 3r3309. 10 libraries that every Android developer should know about
3r33311.  3r33351. 3r3309. In 201? we have already published Article 3r33337. about the top five libraries we used at the time. However, the Android platform has grown significantly since then. As you know, in such a rapidly developing area as software development, everything changes and develops at lightning speed. That is why we decided it was time to update the list of the most effective Android libraries.
3r311. 3r33337. 3r33311.  3r33351. 3r3309. Let's go straight to our list without long prefaces. First, we will look at one of the oldest, but, in my opinion, and one of the most efficient Android libraries.
3r33311.  3r33351.
3r3306. 3r33311.  3r33351. 3r3309. Retrofit is a type-safe HTTP client that allows you to present your REST API as an interface. You can manage bodies, headers, API request parameters, and much more with annotations, which will make this process simple and straightforward. Retrofit also allows you to perform synchronous and asynchronous API calls.
3r33311.  3r33351.
interface ApiService {
@GET ("movie /{id}")
fun getMovieDetails (@Path ("id") id: String): Call 3r33351.}
3r33311.  3r33351. 3r3309. In addition, Retrofit provides a separate Rx module. If you use Rx, this module will return Observable when accessing the API, which allows you to associate it with the rest of your application. And these are just some of the many reasons why we still love and use Retrofit. 3r33311.  3r33351.

2. Moshi 3r3306. 3r33311.  3r33351. 3r3309. Moshi is a library for converting JSON to Java and Kotlin objects. Many perceive Moshi as GSON 3.0. However, this library is superior to GSON in several aspects: 3r3-350. she is faster , it supports Kotlin, it updates, generates predictable exceptions, and does not use the defaulted DateTime adapter by default. In addition, using Moshi, the process of converting JSON into Java objects (and vice versa) becomes as simple and understandable as possible. 3r33311.  3r33351.

    val moshi = Moshi.Builder (). build ()
val jsonAdapter = moshi.adapter (Model :: class.java)
3r33351. /* JSON to Model * /
val model = jsonAdapter.fromJson (json)
3r33351. /* Model to JSON * /
val json = jsonAdapter.toJson (model)
3r33311.  3r33351. 3r3309. We also love Moshi for supporting the JSON API. The JSON API is a build API specification, and many of the APIs we work with are written using this specification. Moshi JSON API makes our life easier because the JSON API response is converted to meaningful Java objects. Retrofit still supports Moshi, and together they work just fine. 3r33311.  3r33351.

3. Chuck 3r3306. 3r33311.  3r33351. 3r3309. Chuck is an HTTP inspector for Android that allows you to “dig” into the HTTP history of your application on a mobile phone. The HTTP log is displayed as a notification, which can be deployed to log into Chuck and view detailed information. Using Chuck will be incredibly pleasing to the QA department because they can see where the problem is: on the Android side or on the server side. This library can sometimes help you more than logcat. This is due to the fact that your HTTP history will be preserved even in the event of an unexpected closure of the application, while logcat will self-clean from time to time after a restart. 3r33311.  3r33351. 3r3309. 3r33311.  3r33351.

4. Glide 3r3306. 3r33311.  3r33351. 3r3309. You most likely know that uploading images to Android causes great difficulties. Even resizing an image can turn out to be a disaster from 3r3250. OutOfMemoryException . Glide is an image loading library that provides a quality API that allows you to change the image as you like. 3r33311.  3r33351.

    GlideApp.with (context)
.load (url)
.centerCrop ()
.placeholder (R.drawable.ic_placeholder)
.into (imageView)
3r33311.  3r33351. 3r3309. The library will allow you to easily upload a deleted image to ImageView, determine stub images, cache and scale images, etc. Just try doing all this without the help of Glide, and you will immediately understand why it is in our list of key libraries. Glide even supports some common default changes, such as creating a circular image. 3r33311.  3r33351. 3r3115. 5. ThreeTen 3r3306. 3r33311.  3r33351. 3r3309. ThreeTen is a library for working with date and time in Android. This is a ported version of JSR-31? which was included in Java 8 as a standard package 3r32-50. java.time. * . We love this library because the standard Android Calendar API turns work into a real nightmare. 3r33311.  3r33351.
    /* Current DateTime * /
LocalDateTime.now ()
3r33351. /* String to DateTime * /
val localDateTimeString = "2011-12-03T10: 15: 30"
val localDateTime = LocalDateTime.parse (localDateTimeString)
3r33311.  3r33351. 3r3309. ThreeTen is inferior to JodaTime in terms of the number of methods and binary size. The API of this library is also smaller than the JodaTime API. If you are already using JodaTime, then you probably shouldn't switch to ThreeTen. Nevertheless, I highly recommend trying ThreeTen if you are just starting to work on a new project. 3r33311.  3r33351. 3r3142. 6. 3r3143. Timber 3r33333. 3r3306. 3r33311.  3r33351. 3r3309. Timber is a powerful but simple logging library, built on the basis of the Android class 3r-3250. Log . With it, you can easily turn on and off the display of logs. The library also offers excellent support for logging formatted strings and exceptions. Thanks to these advantages, Timber is included in our list of key libraries that we use on almost all Android projects. 3r33311.  3r33351.
    /* Log error * /
Timber.e ("Error happened")
3r33351. /* Log warning with params * /
Timber.w ("Your variable value is% s", variable)
3r33351. /* Log exception * /
try {
} catch (e: Exception) {
Timber.e (e)
3r33311.  3r33351. 3r3171. 7. 3r3172. Room 3r3306. 3r33311.  3r33351. 3r3309. Room is the official ORM for Android, and this status is justified by several reasons. This library has a convenient API, similar to Retrofit. Room also relies heavily on annotations and standard SQL syntax. 3r33311.  3r33351.
interface MovieDao {
@Query ("SELECT details FROM movies WHERE id =: id")
fun getMovieDetails (id: String): MovieDetails
3r33311.  3r33351. 3r3309. In addition, Room by default includes support for Rx and LiveData so you can use it as you like. The main advantage of the Room over various ORMs is simplicity. Many ORMs have a much more complex API, for which you will need to carefully study all the documentation. Thanks to the standard SQL syntax, Room is extremely easy to understand, which allows you to start work right away without spending a lot of time reading the documentation. 3r33311.  3r33351. 3r3197. 8. 3r3198. RxJava 3r3306. 3r33311.  3r33351. 3r3309. RxJava is a Java implementation of the ReactiveX API that allows you to link asynchronous tasks and events into observable (eng. 3r33292. Observable 3r3-33293.) Sequences. Users expect modern applications to display real-time data. In other words, they want the information to be updated automatically. It is in this aspect that RxJava will come in handy. 3r33311.  3r33351. 3r3309. When getting real-time data, it becomes extremely difficult to combine multiple API requests, switch threads, and handle errors. It is here that RxJava perfectly manifests itself, and it is for this reason that we began to use this library. I agree that RxJava may seem confusing and difficult to learn, but this library definitely deserves your time. Even after switching to Kotlin, we continued to use RxJava because of its advantages. In combination with the Kotlin API, it becomes even better thanks to additional features, extensions. 3r33311.  3r33351.
ApiService. GetMovieDetails (id) .retry (2),
/* Received results *, 3 3pc3351. )}
) 3r3333351. /* Execute API calls on IO thread * /3r3333351. .subscribeOn (Schedulers.io ())
/* Receive results on MainThread * /
.observeOn (AndroidSchedulers.mainThread ())
.subscribeBy (
onerror = {/* Handle error * /},
onSuccess = {/* Handle full movie data * /}
) 3r33273.
3r33311.  3r33351. 3r3309. Try to do something similar to the above snippet using simple Java. Come on. 3r33311.  3r33351.

9. Android KTX 3r3306. 3r33311.  3r33351. 3r3309. Android KTX is a set of wrapper extensions for the Android API in Kotlin that make it more friendly. The main goal of this library is to make the Android API more convenient to use. It contains many methods and excellent new Kotlin functions, such as named parameters, lambda functions and default parameters. 3r33311.  3r33351.

    /* Display View * /
view.isVisible = true
3r33351. /* Apply padding to all sides * /
view.setPadding (padding)
3r33351. /* Update padding on any side * /
view.updatePadding (left = newPadding, right = newPadding)
3r33351. /* Quick Toast * /
toast ("Display test toast")
3r33351. /* New way to create bundle * /
bundleOf {
"key1" to item1
"key2" to item2
3r33351. /* Better way to use SharedPreferences * /
sharedPreferences.edit {
putString ("key1", "value1")
putString ("key2", "value2")

3r33311.  3r33351. 3r3309. Android KTX is distinguished by the presence of many feature extensions, and the only way to find out about them is to dive into the library code to see how the functions have improved the Android API. Android KTX simplifies the way you use the Android API, and for this reason this library should be the basis of every Android application written in Kotlin.
3r33311.  3r33351.
10. Dagger 3r3306. 3r33311.  3r33351. 3r3309. Our list of the top 10 libraries would be incomplete without Dagger. This library is a completely static dependency injection framework at compile time. Dagger, like RxJava, is really hard to understand (I had to spend some time to understand their example of CoffeeMaker), but definitely deserves the time and effort spent.
3r33311.  3r33351. 3r3309. Dependency injection (English 3r33292. Dependency injection 3r3-33293.) Is a way to add small components to other models with minimal effort. For example, if you have a car model, you can add tires to it and easily replace the tire implementation in the future - without changing a single line of code in the car model.
3r33311.  3r33351. 3r3309. When developing more complex applications, you definitely don’t want to do the dependency injection tasks yourself, because the amount of code increases rapidly and becomes too complicated to support. Dagger will save you from this problem, because it creates a dependency injection graph at compile time through annotation processing.
3r33311.  3r33351. 3r3309. Last year, Google added a separate Android Dagger module that allows you to write less template code and simplifies dependency injection.
3r33311.  3r33351. 3r3305. Conclusion 3r3306. 3r33311.  3r33351. 3r3309. So, here it is: our list of the top 10 Android libraries in 2018. Ten great libraries that will make the Android development process more enjoyable for everyone who decides to use them. Want more libraries? It turned out that we in our company have developed several of our own Android libraries. You can read them:
3r33311.  3r33351. 3r33333.  3r33351. 3r33333. 3r33333. MjolnirRecyclerView
- adds support for header, footer, empty view components and DiffUtils to RecyclerView; 3r33338.  3r33351. 3r33333. Goldfinger - simplifies the implementation of fingerprint authentication; 3r33338.  3r33351. 3r33333. DBInspector - browses and provides access to application databases; 3r33338.  3r33351. 3r33333. 3r33333. Complexify
- an easy way to check the quality of a user password; 3r33338.  3r33351. 3r33333. 3r33336. Prince of Versions
- processes updatesapplication inside the application. 3r33338.  3r33351. 3r33333. 3r33347. 3r33351. 3r33351. 3r33333. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e.parentNode.insertBefore (r, e)}; "[object Opera]" == e.opera? a.addEventListener? a.addEventListener ("DOMContentLoaded", d,! 1): e.attachEvent ("onload", d ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () (); 3r33333. 3r33351. 3r33347. 3r33351. 3r33351. 3r33351. 3r33351.
+ 0 -

Add comment