Head First Android Apps Dev Tools

Head First Android Apps Dev Tools

@ MOPCON talks about genymotion & gradle

Gradle sample code: http://goo.gl/fxwZ9l

4cb35be1ef26ed4fb0dd2914ee8a4873?s=128

Shaka Huang

October 26, 2013
Tweet

Transcript

  1. 2.

    Hello ! I’m Shaka • CTO @ SmarTapper Co., Ltd.

    • Consultant @ SleepNOVA, Inc. http:/ /about.me/shakalaca
  2. 3.

    Today’s topic • Genymotion (101 session) • w/ demo •

    Gradle (201 session) • w/ sample scripts • Android Studio (201 session)
  3. 6.

    Really ? • Don’t have to buy a Mac
 ...

    you’ll buy one eventually (look at me) • There’s an emulator
 ... you really use it ? • Android phone is way cheaper than iPhone !
 ... you mean those in the next page ?
  4. 9.

    Problems with emulator • No play services (sort of) •

    No camera • “telnet localhost 5554” doesn’t make sense • f5g really slow in arm based emulator
  5. 11.

    Buy real phone(s) ! • For platform/screen specific issues •

    Nexus is enough ... • ... I’m not sure
  6. 14.

    Is it the one ? • Android x86 emulator based

    on AndroVM open source project • http:/ /androvm.org/ • (In some case) faster than SDK emulator • Multi-platform • IDE plugins
  7. 15.

    Good for .. • Test applications • Fast & cable

    free • Screencast • Use your favorite software (for me: QuickTime for OS X)
  8. 17.

    Features (HW) • Camera • GPS • Battery • Speaker

    / Microphone • Rotation • Physical keys
  9. 18.

    Features (SW) • API 16 & 17, 18 in preview

    • Play store (service) • Root access • OpenGL • Virtual keys • Full screen (F11)
  10. 20.

    Screen size • Nexus One (3.7”) • Nexus S (4”)

    • Galaxy Nexus (4.65”) • Nexus 7 (7”) • Galaxy S4/HTC One/Xperia Z (5”) • WSVGA Tablet (7”) • WXGA Tablet (10.1”)
  11. 22.
  12. 23.

    Control • Buttons • Rotation: ctrl + F11 • Full

    screen: F11 • Gestures • Zoom: ctrl + mouse left/right • Tile: ctrl + mouse up/down • Rotate: ctrl + shift + mouse left/right
  13. 24.

    Launch from CLI • VBoxManage list vms • "Galaxy Nexus

    - 4.2.2 - with Google Apps - API 17 - 720x1280" {fbbd7f3e-188d-4a9b-8cdc-5b70c1554f5b} • player --vm-name <VM name/id> • /Application/Genymotion.app/Contents/MacOS/player --vm-name "Galaxy Nexus - 4.2.2 - with Google Apps - API 17 - 720x1280"
  14. 25.

    genyshell • Example: Setup gps to somewhere in Taipei •

    Content of file “gps_loc” • gps setstatus enabled • gps setlatitude 25.03 • gps setlongitude 121.54 • Command to apply configurations • genyshell -f gps_loc
  15. 26.

    Change resolution • Dummy way: Set in menu before launch

    • Geek way: Set through adb • adb shell am display-size 800x480 • adb shell am display-density 240 • adb shell am display-size reset • For 4.3+ • adb shell wm size 800x480 • adb shell wm density 240
  16. 27.

    Use my scripts :p • adb root • https:/ /gist.github.com/shakalaca/6716635

    • screenshot • https:/ /gist.github.com/shakalaca/6822570 • migration tool • https:/ /github.com/shakalaca/ GenymotionVMMigrationTool
  17. 29.

    What is gradle ? Gradle is build automation evolved. Gradle

    can automate the building, testing, publishing, deployment and more of software packages or other types of projects such as generated static websites, generated documentation or indeed anything else. ! Gradle combines the power and flexibility of Ant with the dependency management and conventions of Maven into a more effective way to build. Powered by a Groovy DSL and packed with innovation, Gradle provides a declarative way to describe all kinds of builds through sensible defaults. Gradle is quickly becoming the build system of choice for many open source projects, leading edge enterprises and legacy automation challenges. - http:/ /www.gradle.org/
  18. 30.

    .. short version An open source build system that combines

    the power of Ant & Maven but easy to use
  19. 31.

    Why (google wants to change the build system to) gradle

    ? • My guess.. • Simplify and unify project dependency management in IDE & CLI • Think about Eclipse & ant (ci server) • Android Studio is coming ! BETA
  20. 32.

    Should I use it ? • For small project •

    Easy to convert • For large project • Worth trying if it can simplify the configurations (dependency) • For project with variants • Time for better management tool
  21. 33.

    Will it blow up my projects ? It’s 2013 now,

    you should have SCM … right ?
  22. 34.

    How gradle works ? • Lifecycle • Initialization • Configuration

    • Execution • Build scripts • build.gradle • settings.gradle (optional) • gradle.properties (optional) http://www.gradle.org/docs/current/userguide/build_lifecycle.html
  23. 35.

    Command • gradle <task name> • tasks • clean •

    assemble • assembleRelease • assembleDebug • aR / asD
  24. 38.
  25. 40.
  26. 42.

    Android packages ! • com.android.support:support-v4:18.0.0 • com.android.support:appcompat-v7:18.0.0 • com.android.support:gridlayout-v7:18.0.0 •

    com.android.support:support-v7-mediarouter:18.0.0 • com.android.support:support-v13:18.0.0 • com.google.android.gms:play-services:3.2.65
  27. 43.

    defaultConfig • versionCode • versionName • minSdkVersion • targetSdkVersion •

    packageName • signingConfig • proguardFile • proguardFiles • testPackageName • testInstrumentation Runner
  28. 44.

    Happy building • Put build.gradle in project directory • Build:

    gradle assemble • build/apk/ • Install: gradle installDebug or gradle installRelease
  29. 47.

    app

  30. 50.

    Happy building • Put build.gradle & settings.gradle in app project

    directory • Put build.gradle in library project directory • Build: gradle assemble • build/apk/
  31. 54.
  32. 55.
  33. 56.

    Known issue • Library project is always “release” build •

    define your own debug flags.. • <application /> in AndroidManifest.xml
  34. 58.
  35. 60.

    Build types • debuggable • jniDebugBuild • renderscriptDebugBuild • renderscriptOptimLevel

    • packageNameSuffix • versionNameSuffix • signingConfig • zipAlign • runProguard • proguardFile • proguardFiles
  36. 62.
  37. 64.

    Build variant • Creating different versions of same application •

    free/paid • multi-apk • Build Variant = Build Type + Product Flavor
  38. 65.

    Product flavor • Defines a customised version of application build

    by the project • Free / Paid • Amazon / Play Store / blah store • Same type as defaultConfig
  39. 66.
  40. 67.

    Build • gradle assemblePaid • gradle aPD / gradle aPR

    • gradle assembleFree • gradle aFD / gradle aFR
  41. 68.
  42. 71.
  43. 73.

    Summary • Simple android project • Sign release key •

    Run proguard • Build variants • Wrapper
  44. 76.

    Why & How ? • Time is money • Use

    aar instead of re-compiling everything • aar: Binary distribution of an Android Library Project • http:/ /tools.android.com/tech-docs/new- build-system/aar-format
  45. 82.

    How • deploy library • ./gradlew deploy • use local

    repository • ./gradlew as -PuseRepo
  46. 83.
  47. 86.

    References • Documentation • http:/ /tools.android.com/tech-docs/new-build-system (Guide / Samples) •

    http:/ /www.gradle.org/documentation • Forums • https:/ /plus.google.com/u/0/communities/114791428968349268860 • https:/ /groups.google.com/forum/#!forum/adt-dev • http:/ /stackoverflow.com/questions/tagged/gradle • Tool • http:/ /gradleplease.appspot.com/
  48. 87.

    Or follow me @ • G+ • http:/ /google.com/profiles/shakalaca •

    Blog • http:/ /23pin.logdown.com • Taipei GDG (G+ Community) • https:/ /plus.google.com/communities/ 100566773212437391191
  49. 88.
  50. 89.
  51. 90.
  52. 94.

    Move out and rename output apk files • android.applicationVariant.all {

    variant ->
 variant.assemble.doLast { do_the_magic } 
 } • variant.zipAlign • true: extra variant.outputFile • false: variant.packageApplication.outputFile • https:/ /gist.github.com/shakalaca/6422811
  53. 96.

    For other issues .. • Google Maps Android API v2

    gradle integration • Different resources for build types • http:/ /23pin.logdown.com/posts/144771-google- maps-android-api-v2-gradle-integration • Gradle and GCM project integration • Difference in AndroidManifest.xml • http:/ /23pin.logdown.com/posts/144770-gradle-and- gcm-project-integration