├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ └── com │ │ └── demo │ │ └── debug_badge │ │ └── MainActivity.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-ldpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── attr ├── badge.png ├── clean.png └── task.png ├── badge ├── .gitignore ├── build.gradle └── src │ └── main │ ├── groovy │ └── com │ │ └── yuebinyun │ │ └── badge │ │ ├── BadgeExtension.groovy │ │ ├── BadgeFlavor.groovy │ │ └── Maker.groovy │ └── resources │ └── META-INF │ └── gradle-plugins │ └── com.yuebinyun.badge.properties ├── build.gradle ├── example ├── .gitignore ├── arrt │ └── device-2017-02-17-212120.png ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── yuebinyun │ │ └── example │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── yuebinyun │ │ │ └── example │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-ldpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── yuebinyun │ └── example │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | .idea 4 | local.properties 5 | build 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Add badge(version code, version name, etc) for your **DEBUG APK**. 2 | 3 | ![screenshot](attr/badge.png) 4 | 5 | Add it to your project! 6 | 7 | ### Clean your project 8 | ![clean](attr/clean.png) 9 | 10 | or 11 | ```bash 12 | ./gradlew clean 13 | ## or 14 | ## gradle clean 15 | ``` 16 | 17 | ### Add gradle plugin 18 | 19 | ```gradle 20 | buildscript { 21 | repositories { 22 | mavenCentral() 23 | } 24 | 25 | dependencies { 26 | classpath 'com.github.yuebinyun.debug-badge:debug-badge:0.1.3' 27 | } 28 | } 29 | 30 | apply plugin: 'com.android.application' 31 | apply plugin: 'com.yuebinyun.badge' 32 | 33 | android { 34 | //... 35 | // 36 | } 37 | 38 | dependencies { 39 | //... 40 | } 41 | 42 | // if you don't set flavor 43 | badge { 44 | // label = "Debug" 45 | // label = "Dev" // optional. Defualt text is `Debug` 46 | label = "${project.android.defaultConfig.versionName}" 47 | labelColor = 0xFFFFFF // optional. Default color is WHITE 48 | labelBgColor = 0x0099FF // optional. Defualt color is RED 49 | } 50 | ``` 51 | 52 | ```gradle 53 | // if you want to add badge for flavor-debug-version app 54 | badgeFlavor { 55 | 56 | demo { 57 | label = "demo" 58 | // label = "Dev" // optional. Defualt text is `Debug` 59 | // label = "${project.android.defaultConfig.versionName}" 60 | // labelColor = 0x000000 // optional. Default color is WHITE 61 | // labelBgColor = 0x0099FF // optional. Defualt color is RED 62 | } 63 | 64 | full { 65 | label = "full" 66 | // label = "Dev" // optional. Defualt text is `Debug` 67 | // label = "${project.android.defaultConfig.versionName}" 68 | // labelColor = 0x000000 // optional. Default color is WHITE 69 | // labelBgColor = 0x0099FF // optional. Defualt color is RED 70 | } 71 | 72 | // NOT SET 73 | // flavor1 { 74 | // label = "flavor1" 75 | // } 76 | 77 | flavor2 { 78 | label = "flavor2" 79 | labelColor = 0xFF00FF // optional. Default color is WHITE 80 | labelBgColor = 0x0099FF // optional. Defualt color is RED 81 | } 82 | } 83 | ``` 84 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.demo.debug_badge" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0.1" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | debug { 16 | //applicationIdSuffix ".debug" 17 | applicationIdSuffix ".dev" 18 | } 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | productFlavors { 26 | 27 | demoAbCdE { 28 | applicationIdSuffix ".demo" 29 | versionNameSuffix "-demo" 30 | } 31 | 32 | full { 33 | applicationIdSuffix ".full" 34 | versionNameSuffix "-full" 35 | } 36 | 37 | flavor1 { 38 | applicationIdSuffix ".fla1" 39 | versionNameSuffix "-demo" 40 | } 41 | 42 | flavor2 { 43 | applicationIdSuffix ".flav2" 44 | versionNameSuffix "-full" 45 | } 46 | } 47 | } 48 | 49 | dependencies { 50 | compile fileTree(dir: 'libs', include: ['*.jar']) 51 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 52 | exclude group: 'com.android.support', module: 'support-annotations' 53 | }) 54 | compile 'com.android.support:appcompat-v7:25.1.1' 55 | testCompile 'junit:junit:4.12' 56 | } 57 | 58 | 59 | /* 60 | 61 | buildscript { 62 | repositories { 63 | mavenLocal() 64 | } 65 | 66 | dependencies { 67 | classpath 'com.github.yuebinyun.debug-badge:debug-badge:0.1.2' 68 | } 69 | } 70 | 71 | apply plugin: 'com.yuebinyun.badge' 72 | 73 | badge { 74 | // label = "Debug" 75 | // label = "Dev" // optional. Defualt text is `Debug` 76 | label = "${project.android.defaultConfig.versionName}" 77 | // labelColor = 0x000000 // optional. Default color is WHITE 78 | // labelBgColor = 0x0099FF // optional. Defualt color is RED 79 | } 80 | 81 | //addDebugBadge.group 'demo' 82 | badgeFlavor { 83 | 84 | demoAbCdE { 85 | label = "demo" 86 | // label = "Dev" // optional. Defualt text is `Debug` 87 | // label = "${project.android.defaultConfig.versionName}" 88 | // labelColor = 0x000000 // optional. Default color is WHITE 89 | // labelBgColor = 0x0099FF // optional. Defualt color is RED 90 | } 91 | 92 | full { 93 | label = "full" 94 | // label = "Dev" // optional. Defualt text is `Debug` 95 | // label = "${project.android.defaultConfig.versionName}" 96 | // labelColor = 0x000000 // optional. Default color is WHITE 97 | // labelBgColor = 0x0099FF // optional. Defualt color is RED 98 | } 99 | 100 | // NOT SET 101 | // flavor1 { 102 | // label = "flavor1" 103 | // } 104 | 105 | flavor2 { 106 | label = "flavor2" 107 | labelColor = 0xFF00FF // optional. Default color is WHITE 108 | labelBgColor = 0x0099FF // optional. Defualt color is RED 109 | } 110 | } 111 | */ 112 | -------------------------------------------------------------------------------- /app/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 D:\AndroidSDK/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 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/java/com/demo/debug_badge/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.demo.debug_badge; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | public class MainActivity extends AppCompatActivity { 7 | 8 | @Override protected void onCreate(Bundle savedInstanceState) { 9 | super.onCreate(savedInstanceState); 10 | setContentView(R.layout.activity_main); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/app/src/main/res/mipmap-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Badge 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /attr/badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/attr/badge.png -------------------------------------------------------------------------------- /attr/clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/attr/clean.png -------------------------------------------------------------------------------- /attr/task.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/attr/task.png -------------------------------------------------------------------------------- /badge/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /badge/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'groovy' 2 | apply plugin: 'maven' 3 | apply plugin: 'signing' 4 | 5 | dependencies { 6 | compile gradleApi() 7 | compile localGroovy() 8 | } 9 | 10 | // best way to set group ID 11 | group = "com.github.yuebinyun.debug-badge" 12 | 13 | install { 14 | repositories.mavenInstaller { 15 | // only necessary if artifact ID diverges from project name 16 | // the latter defaults to project directory name and can be 17 | // configured in settings.gradle 18 | pom.artifactId = "debug-badge" 19 | pom.version = '0.1.3' 20 | } 21 | } 22 | 23 | def isReleaseBuild() { 24 | return VERSION_NAME.contains("SNAPSHOT") == false 25 | } 26 | 27 | 28 | def getRepositoryUsername() { 29 | return hasProperty('nexusUsername') ? nexusUsername : "" 30 | } 31 | 32 | def getRepositoryPassword() { 33 | return hasProperty('nexusPassword') ? nexusPassword : "" 34 | } 35 | 36 | afterEvaluate { project -> 37 | uploadArchives { 38 | repositories { 39 | mavenDeployer { 40 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 41 | 42 | pom.artifactId = POM_ARTIFACT_ID 43 | 44 | repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { 45 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) 46 | } 47 | 48 | pom.project { 49 | name POM_NAME 50 | packaging POM_PACKAGING 51 | description POM_DESCRIPTION 52 | url POM_URL 53 | 54 | scm { 55 | url POM_SCM_URL 56 | connection POM_SCM_CONNECTION 57 | developerConnection POM_SCM_DEV_CONNECTION 58 | } 59 | 60 | licenses { 61 | license { 62 | name POM_LICENCE_NAME 63 | url POM_LICENCE_URL 64 | distribution POM_LICENCE_DIST 65 | } 66 | } 67 | 68 | developers { 69 | developer { 70 | id POM_DEVELOPER_ID 71 | name POM_DEVELOPER_NAME 72 | } 73 | } 74 | } 75 | } 76 | } 77 | } 78 | 79 | signing { 80 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } 81 | sign configurations.archives 82 | } 83 | 84 | task doc(type: Jar, dependsOn: javadoc) { 85 | classifier = 'javadoc' 86 | from javadoc.destinationDir 87 | } 88 | 89 | task sourcesJar(type: Jar) { 90 | classifier = 'sources' 91 | from sourceSets.main.allSource 92 | } 93 | 94 | artifacts { 95 | archives doc 96 | archives sourcesJar 97 | } 98 | } -------------------------------------------------------------------------------- /badge/src/main/groovy/com/yuebinyun/badge/BadgeExtension.groovy: -------------------------------------------------------------------------------- 1 | package com.yuebinyun.badge; 2 | 3 | public class BadgeExtension { 4 | 5 | def String label = "Debug" 6 | def Integer labelColor = -1 7 | def Integer labelBgColor = -1 8 | 9 | @Override 10 | public String toString() { 11 | final StringBuffer sb = new StringBuffer("BadgeExtension{"); 12 | sb.append("label='").append(label).append('\''); 13 | sb.append(", labelColor=").append(labelColor); 14 | sb.append(", labelBgColor=").append(labelBgColor); 15 | sb.append('}'); 16 | return sb.toString(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /badge/src/main/groovy/com/yuebinyun/badge/BadgeFlavor.groovy: -------------------------------------------------------------------------------- 1 | package com.yuebinyun.badge; 2 | 3 | public class BadgeFlavor { 4 | 5 | final String name; 6 | def String label = "Debug" 7 | def Integer labelColor = -1 8 | def Integer labelBgColor = -1 9 | 10 | public BadgeFlavor(String name) { 11 | this.name = name; 12 | } 13 | 14 | @Override public String toString() { 15 | final StringBuffer sb = new StringBuffer("BadgeFlavor{"); 16 | sb.append("name='").append(name).append('\''); 17 | sb.append(", String=").append(String); 18 | sb.append(", Integer=").append(Integer); 19 | sb.append(", Integer=").append(Integer); 20 | sb.append('}'); 21 | return sb.toString(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /badge/src/main/groovy/com/yuebinyun/badge/Maker.groovy: -------------------------------------------------------------------------------- 1 | package com.yuebinyun.badge 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | 6 | import javax.imageio.ImageIO; 7 | import java.awt.*; 8 | import java.awt.image.BufferedImage; 9 | 10 | class Maker implements Plugin { 11 | 12 | @Override void apply(Project project) { 13 | 14 | project.extensions.create("badge", BadgeExtension) 15 | 16 | def debugBadges = project.container(BadgeFlavor) 17 | project.extensions.badgeFlavor = debugBadges 18 | 19 | project.tasks.all() { task -> 20 | 21 | task.doLast { 22 | 23 | if (task.name.equals("processDebugManifest")) { 24 | 25 | // no flavor in this module 26 | 27 | // debug res dir 28 | File debugDir = new File(project.buildDir, "intermediates/res/merged/debug") 29 | 30 | def BadgeFlavor badge = new BadgeFlavor("debug") 31 | badge.label = project.extensions.badge.label 32 | badge.labelColor = project.extensions.badge.labelColor 33 | badge.labelBgColor = project.extensions.badge.labelBgColor 34 | 35 | // debug version AndroidManifest.xml 36 | String manifestPath = project.buildDir.absolutePath + 37 | "/intermediates/manifests/full/debug/AndroidManifest.xml"; 38 | 39 | changeAllIconsInMultiDirs(project, debugDir, badge, manifestPath) 40 | // --- 41 | } else if (task.name.startsWith("process") && task.name.endsWith("DebugManifest")) { 42 | 43 | String curFlavorName = task.name.replace("process", ""). 44 | replace("DebugManifest", ""). 45 | toLowerCase(); 46 | BadgeFlavor badge = null; 47 | for (BadgeFlavor temp : project.extensions.badgeFlavor) { 48 | if (temp.name.toLowerCase().equals(curFlavorName)) { 49 | badge = temp; 50 | break 51 | } 52 | } 53 | 54 | if (badge == null) { 55 | // not set badge for current flavor 56 | println "--> NOT SET BADGE FOR FLAVOR :" + curFlavorName 57 | return 58 | } 59 | 60 | // debug res dir 61 | File debugResDir = new File(project.buildDir, 62 | "intermediates/res/merged/" + badge.name + "/debug") 63 | 64 | // flavor debug manifest file 65 | String manifestFile = project.buildDir.absolutePath + "/intermediates/manifests/full/" + 66 | badge.name + 67 | "/debug/AndroidManifest.xml" 68 | 69 | changeAllIconsInMultiDirs(project, debugResDir, badge, manifestFile) 70 | } 71 | } 72 | } 73 | } 74 | 75 | /** 76 | * 77 | * @param project 78 | * @param releaseResDir 79 | */ 80 | public static void changeAllIconsInMultiDirs(Project project, File debugDir, 81 | BadgeFlavor badge, String manifestPath) { 82 | String[] str = getAppIconInfo(new File(manifestPath)) 83 | if (str == null) { 84 | return; 85 | } 86 | 87 | String iconDirPrefix = str[0].replace("@", "") 88 | String iconFileName = str[1] 89 | 90 | for (File releaseImgDir : debugDir.listFiles(new FileFilter() { 91 | @Override 92 | boolean accept(File file) { 93 | return file.name.startsWith(iconDirPrefix) 94 | } 95 | })) { 96 | File debugIcon = new File(debugDir, 97 | releaseImgDir.name + "/" + iconFileName + ".png") 98 | if (debugIcon.exists()) { 99 | println "--> ADD BADGE ON " + debugIcon.absolutePath 100 | addBadgeOnIcon(debugIcon, badge.label, badge.labelColor, badge.labelBgColor) 101 | } else { 102 | println "*** BADGE PLUGIN WARNING : NO SUCH FILE: " + debugIcon.absolutePath 103 | } 104 | } 105 | } 106 | 107 | /** 108 | * 新建 Debug 版本的 ICON 图标 109 | * @param icon ---- Release 版本的图标文件名 110 | * @param dstImg ---- Debug 版本的图标文件名 111 | * @param label ----- Debug 版本图标上要显示的文字信息 112 | * @param labelColor - label 文字色 113 | * @param labelBgColor --- label 背景色 114 | */ 115 | public static void addBadgeOnIcon(File icon, String label, Integer labelColor, 116 | Integer labelBgColor) { 117 | 118 | BufferedImage image; 119 | image = ImageIO.read(icon); 120 | 121 | int width = image.getWidth(); 122 | int height = image.getHeight(); 123 | 124 | BufferedImage newImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 125 | Graphics2D g2d = newImg.createGraphics(); 126 | g2d.drawImage(image, 0, 0, null); 127 | 128 | FontMetrics fm = null 129 | 130 | for (int i = 10; i < 50; ++i) { 131 | g2d.setFont(new Font("Serif", Font.PLAIN, i)); 132 | fm = g2d.getFontMetrics(); 133 | 134 | if (fm.getHeight() * 4 > newImg.getHeight()) { 135 | // 文字的高度需大于整张图片 1/4 136 | break 137 | } 138 | } 139 | 140 | int x = newImg.getWidth() - fm.stringWidth(label) - 2; 141 | int y = newImg.getHeight() - fm.getAscent(); 142 | 143 | if (labelBgColor == null || labelBgColor < 0 || labelBgColor > 0xFFFFFF) { 144 | g2d.setColor(Color.RED) 145 | g2d.setPaint(Color.RED); 146 | } else { 147 | g2d.setPaint(new Color(labelBgColor)) 148 | g2d.setColor(new Color(labelBgColor)) 149 | } 150 | 151 | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 152 | g2d.fillRect(x - 4, y, newImg.getWidth() - x + 4, newImg.getHeight() - y); 153 | 154 | if (labelColor == null || labelColor < 0 || labelBgColor > 0xFFFFFF) { 155 | g2d.setPaint(Color.WHITE); 156 | g2d.setColor(Color.WHITE); 157 | } else { 158 | g2d.setPaint(new Color(labelColor)); 159 | g2d.setColor(new Color(labelColor)); 160 | } 161 | 162 | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 163 | g2d.drawString(label, x, newImg.getHeight() - fm.getDescent()); 164 | g2d.dispose(); 165 | 166 | // 保存生成的图片 167 | boolean ret = ImageIO.write(newImg, "png", icon); 168 | if (!ret) { 169 | println "*** Failed to add badge" 170 | } 171 | } 172 | 173 | // get app icon info 174 | public static String[] getAppIconInfo(File festFile) { 175 | 176 | if (!festFile.exists()) { 177 | println "Error, NO SUCH FILE " + festFile.absolutePath 178 | return null 179 | } 180 | 181 | def fest = new XmlSlurper().parse(festFile) 182 | String label = fest.application[0]['@android:icon'] 183 | return label.split('/') 184 | } 185 | 186 | /* 187 | public static void main(String[] args) { 188 | File file = new File("./app/src/main/AndroidManifest.xml") 189 | if (file.exists()) { 190 | println getAppIconInfo(file) 191 | } 192 | } 193 | */ 194 | } -------------------------------------------------------------------------------- /badge/src/main/resources/META-INF/gradle-plugins/com.yuebinyun.badge.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.yuebinyun.badge.Maker -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | 25 | task debug4Badeg(type:Exec){ 26 | commandLine 'cmd', '/c', 'gradlew :badge:install && gradlew :app:clean && gradlew :app:addDebugBadge' 27 | } -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /example/arrt/device-2017-02-17-212120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/example/arrt/device-2017-02-17-212120.png -------------------------------------------------------------------------------- /example/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.yuebinyun.example" 9 | minSdkVersion 15 10 | targetSdkVersion 25 11 | versionCode 1 12 | versionName "0.1.2" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | 21 | productFlavors { 22 | 23 | demoAbC { 24 | applicationIdSuffix ".demo" 25 | versionNameSuffix "-demo" 26 | } 27 | 28 | full { 29 | applicationIdSuffix ".full" 30 | versionNameSuffix "-full" 31 | } 32 | 33 | flavor1 { 34 | applicationIdSuffix ".fla1" 35 | versionNameSuffix "-fla1" 36 | } 37 | 38 | flavor2 { 39 | applicationIdSuffix ".fla2" 40 | versionNameSuffix "-fla2" 41 | } 42 | } 43 | } 44 | 45 | dependencies { 46 | compile fileTree(dir: 'libs', include: ['*.jar']) 47 | compile 'com.android.support:appcompat-v7:25.1.1' 48 | } 49 | 50 | 51 | // badge setting 52 | buildscript { 53 | repositories { 54 | mavenCentral() 55 | } 56 | 57 | dependencies { 58 | classpath 'com.github.yuebinyun.debug-badge:debug-badge:0.1.3' 59 | } 60 | } 61 | 62 | apply plugin: 'com.yuebinyun.badge' 63 | 64 | 65 | badge { 66 | // label = "Debug" 67 | // label = "Dev" // optional. Defualt text is `Debug` 68 | label = "${project.android.defaultConfig.versionName}" 69 | labelColor = 0xFFFFFF // optional. Default color is WHITE 70 | labelBgColor = 0x0099FF // optional. Defualt color is RED 71 | } 72 | 73 | // if you want to add badge for flavor-debug-version app 74 | badgeFlavor { 75 | 76 | demoAbC { 77 | label = "demo" 78 | // label = "Dev" // optional. Defualt text is `Debug` 79 | // label = "${project.android.defaultConfig.versionName}" 80 | // labelColor = 0x000000 // optional. Default color is WHITE 81 | // labelBgColor = 0x0099FF // optional. Defualt color is RED 82 | } 83 | 84 | full { 85 | label = "full" 86 | // label = "Dev" // optional. Defualt text is `Debug` 87 | // label = "${project.android.defaultConfig.versionName}" 88 | // labelColor = 0x000000 // optional. Default color is WHITE 89 | // labelBgColor = 0x0099FF // optional. Defualt color is RED 90 | } 91 | 92 | // NOT SET 93 | // flavor1 { 94 | // label = "flavor1" 95 | // } 96 | 97 | flavor2 { 98 | label = "flavor2" 99 | labelColor = 0xFF00FF // optional. Default color is WHITE 100 | labelBgColor = 0x0099FF // optional. Defualt color is RED 101 | } 102 | } -------------------------------------------------------------------------------- /example/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 D:\AndroidSDK/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 | -------------------------------------------------------------------------------- /example/src/androidTest/java/com/yuebinyun/example/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.yuebinyun.example; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { 18 | @Test public void useAppContext() throws Exception { 19 | // Context of the app under test. 20 | Context appContext = InstrumentationRegistry.getTargetContext(); 21 | 22 | assertEquals("com.yuebinyun.example", appContext.getPackageName()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /example/src/main/java/com/yuebinyun/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.yuebinyun.example; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | public class MainActivity extends AppCompatActivity { 7 | 8 | @Override protected void onCreate(Bundle savedInstanceState) { 9 | super.onCreate(savedInstanceState); 10 | setContentView(R.layout.activity_main); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 18 | 19 | -------------------------------------------------------------------------------- /example/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/example/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/example/src/main/res/mipmap-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/example/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/example/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/example/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /example/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /example/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /example/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | example 3 | 4 | -------------------------------------------------------------------------------- /example/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /example/src/test/java/com/yuebinyun/example/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.yuebinyun.example; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test public void addition_isCorrect() throws Exception { 14 | assertEquals(4, 2 + 2); 15 | } 16 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | 13 | org.gradle.jvmargs=-Xmx1536m 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | POM_NAME=add badge for icon 21 | POM_ARTIFACT_ID=debug-badge 22 | POM_PACKAGING=jar 23 | 24 | VERSION_NAME=0.1.3 25 | VERSION_CODE=1 26 | GROUP="com.github.yuebinyun.debug-badge" 27 | POM_DESCRIPTION=add badge on icon 28 | POM_URL=https://github.com/yuebinyun/debug-badge/ 29 | POM_SCM_URL=https://github.com/yuebinyun/debug-badge/ 30 | POM_SCM_CONNECTION=scm:git@github.com/yuebinyun/debug-badge.git 31 | POM_SCM_DEV_CONNECTION=scm:git@github.com:yuebinyun/.git 32 | POM_LICENCE_NAME=The Apache Software License, Version 2.0 33 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 34 | POM_LICENCE_DIST=repo 35 | POM_DEVELOPER_ID=yuebinyun 36 | POM_DEVELOPER_NAME=yuebinyun 37 | 38 | groupId=com.github.yuebinyun.debug-badge 39 | artifactId=badgdebug-badgee 40 | version=0.1.3 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuebinyun/debug-badge/9abc5c9aaa66aa8bf70b2d7adc940d1abd0908f8/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/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 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /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 | include ':app', ':badge', ':example' 2 | --------------------------------------------------------------------------------