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

Head First Android Apps Dev Tools

Head First Android Apps Dev Tools

@ MOPCON talks about genymotion & gradle

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

Shaka Huang

October 26, 2013
Tweet

More Decks by Shaka Huang

Other Decks in Programming

Transcript

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

    • Consultant @ SleepNOVA, Inc. http:/ /about.me/shakalaca
  2. Today’s topic • Genymotion (101 session) • w/ demo •

    Gradle (201 session) • w/ sample scripts • Android Studio (201 session)
  3. 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. 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. Buy real phone(s) ! • For platform/screen specific issues •

    Nexus is enough ... • ... I’m not sure
  6. 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. Good for .. • Test applications • Fast & cable

    free • Screencast • Use your favorite software (for me: QuickTime for OS X)
  8. Features (HW) • Camera • GPS • Battery • Speaker

    / Microphone • Rotation • Physical keys
  9. Features (SW) • API 16 & 17, 18 in preview

    • Play store (service) • Root access • OpenGL • Virtual keys • Full screen (F11)
  10. 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. 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
  12. 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"
  13. 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
  14. 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
  15. 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
  16. 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/
  17. .. short version An open source build system that combines

    the power of Ant & Maven but easy to use
  18. 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
  19. 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
  20. Will it blow up my projects ? It’s 2013 now,

    you should have SCM … right ?
  21. 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
  22. Command • gradle <task name> • tasks • clean •

    assemble • assembleRelease • assembleDebug • aR / asD
  23. 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
  24. defaultConfig • versionCode • versionName • minSdkVersion • targetSdkVersion •

    packageName • signingConfig • proguardFile • proguardFiles • testPackageName • testInstrumentation Runner
  25. Happy building • Put build.gradle in project directory • Build:

    gradle assemble • build/apk/ • Install: gradle installDebug or gradle installRelease
  26. app

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

    directory • Put build.gradle in library project directory • Build: gradle assemble • build/apk/
  28. Known issue • Library project is always “release” build •

    define your own debug flags.. • <application /> in AndroidManifest.xml
  29. Build types • debuggable • jniDebugBuild • renderscriptDebugBuild • renderscriptOptimLevel

    • packageNameSuffix • versionNameSuffix • signingConfig • zipAlign • runProguard • proguardFile • proguardFiles
  30. Build variant • Creating different versions of same application •

    free/paid • multi-apk • Build Variant = Build Type + Product Flavor
  31. Product flavor • Defines a customised version of application build

    by the project • Free / Paid • Amazon / Play Store / blah store • Same type as defaultConfig
  32. Build • gradle assemblePaid • gradle aPD / gradle aPR

    • gradle assembleFree • gradle aFD / gradle aFR
  33. Summary • Simple android project • Sign release key •

    Run proguard • Build variants • Wrapper
  34. 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
  35. How • deploy library • ./gradlew deploy • use local

    repository • ./gradlew as -PuseRepo
  36. 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/
  37. Or follow me @ • G+ • http:/ /google.com/profiles/shakalaca •

    Blog • http:/ /23pin.logdown.com • Taipei GDG (G+ Community) • https:/ /plus.google.com/communities/ 100566773212437391191
  38. 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
  39. 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