├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── build.gradle ├── chapter01 ├── example02 │ └── build.gradle ├── example03 │ └── build.gradle └── example04 │ └── build.gradle ├── chapter02 ├── example21 │ └── build.gradle ├── example22 │ └── build.gradle ├── example23 │ └── build.gradle ├── example24 │ └── build.gradle └── example25 │ └── build.gradle ├── chapter03 ├── example34 │ └── build.gradle ├── example35 │ └── build.gradle ├── example36 │ └── build.gradle └── example37 │ └── build.gradle ├── chapter04 ├── example41 │ └── build.gradle ├── example42 │ └── build.gradle ├── example43 │ └── build.gradle ├── example45 │ └── build.gradle ├── example46 │ └── build.gradle ├── example47 │ └── build.gradle ├── example48 │ └── build.gradle └── example49 │ └── build.gradle ├── chapter05 ├── example52 │ ├── build.gradle │ └── version.gradle └── example53 │ ├── build.gradle │ ├── libs │ └── example53.jar │ └── src │ └── main │ ├── groovy │ └── com │ │ └── github │ │ └── rujews │ │ └── plugins │ │ └── Ex53CustomPlugin.groovy │ └── resources │ └── META-INF │ └── gradle-plugins │ └── com.github.rujews.plugins.ex53customplugin.properties ├── chapter06 ├── example610 │ └── build.gradle ├── example62 │ └── build.gradle ├── example63 │ └── build.gradle ├── example64 │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── flysnow │ │ │ └── androidgradlebook │ │ │ └── ex68 │ │ │ └── app │ │ │ └── HelloWorld.java │ │ └── resources │ │ └── config.properties ├── example65 │ └── build.gradle ├── example68 │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── flysnow │ │ │ └── androidgradlebook │ │ │ └── ex68 │ │ │ └── app │ │ │ └── HelloWorld.java │ └── base │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ └── java │ │ └── org │ │ └── flysnow │ │ └── androidgradlebook │ │ └── ex68 │ │ └── base │ │ └── Person.java └── example69 │ ├── build.gradle │ └── libs │ ├── example69-1.0.0.jar.sha1 │ ├── ivy-1.0.0.xml │ └── ivy-1.0.0.xml.sha1 ├── chapter07 ├── example73 │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── org │ │ │ └── flysnow │ │ │ └── app │ │ │ └── example73 │ │ │ └── MainActivity.java │ │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── content_main.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml └── example74 │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ ├── androidTest │ └── java │ │ └── org │ │ └── flysnow │ │ └── app │ │ └── example74 │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── org │ │ │ └── flysnow │ │ │ └── app │ │ │ └── example74 │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── content_main.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── org │ └── flysnow │ └── app │ └── example74 │ └── ExampleUnitTest.java ├── chapter08 └── example82 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ ├── androidTest │ └── java │ │ └── org │ │ └── flysnow │ │ └── app │ │ └── example82 │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ └── res │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── org │ └── flysnow │ └── app │ └── example82 │ └── ExampleUnitTest.java ├── chapter09 ├── example91 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── org │ │ │ └── flysnow │ │ │ └── app │ │ │ └── example91 │ │ │ └── MainActivity.java │ │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ └── strings.xml ├── example911 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── org │ │ │ └── flysnow │ │ │ └── app │ │ │ └── example911 │ │ │ ├── Example911Application.java │ │ │ └── MainActivity.java │ │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ └── strings.xml ├── example912 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── org │ │ │ └── flysnow │ │ │ └── app │ │ │ └── example912 │ │ │ └── MainActivity.java │ │ └── res │ │ ├── drawable │ │ └── unused.jpg │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── raw │ │ └── keep.xml │ │ └── values │ │ └── strings.xml ├── example92 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── org │ │ │ └── flysnow │ │ │ └── app │ │ │ └── example92 │ │ │ └── MainActivity.java │ │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ └── strings.xml ├── example93 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ ├── src │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── org │ │ │ │ └── flysnow │ │ │ │ └── app │ │ │ │ └── example93 │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ └── version.gradle ├── example94 │ ├── .gitignore │ ├── build.gradle │ ├── debug.keystore │ ├── proguard-rules.pro │ ├── src │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── org │ │ │ │ └── flysnow │ │ │ │ └── app │ │ │ │ └── example94 │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ └── version.gradle ├── example95 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── org │ │ │ └── flysnow │ │ │ └── app │ │ │ └── example95 │ │ │ └── MainActivity.java │ │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ └── strings.xml ├── example96 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── org │ │ │ └── flysnow │ │ │ └── app │ │ │ └── example96 │ │ │ └── MainActivity.java │ │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ └── strings.xml └── example97 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── org │ │ └── flysnow │ │ └── app │ │ └── example97 │ │ └── MainActivity.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ └── values │ └── strings.xml ├── chapter11 ├── example112 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── org │ │ │ └── flysnow │ │ │ └── app │ │ │ └── example112 │ │ │ └── MainActivity.java │ │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ └── strings.xml └── example113 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── org │ │ └── flysnow │ │ └── app │ │ └── example113 │ │ └── MainActivity.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ └── values │ └── strings.xml ├── chapter12 ├── example122 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── org │ │ │ │ └── flysnow │ │ │ │ └── app │ │ │ │ └── example122 │ │ │ │ ├── EmailValidator.java │ │ │ │ ├── MainActivity.java │ │ │ │ └── Utils.java │ │ └── res │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ │ └── test │ │ └── java │ │ └── org │ │ └── flysnow │ │ └── app │ │ └── example122 │ │ ├── EmailValidatorTest.java │ │ └── UtilsTest.java ├── example123 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── org │ │ │ └── flysnow │ │ │ └── app │ │ │ └── example123 │ │ │ └── MainActivityTest.java │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── org │ │ │ └── flysnow │ │ │ └── app │ │ │ └── example123 │ │ │ └── MainActivity.java │ │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ └── strings.xml └── example126 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── org │ │ └── flysnow │ │ └── app │ │ └── example126 │ │ └── MainActivity.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ └── values │ └── strings.xml ├── chapter13 ├── example131 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── org │ │ │ └── flysnow │ │ │ └── app │ │ │ └── example131 │ │ │ └── MainActivity.java │ │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ └── strings.xml └── example132 │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── org │ │ └── flysnow │ │ └── app │ │ └── example132 │ │ ├── HelloWorld.java │ │ └── MainActivity.java │ ├── jni │ ├── org_flysnow_app_example132_HelloWorld.c │ └── org_flysnow_app_example132_HelloWorld.h │ └── res │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ └── values │ └── strings.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | ### Vim template 2 | [._]*.s[a-w][a-z] 3 | [._]s[a-w][a-z] 4 | *.un~ 5 | Session.vim 6 | .netrwhist 7 | *~ 8 | ### Gradle template 9 | .gradle 10 | build/ 11 | 12 | # Ignore Gradle GUI config 13 | gradle-app.setting 14 | 15 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 16 | !gradle-wrapper.jar 17 | ### Maven template 18 | target/ 19 | pom.xml.tag 20 | pom.xml.releaseBackup 21 | pom.xml.versionsBackup 22 | pom.xml.next 23 | release.properties 24 | dependency-reduced-pom.xml 25 | buildNumber.properties 26 | .mvn/timing.properties 27 | ### Java template 28 | # Mobile Tools for Java (J2ME) 29 | .mtj.tmp/ 30 | 31 | # Package Files # 32 | *.war 33 | *.ear 34 | 35 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 36 | hs_err_pid* 37 | ### Android template 38 | # Built application files 39 | *.apk 40 | *.ap_ 41 | 42 | # Files for the Dalvik VM 43 | *.dex 44 | 45 | # Java class files 46 | *.class 47 | 48 | # Generated files 49 | bin/ 50 | gen/ 51 | 52 | # Gradle files 53 | .gradle/ 54 | /*/build/ 55 | 56 | # Local configuration file (sdk path, etc) 57 | local.properties 58 | 59 | # Proguard folder generated by Eclipse 60 | proguard/ 61 | 62 | # Log Files 63 | *.log 64 | 65 | # Android Studio Navigation editor temp files 66 | .navigation/ 67 | ### Windows template 68 | # Windows image file caches 69 | Thumbs.db 70 | ehthumbs.db 71 | 72 | # Folder config file 73 | Desktop.ini 74 | 75 | # Recycle Bin used on file shares 76 | $RECYCLE.BIN/ 77 | 78 | # Windows Installer files 79 | *.cab 80 | *.msi 81 | *.msm 82 | *.msp 83 | 84 | # Windows shortcuts 85 | *.lnk 86 | ### JetBrains template 87 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio 88 | 89 | *.iml 90 | 91 | ## Directory-based project format: 92 | .idea/ 93 | # if you remove the above rule, at least ignore the following: 94 | 95 | # User-specific stuff: 96 | # .idea/workspace.xml 97 | # .idea/tasks.xml 98 | # .idea/dictionaries 99 | 100 | # Sensitive or high-churn files: 101 | # .idea/dataSources.ids 102 | # .idea/dataSources.xml 103 | # .idea/sqlDataSources.xml 104 | # .idea/dynamic.xml 105 | # .idea/uiDesigner.xml 106 | 107 | # Gradle: 108 | # .idea/gradle.xml 109 | # .idea/libraries 110 | 111 | # Mongo Explorer plugin: 112 | # .idea/mongoSettings.xml 113 | 114 | ## File-based project format: 115 | *.ipr 116 | *.iws 117 | 118 | ## Plugin-specific files: 119 | 120 | # IntelliJ 121 | /out/ 122 | 123 | # mpeltonen/sbt-idea plugin 124 | .idea_modules/ 125 | 126 | # JIRA plugin 127 | atlassian-ide-plugin.xml 128 | 129 | # Crashlytics plugin (for Android Studio and IntelliJ) 130 | com_crashlytics_export_strings.xml 131 | crashlytics.properties 132 | crashlytics-build.properties 133 | 134 | ### Eclipse template 135 | *.pydevproject 136 | .metadata 137 | tmp/ 138 | *.tmp 139 | *.bak 140 | *.swp 141 | *~.nib 142 | .settings/ 143 | .loadpath 144 | 145 | # Eclipse Core 146 | .project 147 | 148 | # External tool builders 149 | .externalToolBuilders/ 150 | 151 | # Locally stored "Eclipse launch configurations" 152 | *.launch 153 | 154 | # CDT-specific 155 | .cproject 156 | 157 | # JDT-specific (Eclipse Java Development Tools) 158 | .classpath 159 | 160 | # Java annotation processor (APT) 161 | .factorypath 162 | 163 | # PDT-specific 164 | .buildpath 165 | 166 | # sbteclipse plugin 167 | .target 168 | 169 | # TeXlipse plugin 170 | .texlipse 171 | 172 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk8 3 | android: 4 | components: 5 | - build-tools-23.0.1 6 | - android-23 7 | - extra-android-m2repository 8 | - extra-android-support 9 | script: ./gradlew assemble -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 新书《Android Gradle权威指南》的示例代码 2 | 3 | 阅读地址 4 | 5 | [Android Gradle权威指南](https://item.jd.com/12162983.html) 6 | 7 | [https://item.jd.com/12162983.html](https://item.jd.com/12162983.html) 8 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath 'org.jacoco:org.jacoco.core:0.7.4.201502262128' 7 | } 8 | } 9 | allprojects { 10 | repositories { 11 | jcenter() 12 | } 13 | } -------------------------------------------------------------------------------- /chapter01/example02/build.gradle: -------------------------------------------------------------------------------- 1 | task hello{ 2 | doLast{ 3 | println 'Hello world!' 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /chapter01/example03/build.gradle: -------------------------------------------------------------------------------- 1 | //task wrapper(type: Wrapper) { 2 | // gradleVersion = '2.4' 3 | //} 4 | -------------------------------------------------------------------------------- /chapter01/example04/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | task printLog << { 4 | println '输出一段日志信息' 5 | 6 | logger.quiet('quiet日志信息.') 7 | logger.error('error日志信息.') 8 | logger.warn('warn日志信息.') 9 | logger.lifecycle('lifecycle日志信息.') 10 | logger.info('info日志信息.') 11 | logger.debug('debug日志信息.') 12 | } 13 | -------------------------------------------------------------------------------- /chapter02/example21/build.gradle: -------------------------------------------------------------------------------- 1 | task printStringClass << { 2 | def str1 = '单引号' 3 | def str2 = "双引号" 4 | 5 | println "单引号定义的字符串类型:"+str1.getClass().name 6 | println "双引号定义的字符串类型:"+str2.getClass().name 7 | } 8 | 9 | task printStringVar << { 10 | def name = "张三" 11 | 12 | println '单引号的变量计算:${name}' 13 | println "单引号的变量计算:$name" 14 | println "单引号的变量计算:${1+1}" 15 | } -------------------------------------------------------------------------------- /chapter02/example22/build.gradle: -------------------------------------------------------------------------------- 1 | task printList << { 2 | def numList =[1,2,3,4,5,6]; 3 | println numList.getClass().name 4 | 5 | println numList[1]//访问第二个元素 6 | println numList[-1]//访问最后一个元素 7 | println numList[-2]//访问倒数第二个元素 8 | println numList[1..3]//f访问第二个到第四个元素 9 | 10 | numList.each { 11 | println it 12 | } 13 | } 14 | 15 | task printlnMap << { 16 | def map1 =['width':1024,'height':768] 17 | println map1.getClass().name 18 | 19 | println map1['width'] 20 | println map1.height 21 | 22 | map1.each { 23 | println "Key:${it.key},Value:${it.value}" 24 | } 25 | } -------------------------------------------------------------------------------- /chapter02/example23/build.gradle: -------------------------------------------------------------------------------- 1 | task invokeMethod << { 2 | method1(1,2) 3 | method1 1,2 4 | } 5 | 6 | def method1(int a,int b){ 7 | println a+b 8 | } 9 | 10 | task printMethodReturn << { 11 | def add1 = method2 1,2 12 | def add2 = method2 5,3 13 | println "add1:${add1},add2:${add2}" 14 | } 15 | 16 | def method2(int a,int b){ 17 | if(a>b){ 18 | a 19 | }else{ 20 | b 21 | } 22 | } -------------------------------------------------------------------------------- /chapter02/example24/build.gradle: -------------------------------------------------------------------------------- 1 | task helloJavaBean << { 2 | Person p = new Person() 3 | 4 | println "名字是:${p.name}" 5 | p.name = "张三" 6 | println "名字是:${p.name}" 7 | println "年龄是:${p.age}" 8 | } 9 | 10 | class Person { 11 | private String name 12 | 13 | public int getAge(){ 14 | 12 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /chapter02/example25/build.gradle: -------------------------------------------------------------------------------- 1 | task helloClosure << { 2 | //使用我们自定义的闭包 3 | customEach { 4 | println it 5 | } 6 | 7 | //多个参数 8 | eachMap {k,v -> 9 | println "${k} is ${v}" 10 | } 11 | } 12 | 13 | def customEach(closure){ 14 | //模拟一个有10个元素的集合,开始迭代 15 | for(int i in 1..10){ 16 | closure(i) 17 | } 18 | } 19 | 20 | def eachMap(closure){ 21 | def map1 = ["name":"张三","age":18] 22 | map1.each { 23 | closure(it.key,it.value) 24 | } 25 | } 26 | task helloDelegate << { 27 | new Delegate().test { 28 | println "thisObject:${thisObject.getClass()}" 29 | println "owner:${owner.getClass()}" 30 | println "delegate:${delegate.getClass()}" 31 | method1() 32 | it.method1() 33 | } 34 | } 35 | 36 | def method1(){ 37 | println "Context this:${this.getClass()} in root" 38 | println "method1 in root" 39 | } 40 | class Delegate { 41 | def method1(){ 42 | println "Delegate this:${this.getClass()} in Delegate" 43 | println "method1 in Delegate" 44 | } 45 | 46 | def test(Closure closure){ 47 | closure(this) 48 | } 49 | } 50 | 51 | task configClosure << { 52 | person { 53 | personName = "张三" 54 | personAge = 20 55 | dumpPerson() 56 | } 57 | } 58 | 59 | class Person { 60 | String personName 61 | int personAge 62 | 63 | def dumpPerson(){ 64 | println "name is ${personName},age is ${personAge}" 65 | } 66 | } 67 | 68 | def person(Closure closure){ 69 | Person p = new Person(); 70 | closure.delegate = p 71 | //委托模式优先 72 | closure.setResolveStrategy(Closure.DELEGATE_FIRST); 73 | closure(p) 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /chapter03/example34/build.gradle: -------------------------------------------------------------------------------- 1 | task customTask1 { 2 | doFirst { 3 | println 'customTask1:doFirst' 4 | } 5 | doLast { 6 | println 'customTask1:doLast' 7 | } 8 | } 9 | 10 | tasks.create("customTask2") { 11 | doFirst { 12 | println 'customTask2:doFirst' 13 | } 14 | doLast { 15 | println 'customTask2:doLast' 16 | } 17 | } -------------------------------------------------------------------------------- /chapter03/example35/build.gradle: -------------------------------------------------------------------------------- 1 | task ex35Hello << { 2 | println 'hello' 3 | } 4 | 5 | task ex35World << { 6 | println 'world' 7 | } 8 | 9 | task ex35Main(dependsOn: ex35Hello) { 10 | doLast { 11 | println 'main' 12 | } 13 | } 14 | 15 | task ex35MultiTask { 16 | dependsOn ex35Hello,ex35World 17 | doLast { 18 | println 'multiTask' 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /chapter03/example36/build.gradle: -------------------------------------------------------------------------------- 1 | task ex36Hello << { 2 | println 'dowLast1' 3 | } 4 | 5 | ex36Hello.doFirst { 6 | println 'dowFirst' 7 | } 8 | 9 | ex36Hello.doLast { 10 | println project.hasProperty('ex36Hello') 11 | println 'dowLast2' 12 | } 13 | -------------------------------------------------------------------------------- /chapter03/example37/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "java" 2 | 3 | //自定义一个Project的属性 4 | ext.age = 18 5 | 6 | //通过代码块同时自定义多个属性 7 | ext { 8 | phone = 1334512 9 | address = '' 10 | } 11 | 12 | sourceSets.all { 13 | ext.resourcesDir = null 14 | } 15 | 16 | sourceSets { 17 | main { 18 | resourcesDir = 'main/res' 19 | } 20 | test { 21 | resourcesDir = 'test/res' 22 | } 23 | } 24 | 25 | task ex37CustomProperty << { 26 | println "年龄是:${age}" 27 | println "电话是:${phone}" 28 | println "地址是:${address}" 29 | 30 | sourceSets.each { 31 | println "${it.name}的resourcesDir是:${it.resourcesDir}" 32 | } 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /chapter04/example41/build.gradle: -------------------------------------------------------------------------------- 1 | def Task ex41CreateTask1 = task(ex41CreateTask1) 2 | 3 | ex41CreateTask1.doLast { 4 | println "创建方法原型为:Task task(String name) throws InvalidUserDataException" 5 | } 6 | 7 | 8 | def Task ex41CreateTask2 = task(ex41CreateTask2,group:BasePlugin.BUILD_GROUP) 9 | 10 | ex41CreateTask2.doLast { 11 | println "创建方法原型为:Task task(Map args, String name) throws InvalidUserDataException" 12 | println "任务分组:${ex41CreateTask2.group}" 13 | } 14 | 15 | task ex41CreateTask3 { 16 | description '演示任务创建' 17 | doLast { 18 | println "创建方法原型为:Task task(String name, Closure configureClosure)" 19 | println "任务描述:${description}" 20 | } 21 | } 22 | 23 | tasks.create('ex41CreateTask4') { 24 | description '演示任务创建' 25 | doLast { 26 | println "创建方法原型为:Task create(String name, Closure configureClosure) throws InvalidUserDataException" 27 | println "任务描述:${description}" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /chapter04/example42/build.gradle: -------------------------------------------------------------------------------- 1 | task ex42AccessTask1 2 | ex42AccessTask1.doLast { 3 | println 'ex42AccessTask1.doLast' 4 | } 5 | 6 | task ex42AccessTask2 7 | tasks['ex42AccessTask2'].doLast { 8 | println 'ex42AccessTask2.doLast' 9 | } 10 | 11 | task ex42AccessTask3 12 | tasks['ex42AccessTask3'].doLast { 13 | println tasks.findByPath(':example42:ex42AccessTask3') 14 | println tasks.getByPath(':example42:ex42AccessTask3') 15 | println tasks.findByPath(':example42:asdfasdfasdf') 16 | } 17 | 18 | task ex42AccessTask4 19 | tasks['ex42AccessTask4'].doLast { 20 | println tasks.findByName('ex42AccessTask4') 21 | println tasks.getByName('ex42AccessTask4') 22 | println tasks.findByName('asdfasdfasdf') 23 | } -------------------------------------------------------------------------------- /chapter04/example43/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | 3 | def Task myTask = task ex43GroupTask 4 | myTask.group = BasePlugin.BUILD_GROUP 5 | myTask.description = '这是一个构建的引导任务' 6 | 7 | myTask.doLast { 8 | println "group:${group},description:${description}" 9 | } -------------------------------------------------------------------------------- /chapter04/example45/build.gradle: -------------------------------------------------------------------------------- 1 | def Task myTask = task ex45CustomTask(type: CustomTask) 2 | myTask.doFirst{ 3 | println 'Task执行之前执行 in doFirst' 4 | } 5 | myTask.doLast{ 6 | println 'Task执行之后执行 in doLast' 7 | } 8 | 9 | class CustomTask extends DefaultTask { 10 | 11 | @TaskAction 12 | def doSelf() { 13 | println 'Task自己本身在执行 in doSelf' 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /chapter04/example46/build.gradle: -------------------------------------------------------------------------------- 1 | task ex46OrderTask1 << { 2 | println 'ex46OrderTask1' 3 | } 4 | 5 | task ex46OrderTask2 << { 6 | println 'ex46OrderTask2' 7 | } 8 | 9 | ex46OrderTask1.mustRunAfter ex46OrderTask2 10 | -------------------------------------------------------------------------------- /chapter04/example47/build.gradle: -------------------------------------------------------------------------------- 1 | task ex47DisenabledTask << { 2 | println 'ex47DisenabledTask' 3 | } 4 | 5 | ex47DisenabledTask.enabled =false 6 | 7 | -------------------------------------------------------------------------------- /chapter04/example48/build.gradle: -------------------------------------------------------------------------------- 1 | final String BUILD_APPS_ALL="all"; 2 | final String BUILD_APPS_SHOUFA="shoufa"; 3 | final String BUILD_APPS_EXCLUDE_SHOUFA="exclude_shoufa"; 4 | 5 | task ex48QQRelease << { 6 | println "打应用宝的包" 7 | } 8 | task ex48BaiduRelease << { 9 | println "打百度的包" 10 | } 11 | task ex48HuaweiRelease << { 12 | println "打华为的包" 13 | } 14 | 15 | task ex48MiuiRelease << { 16 | println "打Miui的包" 17 | } 18 | 19 | task build { 20 | group BasePlugin.BUILD_GROUP 21 | description "打渠道包" 22 | } 23 | 24 | build.dependsOn ex48QQRelease,ex48BaiduRelease,ex48HuaweiRelease,ex48MiuiRelease 25 | 26 | ex48QQRelease.onlyIf { 27 | def execute = false; 28 | if(project.hasProperty("build_apps")){ 29 | Object buildApps = project.property("build_apps") 30 | if(BUILD_APPS_SHOUFA.equals(buildApps) 31 | || BUILD_APPS_ALL.equals(buildApps)){ 32 | execute = true 33 | }else{ 34 | execute = false 35 | } 36 | }else{ 37 | execute = true 38 | } 39 | execute 40 | } 41 | 42 | ex48BaiduRelease.onlyIf { 43 | def execute = false; 44 | if(project.hasProperty("build_apps")){ 45 | Object buildApps = project.property("build_apps") 46 | if(BUILD_APPS_SHOUFA.equals(buildApps) 47 | || BUILD_APPS_ALL.equals(buildApps)){ 48 | execute = true 49 | }else{ 50 | execute = false 51 | } 52 | }else{ 53 | execute = true 54 | } 55 | execute 56 | } 57 | 58 | ex48HuaweiRelease.onlyIf { 59 | def execute = false; 60 | if(project.hasProperty("build_apps")){ 61 | Object buildApps = project.property("build_apps") 62 | if(BUILD_APPS_EXCLUDE_SHOUFA.equals(buildApps) 63 | || BUILD_APPS_ALL.equals(buildApps)){ 64 | execute = true 65 | }else{ 66 | execute = false 67 | } 68 | }else{ 69 | execute = true 70 | } 71 | execute 72 | } 73 | 74 | ex48MiuiRelease.onlyIf { 75 | def execute = false; 76 | if(project.hasProperty("build_apps")){ 77 | Object buildApps = project.property("build_apps") 78 | if(BUILD_APPS_EXCLUDE_SHOUFA.equals(buildApps) 79 | || BUILD_APPS_ALL.equals(buildApps)){ 80 | execute = true 81 | }else{ 82 | execute = false 83 | } 84 | }else{ 85 | execute = true 86 | } 87 | execute 88 | } 89 | -------------------------------------------------------------------------------- /chapter04/example49/build.gradle: -------------------------------------------------------------------------------- 1 | tasks.addRule("对该规则的一个描述,便于调试、查看等") { String taskName -> 2 | task(taskName) << { 3 | println "该${taskName}任务不存在,请查证后再执行" 4 | } 5 | } 6 | 7 | task ex49RuleTask { 8 | dependsOn missTask 9 | } -------------------------------------------------------------------------------- /chapter05/example52/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | apply plugin:'java' 5 | apply plugin:org.gradle.api.plugins.JavaPlugin 6 | apply plugin:JavaPlugin 7 | apply { 8 | plugin 'java' 9 | } 10 | 11 | apply(new Action() { 12 | @Override 13 | void execute(ObjectConfigurationAction objectConfigurationAction) { 14 | objectConfigurationAction.plugin('java') 15 | } 16 | }) 17 | 18 | apply from:'version.gradle' 19 | 20 | task ex52PrintlnTask << { 21 | println "App版本是:${versionName},版本号是:${versionCode}" 22 | } 23 | -------------------------------------------------------------------------------- /chapter05/example52/version.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | versionName = '1.0.0' 3 | versionCode = 1 4 | } -------------------------------------------------------------------------------- /chapter05/example53/build.gradle: -------------------------------------------------------------------------------- 1 | /*apply plugin: Ex53CustomPlugin 2 | 3 | class Ex53CustomPlugin implements Plugin { 4 | void apply(Project project) { 5 | project.task('ex53CustomTask') << { 6 | println "这是一个通过自定义插件方式创建的任务" 7 | } 8 | } 9 | }*/ 10 | 11 | buildscript { 12 | dependencies { 13 | classpath files('libs/example53.jar') 14 | } 15 | } 16 | 17 | 18 | apply plugin: 'groovy' 19 | apply plugin: 'com.github.rujews.plugins.ex53customplugin' 20 | 21 | dependencies { 22 | compile gradleApi() 23 | compile localGroovy() 24 | } 25 | -------------------------------------------------------------------------------- /chapter05/example53/libs/example53.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter05/example53/libs/example53.jar -------------------------------------------------------------------------------- /chapter05/example53/src/main/groovy/com/github/rujews/plugins/Ex53CustomPlugin.groovy: -------------------------------------------------------------------------------- 1 | package com.github.rujews.plugins 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | 6 | /** 7 | * Created by 飞雪无情 on 16-1-17. 8 | */ 9 | class Ex53CustomPlugin implements Plugin{ 10 | 11 | @Override 12 | void apply(Project target) { 13 | target.task('ex53CustomTask') << { 14 | println "这是一个通过自定义插件方式创建的任务" 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /chapter05/example53/src/main/resources/META-INF/gradle-plugins/com.github.rujews.plugins.ex53customplugin.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.github.rujews.plugins.Ex53CustomPlugin -------------------------------------------------------------------------------- /chapter06/example610/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin:'java' 2 | apply plugin:'idea' 3 | apply plugin:'eclipse' -------------------------------------------------------------------------------- /chapter06/example62/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin:'java' 2 | 3 | sourceSets { 4 | vip{ 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /chapter06/example63/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin:'java' 2 | 3 | repositories { 4 | mavenCentral() 5 | /*maven { 6 | url 'http://www.mavenurl.com/' 7 | }*/ 8 | } 9 | 10 | dependencies { 11 | compile 'com.squareup.okhttp3:okhttp:3.0.1' 12 | } -------------------------------------------------------------------------------- /chapter06/example64/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin:'java' -------------------------------------------------------------------------------- /chapter06/example64/src/main/java/org/flysnow/androidgradlebook/ex68/app/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.androidgradlebook.ex68.app; 2 | 3 | /** 4 | * Created by 飞雪无情 on 16-1-22. 5 | */ 6 | public class HelloWorld { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /chapter06/example64/src/main/resources/config.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter06/example64/src/main/resources/config.properties -------------------------------------------------------------------------------- /chapter06/example65/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin:'java' 2 | 3 | sourceSets { 4 | main { 5 | //这里对main SourceSet配置 6 | } 7 | } 8 | 9 | task ex65SourceSetTask { 10 | sourceSets.all{ 11 | println name 12 | } 13 | } -------------------------------------------------------------------------------- /chapter06/example68/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin:'java' 2 | 3 | dependencies { 4 | compile project(':example68base') 5 | } -------------------------------------------------------------------------------- /chapter06/example68/app/src/main/java/org/flysnow/androidgradlebook/ex68/app/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.androidgradlebook.ex68.app; 2 | 3 | import org.flysnow.androidgradlebook.ex68.base.Person; 4 | 5 | /** 6 | * Created by 飞雪无情 on 16-1-24. 7 | */ 8 | public class HelloWorld { 9 | public static void main(String[] args){ 10 | Person person =new Person(); 11 | person.setName("张三"); 12 | person.setAge(18); 13 | System.out.println(person.toString()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /chapter06/example68/base/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin:'java' -------------------------------------------------------------------------------- /chapter06/example68/base/src/main/java/org/flysnow/androidgradlebook/ex68/base/Person.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.androidgradlebook.ex68.base; 2 | 3 | /** 4 | * Created by 飞雪无情 on 16-1-24. 5 | */ 6 | public class Person { 7 | private String name; 8 | private int age; 9 | 10 | public String getName() { 11 | return name; 12 | } 13 | 14 | public void setName(String name) { 15 | this.name = name; 16 | } 17 | 18 | public int getAge() { 19 | return age; 20 | } 21 | 22 | public void setAge(int age) { 23 | this.age = age; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "Person{" + 29 | "name='" + name + '\'' + 30 | ", age=" + age + 31 | '}'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /chapter06/example69/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin:'java' 2 | apply plugin:'maven' 3 | 4 | task publishJar(type: Jar) 5 | 6 | group 'org.flysnow.androidgradlebook.ex69' 7 | version '1.0.0' 8 | 9 | artifacts { 10 | archives publishJar 11 | } 12 | 13 | uploadArchives { 14 | repositories { 15 | flatDir { 16 | name 'libs' 17 | dirs "$projectDir/libs" 18 | } 19 | mavenLocal() 20 | mavenDeployer { 21 | repository(url: "http://repo.mycompany.com/nexus/content/repositories/releases") { 22 | authentication(userName: "usrname", password: "pwd") 23 | } 24 | snapshotRepository(url: "http://repo.mycompany.com/nexus/content/repositories/snapshots") { 25 | authentication(userName: "usrname", password: "pwd") 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /chapter06/example69/libs/example69-1.0.0.jar.sha1: -------------------------------------------------------------------------------- 1 | 864a5b5134f9428a2bcb107229a2f86503ffbf21 -------------------------------------------------------------------------------- /chapter06/example69/libs/ivy-1.0.0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter06/example69/libs/ivy-1.0.0.xml.sha1: -------------------------------------------------------------------------------- 1 | 835192e400cc248f8de511ea4b65697a311d8d8b -------------------------------------------------------------------------------- /chapter07/example73/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:2.2.3' 7 | } 8 | } 9 | apply plugin: 'com.android.application' 10 | 11 | android { 12 | compileSdkVersion 23 13 | buildToolsVersion "23.0.1" 14 | 15 | defaultConfig { 16 | applicationId "org.flysnow.app.example73" 17 | minSdkVersion 14 18 | targetSdkVersion 23 19 | versionCode 1 20 | versionName "1.0" 21 | } 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 26 | } 27 | } 28 | } 29 | 30 | dependencies { 31 | compile fileTree(dir: 'libs', include: ['*.jar']) 32 | testCompile 'junit:junit:4.12' 33 | compile 'com.android.support:appcompat-v7:23.1.1' 34 | compile 'com.android.support:design:23.1.1' 35 | } 36 | -------------------------------------------------------------------------------- /chapter07/example73/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter07/example73/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /chapter07/example73/src/main/java/org/flysnow/app/example73/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example73; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.FloatingActionButton; 5 | import android.support.design.widget.Snackbar; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.support.v7.widget.Toolbar; 8 | import android.view.View; 9 | import android.view.Menu; 10 | import android.view.MenuItem; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_main); 18 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 19 | setSupportActionBar(toolbar); 20 | 21 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 22 | fab.setOnClickListener(new View.OnClickListener() { 23 | @Override 24 | public void onClick(View view) { 25 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 26 | .setAction("Action", null).show(); 27 | } 28 | }); 29 | } 30 | 31 | @Override 32 | public boolean onCreateOptionsMenu(Menu menu) { 33 | // Inflate the menu; this adds items to the action bar if it is present. 34 | getMenuInflater().inflate(R.menu.menu_main, menu); 35 | return true; 36 | } 37 | 38 | @Override 39 | public boolean onOptionsItemSelected(MenuItem item) { 40 | // Handle action bar item clicks here. The action bar will 41 | // automatically handle clicks on the Home/Up button, so long 42 | // as you specify a parent activity in AndroidManifest.xml. 43 | int id = item.getItemId(); 44 | 45 | //noinspection SimplifiableIfStatement 46 | if (id == R.id.action_settings) { 47 | return true; 48 | } 49 | 50 | return super.onOptionsItemSelected(item); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 22 | 23 | 24 | 25 | 26 | 27 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 20 | 21 | -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter07/example73/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter07/example73/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter07/example73/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter07/example73/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter07/example73/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | > 2 | 8 | 9 | -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example73 3 | Settings 4 | 5 | -------------------------------------------------------------------------------- /chapter07/example73/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 14 | 8 | 9 | -------------------------------------------------------------------------------- /chapter07/example74/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /chapter07/example74/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /chapter07/example74/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /chapter07/example74/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example74 3 | Settings 4 | 5 | -------------------------------------------------------------------------------- /chapter07/example74/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 14 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /chapter08/example82/src/test/java/org/flysnow/app/example82/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example82; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /chapter09/example91/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter09/example91/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | useLibrary 'org.apache.http.legacy' 20 | 21 | 22 | defaultConfig { 23 | applicationId "org.flysnow.app.example91" 24 | minSdkVersion 14 25 | targetSdkVersion 23 26 | versionCode 1 27 | versionName "1.0" 28 | } 29 | buildTypes { 30 | release { 31 | minifyEnabled false 32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 33 | zipAlignEnabled true 34 | } 35 | } 36 | } 37 | 38 | dependencies { 39 | compile fileTree(dir: 'libs', include: ['*.jar']) 40 | testCompile 'junit:junit:4.12' 41 | } 42 | -------------------------------------------------------------------------------- /chapter09/example91/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter09/example91/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter09/example91/src/main/java/org/flysnow/app/example91/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example91; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.widget.TextView; 6 | 7 | import org.apache.http.client.HttpClient; 8 | import org.apache.http.impl.client.DefaultHttpClient; 9 | 10 | public class MainActivity extends Activity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_main); 16 | 17 | String[] sharedLibraryNames = getPackageManager().getSystemSharedLibraryNames(); 18 | StringBuilder resultBuild = new StringBuilder(); 19 | for(String name:sharedLibraryNames){ 20 | resultBuild.append(name); 21 | resultBuild.append("\n"); 22 | } 23 | ((TextView)findViewById(android.R.id.text1)).setText(resultBuild); 24 | HttpClient httpClient = new DefaultHttpClient(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /chapter09/example91/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter09/example91/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example91/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example91/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example91/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example91/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example91/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example91/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example91/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example91/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example91/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example91/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example91 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter09/example911/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter09/example911/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | defaultConfig { 20 | applicationId "org.flysnow.app.example911" 21 | minSdkVersion 14 22 | targetSdkVersion 23 23 | versionCode 1 24 | versionName '1.0.0' 25 | //启用multidex 26 | multiDexEnabled true 27 | } 28 | buildTypes { 29 | release { 30 | minifyEnabled false 31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 32 | zipAlignEnabled true 33 | } 34 | } 35 | } 36 | dependencies { 37 | compile fileTree(dir: 'libs', include: ['*.jar']) 38 | compile 'com.android.support:multidex:1.0.1' 39 | } 40 | -------------------------------------------------------------------------------- /chapter09/example911/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter09/example911/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /chapter09/example911/src/main/java/org/flysnow/app/example911/Example911Application.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example911; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.support.multidex.MultiDex; 6 | 7 | /** 8 | * @author 飞雪无情 9 | * @since 16-3-30 下午11:42 10 | */ 11 | public class Example911Application extends Application{ 12 | @Override 13 | protected void attachBaseContext(Context base) { 14 | super.attachBaseContext(base); 15 | MultiDex.install(this); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /chapter09/example911/src/main/java/org/flysnow/app/example911/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example911; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | 7 | public class MainActivity extends Activity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_main); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /chapter09/example911/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter09/example911/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example911/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example911/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example911/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example911/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example911/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example911/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example911/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example911/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example911/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example911/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example11 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter09/example912/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter09/example912/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | defaultConfig { 20 | applicationId "org.flysnow.app.example912" 21 | minSdkVersion 14 22 | targetSdkVersion 23 23 | versionCode 1 24 | versionName '1.0.0' 25 | resConfigs 'zh' 26 | } 27 | buildTypes { 28 | release { 29 | minifyEnabled true 30 | shrinkResources true 31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 32 | zipAlignEnabled true 33 | } 34 | } 35 | } 36 | dependencies { 37 | compile fileTree(dir: 'libs', include: ['*.jar']) 38 | } 39 | -------------------------------------------------------------------------------- /chapter09/example912/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter09/example912/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter09/example912/src/main/java/org/flysnow/app/example912/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example912; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | 7 | public class MainActivity extends Activity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_main); 13 | getResources().getIdentifier("unused","drawable",getPackageName()); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /chapter09/example912/src/main/res/drawable/unused.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example912/src/main/res/drawable/unused.jpg -------------------------------------------------------------------------------- /chapter09/example912/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter09/example912/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example912/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example912/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example912/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example912/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example912/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example912/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example912/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example912/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example912/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example912/src/main/res/raw/keep.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /chapter09/example912/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example912 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter09/example92/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter09/example92/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | useLibrary 'org.apache.http.legacy' 20 | 21 | 22 | defaultConfig { 23 | applicationId "org.flysnow.app.example92" 24 | minSdkVersion 14 25 | targetSdkVersion 23 26 | versionCode 1 27 | versionName "1.0" 28 | } 29 | buildTypes { 30 | release { 31 | minifyEnabled false 32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 33 | zipAlignEnabled true 34 | } 35 | } 36 | productFlavors { 37 | google { 38 | 39 | } 40 | } 41 | applicationVariants.all { variant -> 42 | variant.outputs.each { output -> 43 | if (output.outputFile != null && output.outputFile.name.endsWith('.apk') 44 | &&'release'.equals(variant.buildType.name)) { 45 | def flavorName = variant.flavorName.startsWith("_") ? variant.flavorName.substring(1) : variant.flavorName 46 | def apkFile = new File( 47 | output.outputFile.getParent(), 48 | "Example92_${flavorName}_v${variant.versionName}_${buildTime()}.apk") 49 | output.outputFile = apkFile 50 | } 51 | } 52 | } 53 | } 54 | 55 | def buildTime() { 56 | def date = new Date() 57 | def formattedDate = date.format('yyyyMMdd') 58 | return formattedDate 59 | } 60 | 61 | dependencies { 62 | compile fileTree(dir: 'libs', include: ['*.jar']) 63 | testCompile 'junit:junit:4.12' 64 | } 65 | -------------------------------------------------------------------------------- /chapter09/example92/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter09/example92/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter09/example92/src/main/java/org/flysnow/app/example92/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example92; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.widget.TextView; 6 | 7 | import org.apache.http.client.HttpClient; 8 | import org.apache.http.impl.client.DefaultHttpClient; 9 | 10 | public class MainActivity extends Activity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_main); 16 | 17 | String[] sharedLibraryNames = getPackageManager().getSystemSharedLibraryNames(); 18 | StringBuilder resultBuild = new StringBuilder(); 19 | for(String name:sharedLibraryNames){ 20 | resultBuild.append(name); 21 | resultBuild.append("\n"); 22 | } 23 | ((TextView)findViewById(android.R.id.text1)).setText(resultBuild); 24 | HttpClient httpClient = new DefaultHttpClient(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /chapter09/example92/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter09/example92/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example92/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example92/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example92/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example92/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example92/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example92/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example92/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example92/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example92/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example92/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example92 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter09/example93/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter09/example93/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | 20 | defaultConfig { 21 | applicationId "org.flysnow.app.example93" 22 | minSdkVersion 14 23 | targetSdkVersion 23 24 | versionCode getAppVersionCode() 25 | versionName getAppVersionName() 26 | } 27 | buildTypes { 28 | release { 29 | minifyEnabled false 30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 31 | zipAlignEnabled true 32 | } 33 | } 34 | } 35 | /** 36 | * 以git tag的数量作为其版本号 37 | * @return tag的数量 38 | */ 39 | def getAppVersionCode(){ 40 | def stdout = new ByteArrayOutputStream() 41 | exec { 42 | commandLine 'git','tag','--list' 43 | standardOutput = stdout 44 | } 45 | return stdout.toString().split("\n").size() 46 | } 47 | 48 | /** 49 | * 从git tag中获取应用的版本名称 50 | * @return git tag的名称 51 | */ 52 | def getAppVersionName(){ 53 | def stdout = new ByteArrayOutputStream() 54 | exec { 55 | commandLine 'git','describe','--abbrev=0','--tags' 56 | standardOutput = stdout 57 | } 58 | return stdout.toString().replaceAll("\n","") 59 | } 60 | 61 | dependencies { 62 | compile fileTree(dir: 'libs', include: ['*.jar']) 63 | testCompile 'junit:junit:4.12' 64 | } 65 | -------------------------------------------------------------------------------- /chapter09/example93/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter09/example93/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter09/example93/src/main/java/org/flysnow/app/example93/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example93; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.widget.TextView; 6 | 7 | public class MainActivity extends Activity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_main); 13 | 14 | String[] sharedLibraryNames = getPackageManager().getSystemSharedLibraryNames(); 15 | StringBuilder resultBuild = new StringBuilder(); 16 | for(String name:sharedLibraryNames){ 17 | resultBuild.append(name); 18 | resultBuild.append("\n"); 19 | } 20 | ((TextView)findViewById(android.R.id.text1)).setText(resultBuild); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /chapter09/example93/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter09/example93/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example93/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example93/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example93/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example93/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example93/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example93/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example93/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example93/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example93/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example93/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example93 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter09/example93/version.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | appVersionCode =1 3 | appVersionName = "1.0.0" 4 | } -------------------------------------------------------------------------------- /chapter09/example94/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter09/example94/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | signingConfigs { 20 | def appStoreFile = System.getenv("STORE_FILE") 21 | def appStorePassword = System.getenv("STORE_PASSWORD") 22 | def appKeyAlias = System.getenv("KEY_ALIAS") 23 | def appKeyPassword = System.getenv("KEY_PASSWORD") 24 | 25 | //当不能从环境变量里获取到签名信息的时候,就使用模式的 26 | if(!appStoreFile||!appStorePassword||!appKeyAlias||!appKeyPassword){ 27 | appStoreFile = "debug.keystore" 28 | appStorePassword = "android" 29 | appKeyAlias = "androiddebugkey" 30 | appKeyPassword = "android" 31 | } 32 | release { 33 | storeFile file(appStoreFile) 34 | storePassword appStorePassword 35 | keyAlias appKeyAlias 36 | keyPassword appKeyPassword 37 | } 38 | } 39 | 40 | defaultConfig { 41 | applicationId "org.flysnow.app.example94" 42 | minSdkVersion 14 43 | targetSdkVersion 23 44 | versionCode 1 45 | versionName '1.0.0' 46 | } 47 | buildTypes { 48 | release { 49 | signingConfig signingConfigs.release 50 | minifyEnabled false 51 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 52 | zipAlignEnabled true 53 | } 54 | } 55 | } 56 | dependencies { 57 | compile fileTree(dir: 'libs', include: ['*.jar']) 58 | testCompile 'junit:junit:4.12' 59 | } 60 | -------------------------------------------------------------------------------- /chapter09/example94/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example94/debug.keystore -------------------------------------------------------------------------------- /chapter09/example94/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter09/example94/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter09/example94/src/main/java/org/flysnow/app/example94/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example94; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.widget.TextView; 6 | 7 | 8 | public class MainActivity extends Activity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_main); 14 | 15 | String[] sharedLibraryNames = getPackageManager().getSystemSharedLibraryNames(); 16 | StringBuilder resultBuild = new StringBuilder(); 17 | for(String name:sharedLibraryNames){ 18 | resultBuild.append(name); 19 | resultBuild.append("\n"); 20 | } 21 | ((TextView)findViewById(android.R.id.text1)).setText(resultBuild); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /chapter09/example94/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter09/example94/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example94/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example94/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example94/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example94/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example94/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example94/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example94/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example94/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example94/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example94/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example94 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter09/example94/version.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | appVersionCode =1 3 | appVersionName = "1.0.0" 4 | } -------------------------------------------------------------------------------- /chapter09/example95/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter09/example95/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | defaultConfig { 20 | applicationId "org.flysnow.app.example95" 21 | minSdkVersion 14 22 | targetSdkVersion 23 23 | versionCode 1 24 | versionName '1.0.0' 25 | } 26 | buildTypes { 27 | release { 28 | minifyEnabled false 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | zipAlignEnabled true 31 | } 32 | } 33 | productFlavors { 34 | google { 35 | } 36 | baidu { 37 | } 38 | } 39 | 40 | productFlavors.all { flavor -> 41 | manifestPlaceholders.put("UMENG_CHANNEL",name) 42 | } 43 | } 44 | dependencies { 45 | compile fileTree(dir: 'libs', include: ['*.jar']) 46 | testCompile 'junit:junit:4.12' 47 | } 48 | -------------------------------------------------------------------------------- /chapter09/example95/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter09/example95/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /chapter09/example95/src/main/java/org/flysnow/app/example95/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example95; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.widget.TextView; 6 | 7 | 8 | public class MainActivity extends Activity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_main); 14 | 15 | String[] sharedLibraryNames = getPackageManager().getSystemSharedLibraryNames(); 16 | StringBuilder resultBuild = new StringBuilder(); 17 | for(String name:sharedLibraryNames){ 18 | resultBuild.append(name); 19 | resultBuild.append("\n"); 20 | } 21 | ((TextView)findViewById(android.R.id.text1)).setText(resultBuild); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /chapter09/example95/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter09/example95/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example95/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example95/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example95/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example95/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example95/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example95/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example95/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example95/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example95/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example95/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example95 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter09/example96/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter09/example96/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | defaultConfig { 20 | applicationId "org.flysnow.app.example96" 21 | minSdkVersion 14 22 | targetSdkVersion 23 23 | versionCode 1 24 | versionName '1.0.0' 25 | } 26 | buildTypes { 27 | release { 28 | minifyEnabled false 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | zipAlignEnabled true 31 | } 32 | } 33 | productFlavors { 34 | google { 35 | buildConfigField 'String','WEB_URL','"http://www.google.com"' 36 | } 37 | baidu { 38 | buildConfigField 'String','WEB_URL','"http://www.baidu.com"' 39 | } 40 | } 41 | } 42 | dependencies { 43 | compile fileTree(dir: 'libs', include: ['*.jar']) 44 | } 45 | -------------------------------------------------------------------------------- /chapter09/example96/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter09/example96/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter09/example96/src/main/java/org/flysnow/app/example96/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example96; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.widget.TextView; 6 | 7 | 8 | public class MainActivity extends Activity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_main); 14 | 15 | String[] sharedLibraryNames = getPackageManager().getSystemSharedLibraryNames(); 16 | StringBuilder resultBuild = new StringBuilder(); 17 | for(String name:sharedLibraryNames){ 18 | resultBuild.append(name); 19 | resultBuild.append("\n"); 20 | } 21 | ((TextView)findViewById(android.R.id.text1)).setText(resultBuild); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /chapter09/example96/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter09/example96/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example96/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example96/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example96/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example96/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example96/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example96/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example96/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example96/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example96/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example96/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example96 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter09/example97/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter09/example97/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | defaultConfig { 20 | applicationId "org.flysnow.app.example97" 21 | minSdkVersion 14 22 | targetSdkVersion 23 23 | versionCode 1 24 | versionName '1.0.0' 25 | } 26 | buildTypes { 27 | release { 28 | minifyEnabled false 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | zipAlignEnabled true 31 | } 32 | } 33 | productFlavors { 34 | google { 35 | resValue 'string','channel_tips','google渠道欢迎你' 36 | } 37 | baidu { 38 | resValue 'string','channel_tips','baidu渠道欢迎你' 39 | resValue 'color','main_bg','#567896' 40 | resValue 'integer-array','months','1</item>' 41 | } 42 | } 43 | aaptOptions { 44 | 45 | } 46 | } 47 | dependencies { 48 | compile fileTree(dir: 'libs', include: ['*.jar']) 49 | } 50 | -------------------------------------------------------------------------------- /chapter09/example97/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter09/example97/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter09/example97/src/main/java/org/flysnow/app/example97/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example97; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.widget.TextView; 6 | 7 | 8 | public class MainActivity extends Activity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_main); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /chapter09/example97/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter09/example97/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example97/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example97/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example97/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example97/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example97/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example97/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example97/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example97/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter09/example97/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter09/example97/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example97 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter11/example112/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter11/example112/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | defaultConfig { 20 | applicationId "org.flysnow.app.example112" 21 | minSdkVersion 14 22 | targetSdkVersion 23 23 | versionCode 1 24 | versionName '1.0.0' 25 | } 26 | buildTypes { 27 | release { 28 | minifyEnabled true 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | zipAlignEnabled true 31 | } 32 | } 33 | productFlavors { 34 | google { 35 | buildConfigField 'String','FLURRY_KEY','"BHJKOUASDASFKLZL"' 36 | } 37 | baidu { 38 | buildConfigField 'String','FLURRY_KEY','"HJSDKHFJDSF23478"' 39 | } 40 | } 41 | } 42 | dependencies { 43 | compile fileTree(dir: 'libs', include: ['*.jar']) 44 | } 45 | -------------------------------------------------------------------------------- /chapter11/example112/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter11/example112/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter11/example112/src/main/java/org/flysnow/app/example112/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example112; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | 7 | public class MainActivity extends Activity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_main); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /chapter11/example112/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter11/example112/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter11/example112/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter11/example112/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter11/example112/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter11/example112/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter11/example112/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter11/example112/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter11/example112/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter11/example112/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter11/example112/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter11/example112/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example112 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter11/example113/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter11/example113/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | defaultConfig { 20 | applicationId "org.flysnow.app.example113" 21 | minSdkVersion 14 22 | targetSdkVersion 23 23 | versionCode 1 24 | versionName '1.0.0' 25 | } 26 | buildTypes { 27 | release { 28 | minifyEnabled true 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | zipAlignEnabled true 31 | } 32 | } 33 | flavorDimensions "abi", "version" 34 | productFlavors { 35 | free { 36 | dimension 'version' 37 | } 38 | paid { 39 | dimension 'version' 40 | } 41 | x86 { 42 | dimension 'abi' 43 | } 44 | arm { 45 | dimension 'abi' 46 | } 47 | } 48 | } 49 | dependencies { 50 | compile fileTree(dir: 'libs', include: ['*.jar']) 51 | } 52 | -------------------------------------------------------------------------------- /chapter11/example113/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter11/example113/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter11/example113/src/main/java/org/flysnow/app/example113/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example113; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | 7 | public class MainActivity extends Activity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_main); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /chapter11/example113/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter11/example113/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter11/example113/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter11/example113/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter11/example113/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter11/example113/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter11/example113/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter11/example113/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter11/example113/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter11/example113/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter11/example113/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter11/example113/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example113 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter12/example122/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter12/example122/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | defaultConfig { 20 | applicationId "org.flysnow.app.example122" 21 | minSdkVersion 14 22 | targetSdkVersion 23 23 | versionCode 1 24 | versionName '1.0.0' 25 | } 26 | buildTypes { 27 | release { 28 | minifyEnabled true 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | zipAlignEnabled true 31 | } 32 | } 33 | } 34 | dependencies { 35 | compile fileTree(dir: 'libs', include: ['*.jar']) 36 | testCompile 'junit:junit:4.12' 37 | testCompile 'org.mockito:mockito-core:1.10.19' 38 | } 39 | -------------------------------------------------------------------------------- /chapter12/example122/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter12/example122/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter12/example122/src/main/java/org/flysnow/app/example122/EmailValidator.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example122; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | /** 7 | * @author 飞雪无情 8 | * @since 16-5-9 上午12:00 9 | */ 10 | public class EmailValidator { 11 | public static boolean isValidEmail(String email){ 12 | if (null==email || "".equals(email)) return false; 13 | //Pattern p = Pattern.compile("\\w+@(\\w+.)+[a-z]{2,3}"); //简单匹配 14 | Pattern p = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");//复杂匹配 15 | Matcher m = p.matcher(email); 16 | return m.matches(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter12/example122/src/main/java/org/flysnow/app/example122/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example122; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | 7 | public class MainActivity extends Activity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_main); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /chapter12/example122/src/main/java/org/flysnow/app/example122/Utils.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example122; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * @author 飞雪无情 7 | * @since 16-5-9 上午12:51 8 | */ 9 | public class Utils { 10 | private Context mContext; 11 | 12 | public Utils(Context context) { 13 | this.mContext = context; 14 | } 15 | public String getAppName(){ 16 | return String.valueOf(mContext.getString(R.string.app_name)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter12/example122/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter12/example122/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example122/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example122/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example122/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example122/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example122/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example122/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example122/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example122/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example122/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example122/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example122 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter12/example122/src/test/java/org/flysnow/app/example122/EmailValidatorTest.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example122; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.hamcrest.CoreMatchers.is; 6 | import static org.junit.Assert.assertThat; 7 | 8 | /** 9 | * @author 飞雪无情 10 | * @since 16-5-9 上午12:02 11 | */ 12 | public class EmailValidatorTest { 13 | @Test 14 | public void emailValidator_CorrectEmailSimple_ReturnsTrue() { 15 | assertThat(EmailValidator.isValidEmail("name@email.com"), is(true)); 16 | } 17 | @Test 18 | public void emailValidator_CorrectEmailSimple_ReturnsFalse() { 19 | assertThat(EmailValidator.isValidEmail("name"), is(false)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter12/example122/src/test/java/org/flysnow/app/example122/UtilsTest.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example122; 2 | 3 | import android.content.Context; 4 | 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.mockito.Mock; 8 | import org.mockito.runners.MockitoJUnitRunner; 9 | 10 | import static org.hamcrest.CoreMatchers.*; 11 | import static org.junit.Assert.*; 12 | import static org.mockito.Mockito.*; 13 | /** 14 | * @author 飞雪无情 15 | * @since 16-5-9 上午12:53 16 | */ 17 | @RunWith(MockitoJUnitRunner.class) 18 | public class UtilsTest { 19 | private static final String APP_NAME = "Example122"; 20 | 21 | @Mock 22 | Context mMockContext; 23 | @Test 24 | public void readAppNameFromContext(){ 25 | when(mMockContext.getString(R.string.app_name)).thenReturn(APP_NAME); 26 | 27 | Utils utils = new Utils(mMockContext); 28 | String appName = utils.getAppName(); 29 | assertThat(appName,is(APP_NAME)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /chapter12/example123/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter12/example123/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.1" 18 | 19 | defaultConfig { 20 | applicationId "org.flysnow.app.example123" 21 | minSdkVersion 14 22 | targetSdkVersion 23 23 | versionCode 1 24 | versionName '1.0.0' 25 | 26 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 27 | } 28 | buildTypes { 29 | release { 30 | minifyEnabled true 31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 32 | zipAlignEnabled true 33 | } 34 | debug { 35 | testCoverageEnabled = true 36 | } 37 | } 38 | } 39 | dependencies { 40 | compile fileTree(dir: 'libs', include: ['*.jar']) 41 | androidTestCompile 'com.android.support.test:runner:0.4.1' 42 | androidTestCompile 'com.android.support.test:rules:0.4.1' 43 | } -------------------------------------------------------------------------------- /chapter12/example123/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter12/example123/src/androidTest/java/org/flysnow/app/example123/MainActivityTest.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example126; 2 | 3 | import android.support.test.rule.ActivityTestRule; 4 | import android.support.test.runner.AndroidJUnit4; 5 | import android.test.suitebuilder.annotation.LargeTest; 6 | 7 | import org.junit.Before; 8 | import org.junit.Rule; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | 12 | /** 13 | * @author 飞雪无情 14 | * @since 16-5-14 下午11:03 15 | */ 16 | @RunWith(AndroidJUnit4.class) 17 | @LargeTest 18 | public class MainActivityTest { 19 | @Rule 20 | public ActivityTestRule mActivityRule = new ActivityTestRule<>( 21 | MainActivity.class); 22 | 23 | @Before 24 | public void initSomething(){ 25 | 26 | } 27 | 28 | @Test 29 | public void validSomething(){ 30 | mActivityRule.getActivity().findViewById(android.R.id.text1).performClick(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /chapter12/example123/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter12/example123/src/main/java/org/flysnow/app/example123/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example123; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | 7 | public class MainActivity extends Activity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_main); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /chapter12/example123/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter12/example123/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example123/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example123/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example123/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example123/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example123/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example123/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example123/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example123/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example123/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example123/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example123 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter12/example126/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter12/example126/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | 17 | compileSdkVersion 23 18 | buildToolsVersion "23.0.1" 19 | 20 | defaultConfig { 21 | applicationId "org.flysnow.app.example126" 22 | minSdkVersion 14 23 | targetSdkVersion 23 24 | versionCode 1 25 | versionName '1.0.0' 26 | } 27 | buildTypes { 28 | release { 29 | minifyEnabled true 30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 31 | zipAlignEnabled true 32 | } 33 | } 34 | lintOptions { 35 | abortOnError false 36 | warningsAsErrors true 37 | } 38 | } 39 | dependencies { 40 | compile fileTree(dir: 'libs', include: ['*.jar']) 41 | } 42 | -------------------------------------------------------------------------------- /chapter12/example126/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter12/example126/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter12/example126/src/main/java/org/flysnow/app/example126/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example126; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | 7 | public class MainActivity extends Activity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_main); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /chapter12/example126/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter12/example126/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example126/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example126/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example126/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example126/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example126/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example126/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example126/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example126/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter12/example126/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter12/example126/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example126 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter13/example131/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter13/example131/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | 17 | compileSdkVersion 23 18 | buildToolsVersion "23.0.1" 19 | 20 | defaultConfig { 21 | applicationId "org.flysnow.app.example131" 22 | minSdkVersion 14 23 | targetSdkVersion 23 24 | versionCode 1 25 | versionName '1.0.0' 26 | 27 | ndk { 28 | 29 | } 30 | } 31 | buildTypes { 32 | release { 33 | minifyEnabled true 34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 35 | zipAlignEnabled true 36 | } 37 | } 38 | } 39 | dependencies { 40 | compile fileTree(dir: 'libs', include: ['*.jar']) 41 | } 42 | -------------------------------------------------------------------------------- /chapter13/example131/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter13/example131/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter13/example131/src/main/java/org/flysnow/app/example131/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example131; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | 7 | public class MainActivity extends Activity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_main); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /chapter13/example131/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter13/example131/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter13/example131/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter13/example131/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter13/example131/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter13/example131/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter13/example131/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter13/example131/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter13/example131/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter13/example131/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter13/example131/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter13/example131/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example131 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /chapter13/example132/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /chapter13/example132/build.gradle: -------------------------------------------------------------------------------- 1 | //我是因为代码示例,有比较多的项目,所以把这个配置 2 | //放在的子工程里,开发中你可以在根工程里配置,这样每个 3 | //子工程就不用一遍遍配置了 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.2.3' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | android { 16 | 17 | compileSdkVersion 23 18 | buildToolsVersion "23.0.1" 19 | 20 | defaultConfig { 21 | applicationId "org.flysnow.app.example132" 22 | minSdkVersion 14 23 | targetSdkVersion 23 24 | versionCode 1 25 | versionName '1.0.0' 26 | 27 | ndk { 28 | moduleName 'helloworld' 29 | //abiFilters 'armeabi-v7a','x86' 30 | abiFilter 'armeabi-v7a' 31 | abiFilter 'x86' 32 | ldLibs 'log','z' 33 | } 34 | } 35 | buildTypes { 36 | release { 37 | minifyEnabled true 38 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 39 | zipAlignEnabled true 40 | } 41 | } 42 | } 43 | dependencies { 44 | compile fileTree(dir: 'libs', include: ['*.jar']) 45 | } 46 | -------------------------------------------------------------------------------- /chapter13/example132/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/flysnow/frame/android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /chapter13/example132/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter13/example132/src/main/java/org/flysnow/app/example132/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example132; 2 | 3 | /** 4 | * @author 飞雪无情 5 | * @since 16-6-1 下午9:24 6 | */ 7 | public class HelloWorld { 8 | static { 9 | System.loadLibrary("helloworld"); 10 | } 11 | public native String getHelloWorld(); 12 | } 13 | -------------------------------------------------------------------------------- /chapter13/example132/src/main/java/org/flysnow/app/example132/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.flysnow.app.example132; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.widget.TextView; 6 | 7 | 8 | public class MainActivity extends Activity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_main); 14 | 15 | HelloWorld helloWorld = new HelloWorld(); 16 | 17 | ((TextView)findViewById(android.R.id.text1)).setText(helloWorld.getHelloWorld()); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /chapter13/example132/src/main/jni/org_flysnow_app_example132_HelloWorld.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by flysnow on 16-6-1. 3 | // 4 | #include 5 | #include "org_flysnow_app_example132_HelloWorld.h" 6 | 7 | JNIEXPORT jstring JNICALL Java_org_flysnow_app_example132_HelloWorld_getHelloWorld 8 | (JNIEnv *env, jobject obj){ 9 | __android_log_print(ANDROID_LOG_INFO,"HelloWorld","测试Android Log日志打印"); 10 | return (*env)->NewStringUTF(env,"你好,《Android Gradle权威指南》的朋友们"); 11 | } 12 | -------------------------------------------------------------------------------- /chapter13/example132/src/main/jni/org_flysnow_app_example132_HelloWorld.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class org_flysnow_app_example132_HelloWorld */ 4 | 5 | #ifndef _Included_org_flysnow_app_example132_HelloWorld 6 | #define _Included_org_flysnow_app_example132_HelloWorld 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: org_flysnow_app_example132_HelloWorld 12 | * Method: getHelloWorld 13 | * Signature: ()Ljava/lang/String; 14 | */ 15 | JNIEXPORT jstring JNICALL Java_org_flysnow_app_example132_HelloWorld_getHelloWorld 16 | (JNIEnv *, jobject); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /chapter13/example132/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /chapter13/example132/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter13/example132/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter13/example132/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter13/example132/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter13/example132/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter13/example132/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter13/example132/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter13/example132/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter13/example132/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/chapter13/example132/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /chapter13/example132/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example132 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Tue May 31 23:42:41 CST 2016 16 | android.useDeprecatedNdk=true 17 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flysnoworg/android-gradle-book-code/477d0e6ebee1cf6b41e2fa1601e6ae1bc7e3f0ed/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 21:50:34 CST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://mirrors.flysnow.org/gradle/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'android-gradle-book-code' 2 | //第一章项目例子定义 3 | include ':example02' 4 | project(':example02').projectDir = new File(rootDir, 'chapter01/example02') 5 | include ':example03' 6 | project(':example03').projectDir = new File(rootDir, 'chapter01/example03') 7 | include ':example04' 8 | project(':example04').projectDir = new File(rootDir, 'chapter01/example04') 9 | //第二章项目例子定义 10 | include ':example21' 11 | project(':example21').projectDir = new File(rootDir, 'chapter02/example21') 12 | include ':example22' 13 | project(':example22').projectDir = new File(rootDir, 'chapter02/example22') 14 | include ':example23' 15 | project(':example23').projectDir = new File(rootDir, 'chapter02/example23') 16 | include ':example24' 17 | project(':example24').projectDir = new File(rootDir, 'chapter02/example24') 18 | include ':example25' 19 | project(':example25').projectDir = new File(rootDir, 'chapter02/example25') 20 | //第三章项目例子定义 21 | include ':example34' 22 | project(':example34').projectDir = new File(rootDir, 'chapter03/example34') 23 | include ':example35' 24 | project(':example35').projectDir = new File(rootDir, 'chapter03/example35') 25 | include ':example36' 26 | project(':example36').projectDir = new File(rootDir, 'chapter03/example36') 27 | include ':example37' 28 | project(':example37').projectDir = new File(rootDir, 'chapter03/example37') 29 | //第四章项目例子定义 30 | include ':example41' 31 | project(':example41').projectDir = new File(rootDir, 'chapter04/example41') 32 | include ':example42' 33 | project(':example42').projectDir = new File(rootDir, 'chapter04/example42') 34 | include ':example43' 35 | project(':example43').projectDir = new File(rootDir, 'chapter04/example43') 36 | include ':example45' 37 | project(':example45').projectDir = new File(rootDir, 'chapter04/example45') 38 | include ':example46' 39 | project(':example46').projectDir = new File(rootDir, 'chapter04/example46') 40 | include ':example47' 41 | project(':example47').projectDir = new File(rootDir, 'chapter04/example47') 42 | include ':example48' 43 | project(':example48').projectDir = new File(rootDir, 'chapter04/example48') 44 | include ':example49' 45 | project(':example49').projectDir = new File(rootDir, 'chapter04/example49') 46 | //第五章项目例子定义 47 | include ':example52' 48 | project(':example52').projectDir = new File(rootDir, 'chapter05/example52') 49 | include ':example53' 50 | project(':example53').projectDir = new File(rootDir, 'chapter05/example53') 51 | //第六章项目例子定义 52 | include ':example62' 53 | project(':example62').projectDir = new File(rootDir, 'chapter06/example62') 54 | include ':example63' 55 | project(':example63').projectDir = new File(rootDir, 'chapter06/example63') 56 | include ':example64' 57 | project(':example64').projectDir = new File(rootDir, 'chapter06/example64') 58 | include ':example65' 59 | project(':example65').projectDir = new File(rootDir, 'chapter06/example65') 60 | include ':example68app' 61 | project(':example68app').projectDir = new File(rootDir, 'chapter06/example68/app') 62 | include ':example68base' 63 | project(':example68base').projectDir = new File(rootDir, 'chapter06/example68/base') 64 | include ':example69' 65 | project(':example69').projectDir = new File(rootDir, 'chapter06/example69') 66 | include ':example610' 67 | project(':example610').projectDir = new File(rootDir, 'chapter06/example610') 68 | //第七章项目例子定义 69 | include ':example73' 70 | project(':example73').projectDir = new File(rootDir, 'chapter07/example73') 71 | include ':example74' 72 | project(':example74').projectDir = new File(rootDir, 'chapter07/example74') 73 | //第八章项目例子定义 74 | include ':example82' 75 | project(':example82').projectDir = new File(rootDir, 'chapter08/example82') 76 | //第九章项目例子定义 77 | include ':example91' 78 | project(':example91').projectDir = new File(rootDir, 'chapter09/example91') 79 | include ':example92' 80 | project(':example92').projectDir = new File(rootDir, 'chapter09/example92') 81 | include ':example93' 82 | project(':example93').projectDir = new File(rootDir, 'chapter09/example93') 83 | include ':example94' 84 | project(':example94').projectDir = new File(rootDir, 'chapter09/example94') 85 | include ':example95' 86 | project(':example95').projectDir = new File(rootDir, 'chapter09/example95') 87 | include ':example96' 88 | project(':example96').projectDir = new File(rootDir, 'chapter09/example96') 89 | include ':example97' 90 | project(':example97').projectDir = new File(rootDir, 'chapter09/example97') 91 | include ':example911' 92 | project(':example911').projectDir = new File(rootDir, 'chapter09/example911') 93 | include ':example912' 94 | project(':example912').projectDir = new File(rootDir, 'chapter09/example912') 95 | //第十一章项目例子定义 96 | include ':example112' 97 | project(':example112').projectDir = new File(rootDir, 'chapter11/example112') 98 | include ':example113' 99 | project(':example113').projectDir = new File(rootDir, 'chapter11/example113') 100 | //第十二章项目例子定义 101 | include ':example122' 102 | project(':example122').projectDir = new File(rootDir, 'chapter12/example122') 103 | include ':example123' 104 | project(':example123').projectDir = new File(rootDir, 'chapter12/example123') 105 | include ':example126' 106 | project(':example126').projectDir = new File(rootDir, 'chapter12/example126') 107 | //第十三章项目例子定义 108 | include ':example131' 109 | project(':example131').projectDir = new File(rootDir, 'chapter13/example131') 110 | include ':example132' 111 | project(':example132').projectDir = new File(rootDir, 'chapter13/example132') --------------------------------------------------------------------------------