diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 7158618..cc67baf 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -51,7 +51,7 @@ diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/app-channel_default-release.apk b/app/app-channel_default-release.apk new file mode 100644 index 0000000..c45dda2 Binary files /dev/null and b/app/app-channel_default-release.apk differ diff --git a/app/build.gradle b/app/build.gradle index cce0ab7..051a327 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' + android { compileSdkVersion 25 buildToolsVersion "25.0.3" @@ -12,21 +13,140 @@ android { versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } + dexOptions { + preDexLibraries = false + } + + lintOptions { + abortOnError false + } + signingConfigs { + release { + try { + storeFile file(KEYSTORE_FILE) + storePassword KEYSTORE_PASSWORD + keyAlias KEYSTORE_ALIAS + keyPassword KEY_PASSWORD + } + catch (ignored) { + if (System.getenv("KEYSTORE_FILE") != null) { + storeFile = file(System.getenv("KEYSTORE_FILE")) + storePassword = System.getenv("KEYSTORE_PWD") + keyAlias = System.getenv("KEYSTORE_ALIAS") + keyPassword = System.getenv("KEYSTORE_ALIAS_PWD") + } else { + throw new InvalidUserDataException("You should define KEYSTORE_PASSWORD and KEY_PASSWORD in gradle.properties.") + } + } + } + } + buildTypes { release { - minifyEnabled false + signingConfig signingConfigs.release + minifyEnabled true + shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + applicationVariants.all { variant -> + if (variant.buildType.name == 'release') { + variant.mergedFlavor.versionName = VersionName() + variant.mergedFlavor.versionCode = getGitVersionCode() + renameArtifact(variant) + } + + } + } + } + + productFlavors { + + "360" { + applicationId "com.hcy.tomeetu" + } + + huawei { + applicationId "com.hcy.tomeetu" } + } } +def renameArtifact(variant) { + + variant.outputs.each { output -> + output.outputFile = new File( + (String) output.outputFile.parent, + (String) "${variant.productFlavors[0].name}-${variant.buildType.name}-code-${variant.versionCode}-(v${variant.versionName})-${releaseTime()}.apk".toLowerCase()) + } +} + +def releaseTime() { + return new Date().format("yyyyMMdd-HHmmss") +} + + +def getGitVersionCode() { + + def cmd = 'git rev-list HEAD --count' + + int gitVersion = cmd.execute().text.trim().toInteger() + + println("the git version is : " + gitVersion) + + return gitVersion + +} +//使用git的Tag来自动定制Version +def VersionName() { + def cmd = 'git tag' + def tags = cmd.execute().text.readLines() + /* if (tags.size() >= 1) { + def version_last = tags.last().trim() //newest + cmd = 'git rev-list ' + version_last + '.. --count' + if (tags.size() >= 2) { + tags.remove(tags.last()) + def version_last_2 = tags.last().trim() //newest + cmd = 'git rev-list ' + version_last_2 + '..' + version_last + ' --count' + } + } else { + cmd = 'git rev-list --count' + }*/ + cmd = 'git rev-list --all --count' + def code = cmd.execute().text.trim().toInteger() + + def versionName = tags.last().trim().replaceAll("[a-zA-Z]", "") + "-build" + code + logger.quiet(cmd + " >>>> versionName = " + versionName) + println("the git versionName is : " + versionName) + return versionName +} + +def getGitCommitDescription() { + +// def cmd = "git rev-parse --short HEAD" + + def cmd = "git log -1 --pretty=format:%cd --date=iso" + + def proc = cmd.execute() + + String cmdResult = proc.text.trim() + + String[] resultArray = cmdResult.replaceAll(":", "-").split() + + String apkName = (resultArray[0] + "-" + resultArray[1]).replaceAll("-", "_") + + println("the apkName is : " + apkName) + + return apkName + +} + + dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' - compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 4ce37d1..0eb2964 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -23,3 +23,84 @@ # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile +##################below is for common android +-keep public class **.R$* { public static final int *; } +-keep public class * extends android.app.Activity +-keep public class * extends android.support.v4.app.Fragment +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.view.View +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep class * implements android.os.Parcelable {public static final android.os.Parcelable$Creator *; } +# 保留自定义控件不能被混淆 +-keep public class * extends android.view.View { + public (android.content.Context); + public (android.content.Context, android.util.AttributeSet); + public (android.content.Context, android.util.AttributeSet, int); + public void set*(***); + *** get* (); +} +# 保留Parcelable序列化的类不能被混淆 +-keep class * implements android.os.Parcelable{ + public static final android.os.Parcelable$Creator *; +} +# 保留Serializable 序列化的类不被混淆 +-keepclassmembers class * implements java.io.Serializable { + static final long serialVersionUID; + private static final java.io.ObjectStreamField[] serialPersistentFields; + !static !transient ; + private void writeObject(java.io.ObjectOutputStream); + private void readObject(java.io.ObjectInputStream); + java.lang.Object writeReplace(); + java.lang.Object readResolve(); +} + +# 对R文件下的所有类及其方法,都不能被混淆 +-keep class .R +-keepclassmembers class **.R$* { + *; +} +# 对于带有回调函数onXXEvent的,不能混淆 +-keepclassmembers class * { + void *(**On*Event); +} +-keepclassmembers class * { + void *(**Callback); +} + +#gson +##---------------Begin: proguard configuration for Gson ---------- +# Gson uses generic type information stored in a class file when working with fields. Proguard +# removes such information by default_no_login, so configure it to keep all of it. +-keepattributes Signature + +# For using GSON @Expose annotation +-keepattributes *Annotation* + +# Gson specific classes +-keep class sun.misc.Unsafe { *; } +#-keep class com.google.gson.stream.** { *; } + +# Application classes that will be serialized/deserialized over Gson +-keep class com.google.gson.examples.android.model.** { *; } + +##---------------End: proguard configuration for Gson ---------- + + +##---------------Begin: proguard configuration for RxJava ---------- +-dontwarn sun.misc.** + +-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { + long producerIndex; + long consumerIndex; +} + +-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { + rx.internal.util.atomic.LinkedQueueNode producerNode; +} + +-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef { + rx.internal.util.atomic.LinkedQueueNode consumerNode; +} +##---------------End: proguard configuration for RxJava ---------- \ No newline at end of file diff --git a/app/src/main/res/layout/activity_test.xml b/app/src/main/res/layout/activity_test.xml index b247d08..c619ac0 100644 --- a/app/src/main/res/layout/activity_test.xml +++ b/app/src/main/res/layout/activity_test.xml @@ -1,9 +1,8 @@ - - + diff --git a/build.gradle b/build.gradle index ffdbb28..333dbf4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.1.4' + ext.kotlin_version = '1.1.3' repositories { jcenter() } diff --git a/gradle.properties b/gradle.properties index aac7c9b..4d14029 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,23 @@ -# Project-wide Gradle settings. - -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. - +## Project-wide Gradle settings. +# # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html - +# # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx1536m - +# Default value: -Xmx1024m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +# # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true +#Wed Aug 16 09:16:26 CST 2017 +systemProp.http.proxyHost=127.0.0.1 +org.gradle.jvmargs=-Xmx1536m +systemProp.http.proxyPort=8087 +KEY_PASSWORD=123456 +KEYSTORE_ALIAS=mymeet +KEYSTORE_PASSWORD=123456 +kotlin.incremental=true +KEYSTORE_FILE=../jks/mymeet.jks \ No newline at end of file diff --git a/jks/mymeet.jks b/jks/mymeet.jks new file mode 100644 index 0000000..ea02cb7 Binary files /dev/null and b/jks/mymeet.jks differ