Written in the preface

Since Google I/O 2017 announced support for Kotlin and the release of Android Studio 3.0; I jumped on the urge to learn Kotlin. I think a lot of people have the misconception that Google is abandoning Java. I don’t think it’s true at this stage. Google is just adding a language that you can write Android in. After all, the Android SDK and everything is still Java. For those who are new to Android, I don’t recommend learning Kotlin directly, but Java first. Because Kotlin is still calling Java on Android, it would be difficult to proceed if you ran into any problems without knowing Java.

The body of the

The most obvious thing about Kotlin is how much easier it is to write programs. There are not so many complicated procedures. How did I learn kotlin and the problems I encountered with it

  • How to learn Kotlin

    I learn Kotlin through this website, which introduces kotlin’s grammar points in detail. After reading these, I can master the basis of Kotlin

  • Difficulties in applying to Android projects

    • The first problem is the most commonly used singleton pattern. Kotlin is a little bit different from Java so it’s written differently. I did a lot of searching on the Internet and finally came up with my own

    • Use THE RX series – MY favorite way to write Android applications is to use RxJava for almost every project, so the first step is definitely to apply RxJava to Kotlin; I didn’t have any problems with that, I just wrote it a little differently and most of the structures are lambda, and I’ll write this a few times and it’ll get better; But when I tried to use Retrofit + RxJava in Kotlin, I ran into a bit of a problem. See this article

    • Using Dagger2 (v2.11) – Since Dagger2 has added special support for Android, and there are not many articles about this version on the Internet, it is very painful to use this version, fumbling for a long time, finally after getting through, I found that the use method is the same as Java 😜; See this article for more information

    • Use Room (Room Persistence Library) – Room is the official database ORM framework released by Google at IO Conference. It is super easy to use, but kotlin is the most difficult. It’s very different from using Java; For differences and how to use them, see this article

    These are some of the more salient problems encountered in writing projects

    • Another unresolved issue is that the custom controls written with Kotlin are not fully recognized by Android, so there are two Java files in the project; I’ll work on that in the back
  • Projects show

    • First of all, the effect picture, to a large extent to imitate the zhihu daily look 😜





Project screenshots

  • Project source: github.com/a1018875550…
  • Project experience: I fell in love with Kotlin through this writing. It was really great. But now it’s not as easy to write as Java and there aren’t as many plug-ins available. But there will certainly be more and more in the future; Some future Android project will definitely be written in Kotlin;

  • Then this project personally feels like a good example to learn from Kotlin, Dagger2, Room, MVP 😜


Thanks for your support, if you feel this project can be welcome to starπŸ‘