Upgrade to Pro — share decks privately, control downloads, hide ads and more …

10 Common mistakes that Android Developers do

10 Common mistakes that Android Developers do

The second day keynote from DroidCon Zagreb 2016. http://droidcon.hr/en/sessions/10-common-mistakes-android-developers-do

Erik Hellman

April 29, 2016
Tweet

More Decks by Erik Hellman

Other Decks in Programming

Transcript

  1. Erik Hellman Freelance So!ware Developer Stockholm, Sweden Previously Ericsson, Sony

    Mobile, Spotify (and more) Drinks most coffee Author of Android Programming - Pushing the Limits
  2. HTML5 Service Worker if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw.js') .then(function(registration)

    { // Registration was successful console.log('ServiceWorker registration successful!'); }) .catch(function(err) { // registration failed :( console.log('ServiceWorker registration failed: ', err); }); }
  3. Modern C++ // auto std::vector<int> container = // fetch container...

    for (auto it = container.begin(); it != it.end(); it++) { // type of it is std::vector<int>::iterator } // lambdas auto is_odd = [](int n) {return n%2==1;}; // Strongly typed enums enum class Options {None, One, All}; Options o = Options::All;
  4. Looks familar? E/AndroidRuntime(379): FATAL EXCEPTION: main E/AndroidRuntime(379): java.lang.IllegalStateException: Activity has

    been destroyed E/AndroidRuntime(379): at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1365) E/AndroidRuntime(379): at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595) E/AndroidRuntime(379): at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:578) E/AndroidRuntime(379): at com.app.main.AppMainTabActivity.pushFragments(AppMainTabActivity.java:650) E/AndroidRuntime(379): at com.app.home.Home$ExpandableListAdapter$1.onClick(Home.java:530) E/AndroidRuntime(379): at android.view.View.performClick(View.java:2408) E/AndroidRuntime(379): at android.view.View$PerformClick.run(View.java:8816) E/AndroidRuntime(379): at android.os.Handler.handleCallback(Handler.java:587) E/AndroidRuntime(379): at android.os.Handler.dispatchMessage(Handler.java:92) E/AndroidRuntime(379): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime(379): at android.app.ActivityThread.main(ActivityThread.java:4627) E/AndroidRuntime(379): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(379): at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime(379): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) E/AndroidRuntime(379): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) E/AndroidRuntime(379): at dalvik.system.NativeStart.main(Native Method)
  5. – What do we want? – Now! – When do

    we want it? – Fewer race conditions! — Developers
  6. @WorkerThread public void doNetworkStuff() { // Do network stuff here...

    } @MainThread public void doUiStuff() { // Update the UI here }
  7. signingConfigs { release { storeFile file("./cert/release_keystore.jks") storePassword S3cr3tP4ssw0rd keyAlias android

    keyPassword S3cr3tP4ssw0rd } debug { storeFile file("./cert/debug_keystore.jks") storePassword "appdebug" keyAlias "debug" keyPassword "appdebug" } }
  8. · Track actual usage · Perform user studies in public

    · Play Store keeps old versions available