Showing posts with label android studio cookbook. Show all posts
Showing posts with label android studio cookbook. Show all posts

Monday, November 23, 2015

Android Studio 2: Much faster and enhanced testing support

Android 2.0 comes with some great new features. Building and deploying apps will become much faster. The new Instant Run feature for example allows you to quickly see the changes you have made.

The new emulator will run much faster and it will come with enhanced testing support. The emulator will support Google Play Services and phone calls, low battery conditions and GPS locations can be simulated. It will support dragging and dropping APK files, just like Genymotion does.

More speed, that is what Android developers need. And with Android Studio 2.0, which is current available as a preview in the canary channel, speed is what we get.



Enable Instant Run

With Instant Run you build and deploy an app to an emulated or to a physical device just once and then as code needs to be changed, it will only take a few seconds before you can see the changes in the running app.

To see the new stuff for yourself you can grab an Android Studio 2.0 copy from the canary channel and enable the Instant Run feature for your existing apps.

From the Android Studio menu choose Preferences (Android Studio for OSX). In the Preferences dialog expand the Build, execution and deployment option and choose Instant run. You probably need to click on the Update project link to enable this new feature. In my case I also had to update the Build tools and to resync the project.


Once you have done that you are good to go. Run and deploy on the app using the Run button.

While your app is running you can modify your code. For example change the text of a toast being displayed in your app. As a small demo I have modified one of the recipes from my book but you can try this with any app of course.

Now you just hit the Run button again. A toast will be displayed to notify you about the changes. Indeed, we do no longer need to restart the activity to see our changes.



Note! Instant Run is a great feature but it is not (yet) supporting all kinds of changes. Some of these limitations are known, such as changing annotations, static fields or methods. Other kind of changes, such as modifications in the layout, should be supported I guess but I was not able to make it work.

It might because the project that I am using for testing this is having multiple flavors? Or it could be because this is just a preview of Android Studio 2.0 and maybe I need to be a little bit more patient and wait for a more stable release.

Conclusion

Android Studio 2.0 is focused on speed and better testing support. I think that is exactly what Android app developers deserve after struggling so many times with speed (in particular with Eclipse in the old less good days) and with the many fragmentation challenges we still have today.

Just like the Android OS itself Android Studio also has become mature and that is great news!

Further reading

Sunday, November 1, 2015

The Android Studio cook book has arrived.

Since a few days my first book, about Android Studio and Android application development, has become available at Packt Publishing and Amazon. I had fun writing it and I wonder if you think it is fun to read it.

Android studio is the number one IDE for developing Android apps and it is available for free to anyone who wants to develop professional Android apps. Any type of Android app can be developed using Android Studio.

Think of apps for phones, phablets, tablets, TVs, cars and for glasses and other wearables such as watches. Or consider an app that uses a cloud base backend like Parse or App engine, a watch face app or even a complete media centre solution for TV.

So, what is in the book?

This book will help you to make the right choices while developing your apps. For example on smaller screens provide smart navigation and use fragments to make it look great on a tablet too.

Or see how content providers can help you to manage and to persist data and how to share data amongst applications. The observer pattern that comes with them will save you a lot of time.



  • The book will also elaborate on Material design. Create cool apps using CardView and RecyclerView widgets for example. Or find out how to create special effects and how to create great transitions.

  • Another chapter is dedicated to the investigation of the Camera2 API and how to capture and preview photos. In addition you will learn how to apply filters and how or share the results on Facebook.

  • You will learn about patterns and how support annotations can help you to improve the quality of your code. Testing your app is just as important as developing one and it will take your app to the next level. Aim for a five star rating in the Google Play Store later.

  • The book shows you how to do unit testing, based on jUnit or Robolectric and how to use code analysis tools such as Android Lint.

  • You will learn about memory optimization using the Android Device Monitor. Detect issues and learn how to fix them.

  • Having a physical Android device to test your apps is strongly recommended but with thousands of Android devices being available, testing on real devices could be pretty expensive. Genymotion is a real fast and easy-to-use emulator and comes with many real world device configurations.

  • Did all your unit tests succeed? There are no more OutOfMemoryExceptions any more? No memory leaks found? Then it is about time to distribute your app to your beta testers. The final chapter explain how to configure your app for a beta release by creating the build types and build flavours that you need.

  • Finally distribute your app to your beta testers using Google Play to learn from their feedback.

    Conclusion

    These and other topics can be found in this cookbook. Since I am the author of the book there will be no conclusion here. That would be bit weird, wouldn't it? ;-)

    Instead I would like to ask what you think of it...

    Further reading