diff --git a/README.md b/README.md index 36d0c60576..10aae58ba8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # 光环助手Android客户端 +### Sourceset/debug/release +* https://developer.android.com/studio/build/build-variants.html#sourcesets + ### 多渠道打包配置 * 使用[ApkChannelPackage](https://github.com/ltlovezh/ApkChannelPackage)的方案 * 正式打包命令:请使用./gradlew channelPubRelease打包渠道包 diff --git a/app/build.gradle b/app/build.gradle index 6062bd2108..8f8daae4c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,5 @@ apply plugin: 'com.android.application' -apply plugin: 'com.neenbedankt.android-apt' - apply plugin: 'kotlin-android' // kotlin //tinker插件 //apply plugin: 'com.tencent.tinker.patch' @@ -16,9 +14,9 @@ android { targetCompatibility JavaVersion.VERSION_1_7 } - dexOptions { - jumboMode = true - } +// dexOptions { +// jumboMode = true +// } defaultConfig { @@ -107,8 +105,8 @@ android { * 多渠道打包,渠道请参考"channel.txt"文件,所有渠道值均通过java code设置 */ productFlavors { - // public release host - pub { + // publish release host + publish { buildConfigField "String", "API_HOST", "\"${API_HOST}\"" buildConfigField "String", "USER_HOST", "\"${USER_HOST}\"" buildConfigField "String", "COMMENT_HOST", "\"${COMMENT_HOST}\"" @@ -117,8 +115,8 @@ android { buildConfigField "String", "DATA_HOST", "\"${DATA_HOST}\"" buildConfigField "String", "USERSEA_HOST", "\"${USERSEA_HOST}\"" } - // internal dev host - dev { + // internal test dev host + internal { buildConfigField "String", "API_HOST", "\"${DEV_API_HOST}\"" buildConfigField "String", "USER_HOST", "\"${DEV_USER_HOST}\"" buildConfigField "String", "COMMENT_HOST", "\"${DEV_COMMENT_HOST}\"" @@ -143,12 +141,6 @@ channel { apkNameFormat = '${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}' } -apt { - arguments { - eventBusIndex "com.gh.EventBusIndex" - } -} - rebuildChannel { // baseDebugApk = 已有Debug APK // baseReleaseApk = 已有Release APK @@ -159,65 +151,68 @@ rebuildChannel { } dependencies { - debugCompile "com.squareup.leakcanary:leakcanary-android:${leakcanary}" - releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakcanary}" - testCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakcanary}" - -// testCompile test.junit compile fileTree(include: '*.jar', dir: 'libs') - compile libs.supportMultidex - compile libs.supportDesign - compile libs.supportAppCompat - compile libs.supportAnnotation - compile libs.supportPercent - compile libs.supportDesign - compile libs.switchButton + debugCompile "com.squareup.leakcanary:leakcanary-android:${leakcanary}" + debugCompile "com.facebook.stetho:stetho:${stetho}" + debugCompile "com.facebook.stetho:stetho-okhttp3:${stetho}" + debugCompile "com.squareup.okhttp3:logging-interceptor:${okHttp}" - compile libs.systemBarTint + compile "com.android.support:multidex:${multidex}" + compile "com.android.support:design:${androidSupport}" + compile "com.android.support:support-v4:${androidSupport}" + compile "com.android.support:appcompat-v7:${androidSupport}" + compile "com.android.support:support-annotations:${androidSupport}" + compile "com.android.support:percent:${androidSupport}" - compile libs.fresco - compile libs.frescoAnimatedGif + compile "com.kyleduo.switchbutton:library:${switchButton}" + compile "com.readystatesoftware.systembartint:systembartint:${systemBarTint}" - compile libs.okHttp - compile libs.okHttpLogInterceptor + compile "com.facebook.fresco:fresco:${fresco}" + compile "com.facebook.fresco:animated-gif:${fresco}" - compile libs.apkChannelPackage + compile "com.squareup.okhttp3:okhttp:${okHttp}" -// debugCompile libs.stetho -// debugCompile libs.stethoWithOkHttp + compile "com.leon.channel:helper:${apkChannelPackage}" - compile libs.retrofit - compile libs.retrofitWithGson // include gson 2.7 - compile libs.retrofitWithRxJava -// compile libs.gson + compile "com.squareup.retrofit2:retrofit:${retrofit}" + compile "com.squareup.retrofit2:converter-gson:${retrofit}" // include gson 2.7 + compile "com.squareup.retrofit2:adapter-rxjava:${retrofit}" +// compile "com.google.code.gson:gson:${gson}" - compile libs.ormliteAndroid - compile libs.ormliteCore + compile "com.j256.ormlite:ormlite-android:${ormlite}" + compile "com.j256.ormlite:ormlite-core:${ormlite}" - compile libs.butterKnife - apt libs.butterKnifeApt + compile "com.jakewharton:butterknife:${butterKnife}" + annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnife}" - compile libs.rxJava - compile libs.rxAndroid - compile libs.rxBinding - compile libs.zxing - compile libs.zxingAndroid + compile "org.greenrobot:eventbus:${eventbus}" + annotationProcessor "org.greenrobot:eventbus-annotation-processor:${eventbusApt}" - compile libs.swipeLayout - compile(libs.autoScrollViewPager) { + compile "io.reactivex:rxjava:${rxJava}" + compile "io.reactivex:rxandroid:${rxAndroid}" + compile "com.jakewharton.rxbinding:rxbinding:${rxBinding}" + + //TODO update to rx 2.x +// compile "io.reactivex.rxjava2:rxjava:${rxJava2}" +// compile "io.reactivex.rxjava2:rxandroid:${rxAndroid2}" +// compile "com.jakewharton.rxbinding2:rxbinding:${rxBinding2}" + + compile "com.google.zxing:core:${zxing}" + compile "com.google.zxing:android-core:${zxing}" + + compile "com.daimajia.swipelayout:library:${swipeLayout}" + compile("cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:${autoScrollViewPager}") { exclude module: 'support-v4' } // tinker -// provided libs.tinker_anno -// compile libs.tinker_lib + provided "com.tencent.tinker:tinker-android-anno:${tinker}" + compile "com.tencent.tinker:tinker-android-lib:${tinker}" - compile libs.weiboSDK + compile "com.sina.weibo.sdk:core:${weiboSDK}" - compile libs.eventbus - apt libs.eventbusApt compile project(':libraries:LGLibrary') compile project(':libraries:MiPush') compile project(':libraries:MTA') diff --git a/app/src/debug/java/com/gh/gamecenter/Injection.java b/app/src/debug/java/com/gh/gamecenter/Injection.java new file mode 100644 index 0000000000..dc9ebf06c6 --- /dev/null +++ b/app/src/debug/java/com/gh/gamecenter/Injection.java @@ -0,0 +1,40 @@ +package com.gh.gamecenter; + +import android.app.Application; + +import com.facebook.stetho.okhttp3.StethoInterceptor; +import com.squareup.leakcanary.LeakCanary; + +import okhttp3.OkHttpClient; +import okhttp3.logging.HttpLoggingInterceptor; + +/** + * @author CsHeng + * @Date 03/09/2017 + * @Time 4:34 PM + */ + +public class Injection { + + public static boolean appInit(Application application) { + if (LeakCanary.isInAnalyzerProcess(application)) { + // This process is dedicated to LeakCanary for heap analysis. + // You should not init your app in this process. + return false; + } + LeakCanary.install(application); + // Normal app init code... + return true; + } + + public static OkHttpClient.Builder provideRetrofitBuilder() { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); + interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); + builder.addNetworkInterceptor(interceptor); + builder.addNetworkInterceptor(new StethoInterceptor()); + return builder; + } + + +} diff --git a/app/src/main/java/com/gh/base/AppController.java b/app/src/main/java/com/gh/base/AppController.java index 31cecf79d1..71d98a493f 100644 --- a/app/src/main/java/com/gh/base/AppController.java +++ b/app/src/main/java/com/gh/base/AppController.java @@ -16,10 +16,10 @@ import com.gh.common.util.DataUtils; import com.gh.common.util.StringUtils; import com.gh.common.util.TokenUtils; import com.gh.gamecenter.BuildConfig; +import com.gh.gamecenter.Injection; import com.leon.channel.helper.ChannelReaderUtil; import com.lightgame.config.CommonDebug; import com.lightgame.utils.Utils; -import com.squareup.leakcanary.LeakCanary; import com.umeng.message.IUmengRegisterCallback; import com.umeng.message.PushAgent; import com.umeng.message.UTrack; @@ -83,22 +83,12 @@ public class AppController extends MultiDexApplication { public void onCreate() { super.onCreate(); - if (LeakCanary.isInAnalyzerProcess(this)) { - // This process is dedicated to LeakCanary for heap analysis. - // You should not init your app in this process. + if (!Injection.appInit(this)) { return; } - LeakCanary.install(this); - // Normal app init code... mInstance = this; - //TODO 强烈不建议开发阶段开启这个Handler,必须处理错误 - if (!BuildConfig.DEBUG) { - AppUncaughtHandler appUncaughtHandler = new AppUncaughtHandler(this); - Thread.setDefaultUncaughtExceptionHandler(appUncaughtHandler); - } - mChannel = ChannelReaderUtil.getChannel(this); if (TextUtils.isEmpty(mChannel)) { //默认用Android Studio run时并没有写入channel magic number到apk包里面,所以需要fallback @@ -216,7 +206,7 @@ public class AppController extends MultiDexApplication { EventBus.builder().addIndex(new EventBusIndex()).installDefaultEventBus(); // AppTrafficUtils.appTraffic(this); //流量统计 - } + } private boolean shouldInit() { ActivityManager am = ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE)); diff --git a/app/src/main/java/com/gh/gamecenter/entity/GameEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/GameEntity.kt index b3ae7ca415..2c0d97b577 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/GameEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/GameEntity.kt @@ -79,9 +79,9 @@ class GameEntity : Parcelable { } fun setEntryMap(entryMap: ArrayMap?) { - if (AppDebugConfig.IS_DEBUG) { - AppDebugConfig.logMethodWithParams(this, entryMap) - } +// if (AppDebugConfig.IS_DEBUG) { +// AppDebugConfig.logMethodWithParams(this, entryMap) +// } if (entryMap != null) { this.entryMap = entryMap } diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/RetrofitManager.java b/app/src/main/java/com/gh/gamecenter/retrofit/RetrofitManager.java index 6a77be9e67..7b869219a5 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/RetrofitManager.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/RetrofitManager.java @@ -4,16 +4,13 @@ import android.content.Context; import com.gh.base.AppController; import com.gh.common.constant.Config; -import com.gh.gamecenter.BuildConfig; +import com.gh.gamecenter.Injection; import java.io.File; import java.util.concurrent.TimeUnit; import okhttp3.Cache; import okhttp3.OkHttpClient; -import okhttp3.OkHttpClient.Builder; -import okhttp3.logging.HttpLoggingInterceptor; -import okhttp3.logging.HttpLoggingInterceptor.Level; import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; @@ -33,88 +30,37 @@ public class RetrofitManager { private LibaoService mLibaoService; private MessageService mMessageService; private UserseaService mUserseaService; - private Context mContext; + + public static T provideService(OkHttpClient client, String url, Class serviceCls) { + return new Retrofit.Builder() + .client(client) + .addConverterFactory(GsonConverterFactory.create()) + .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) + .baseUrl(url).build().create(serviceCls); + } private RetrofitManager() { - mContext = AppController.getInstance().getApplicationContext(); - final Cache cache = new Cache(new File(OkHttpCache.getCachePath(mContext)), 10 * 1024 * 1024); // 10Mb + final Context context = AppController.getInstance().getApplicationContext(); - final Builder builder = new OkHttpClient.Builder(); - if (BuildConfig.DEBUG) { - HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); - interceptor.setLevel(Level.BASIC); - builder.addNetworkInterceptor(interceptor); -// builder.addNetworkInterceptor(new StethoInterceptor()); - } + final Cache cache = new Cache(new File(OkHttpCache.getCachePath(context)), 10 * 1024 * 1024); // 10Mb - final OkHttpClient okHttpClient = builder - .addInterceptor(new OkHttpCacheInterceptor(mContext)) - .addInterceptor(new OkHttpRetryInterceptor(mContext)) - .addNetworkInterceptor(new OkHttpNetworkInterceptor(mContext)) + final OkHttpClient okHttpClient = Injection.provideRetrofitBuilder() + .addInterceptor(new OkHttpCacheInterceptor(context)) + .addInterceptor(new OkHttpRetryInterceptor(context)) + .addNetworkInterceptor(new OkHttpNetworkInterceptor(context)) .connectTimeout(8, TimeUnit.SECONDS) .cache(cache) .build(); - mApiService = new Retrofit.Builder() - .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) - .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) - .baseUrl(Config.API_HOST) - .build() - .create(ApiService.class); + mApiService = provideService(okHttpClient, Config.API_HOST, ApiService.class); + mDataService = provideService(okHttpClient, Config.DATA_HOST, DataService.class); + mCommentService = provideService(okHttpClient, Config.COMMENT_HOST, CommentService.class); + mUserService = provideService(okHttpClient, Config.USER_HOST, UserService.class); + mLibaoService = provideService(okHttpClient, Config.LIBAO_HOST, LibaoService.class); + mMessageService = provideService(okHttpClient, Config.MESSAGE_HOST, MessageService.class); + mUserseaService = provideService(okHttpClient, Config.USERSEA_HOST, UserseaService.class); - mDataService = new Retrofit.Builder() - .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) - .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) - .baseUrl(Config.DATA_HOST) - .build() - .create(DataService.class); - - mCommentService = new Retrofit.Builder() - .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) - .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) - .baseUrl(Config.COMMENT_HOST) - .build() - .create(CommentService.class); - - mUserService = new Retrofit.Builder() - .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) - .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) - .baseUrl(Config.USER_HOST) - .build() - .create(UserService.class); - - mLibaoService = new Retrofit.Builder() - .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) - .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) - .baseUrl(Config.LIBAO_HOST) - .build() - .create(LibaoService.class); - - mMessageService = new Retrofit.Builder() - .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) - .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) - .baseUrl(Config.MESSAGE_HOST) - .build() - .create(MessageService.class); - - mUserseaService = new Retrofit.Builder() - .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) - .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) - .baseUrl(Config.USERSEA_HOST) - .build() - .create(UserseaService.class); - } - - public static ApiService getApi() { - return getInstance().mApiService; } public static RetrofitManager getInstance() { @@ -128,6 +74,10 @@ public class RetrofitManager { return sInstance; } + public static ApiService getApi() { + return getInstance().mApiService; + } + public static DataService getData() { return getInstance().mDataService; } diff --git a/app/src/release/java/com/gh/gamecenter/Injection.java b/app/src/release/java/com/gh/gamecenter/Injection.java new file mode 100644 index 0000000000..88372a8c6c --- /dev/null +++ b/app/src/release/java/com/gh/gamecenter/Injection.java @@ -0,0 +1,28 @@ +package com.gh.gamecenter; + +import android.app.Application; + +import com.gh.base.AppUncaughtHandler; + +import okhttp3.OkHttpClient; + +/** + * @author CsHeng + * @Date 03/09/2017 + * @Time 4:34 PM + */ + +public class Injection { + + public static boolean appInit(Application application) { + AppUncaughtHandler appUncaughtHandler = new AppUncaughtHandler(application); + Thread.setDefaultUncaughtExceptionHandler(appUncaughtHandler); + return true; + } + + public static OkHttpClient.Builder provideRetrofitBuilder() { + return new OkHttpClient.Builder(); + } + + +} diff --git a/build.gradle b/build.gradle index aec0c0aeaa..b49015845b 100644 --- a/build.gradle +++ b/build.gradle @@ -3,20 +3,20 @@ apply from: 'dependencies.gradle' buildscript { - ext.kotlin_version = '1.1.3-2' + ext.kotlin_version = '1.1.4-3' repositories { - jcenter() + maven { url "https://maven.google.com" } maven { url "https://dl.bintray.com/thelasterstar/maven/" } //weiboSDK + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' - // for ndk-build experimental -// classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha5' - classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' + classpath "com.android.tools.build:gradle:2.3.3" + classpath "com.neenbedankt.gradle.plugins:android-apt:1.8" // for tinker - classpath 'com.tencent.tinker:tinker-patch-gradle-plugin:1.7.9' +// classpath 'com.tencent.tinker:tinker-patch-gradle-plugin:1.7.9' // for apkChannelPackage https://github.com/ltlovezh/ApkChannelPackage - classpath 'com.leon.channel:plugin:1.0.4' + classpath "com.leon.channel:plugin:1.0.5" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } @@ -24,8 +24,10 @@ buildscript { allprojects { repositories { - jcenter() + maven { url "https://maven.google.com" } maven { url "https://dl.bintray.com/thelasterstar/maven/" }//weiboSDK + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + jcenter() } } diff --git a/dependencies.gradle b/dependencies.gradle index 9d367f398b..83cf0ba5d2 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,34 +1,25 @@ -allprojects { - repositories { - jcenter() - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } - } -} - ext { //Android - buildToolsVersion = "25.0.0" - compileSdkVersion = 23 + buildToolsVersion = "26.0.1" + compileSdkVersion = 26 minSdkVersion = 14 - // target 23 will cause permission issues - targetSdkVersion = 21 + // TODO fix permission/ target 23 will cause permission issues + targetSdkVersion = 22 // application info versionCode = 21 versionName = "2.6" applicationId = "com.gh.gamecenter" -// compile 'com.google.dagger:dagger:2.0.2' // dagger2 -// compile 'com.google.dagger:dagger-compiler:2.0.2' // dagger2 - javaxAnnotation = '10.0-b28' - //Libraries - androidSupport = "24.1.0" - supportDesign = "24.1.0" + androidSupport = "26.0.2" multidex = "1.0.1" + butterKnife = "8.4.0" + eventbus = "3.0.0" eventbusApt = "3.0.1" + // rxJava & rxAndroid rxJava = "1.1.0" rxAndroid = "1.1.0" @@ -49,14 +40,9 @@ ext { switchButton = "1.4.5" facebook = "[4,5)" flurry = "6.3.0" - debug = "2.0.1" swipeLayout = "1.2.0@aar" autoScrollViewPager = "1.1.2" - circleImageView = "2.1.0" - weiboSDK = "2.0.3" - - onesignal = "2.3.0@aar" - google_play_services = "8.4.0" + weiboSDK = "2.0.3:openDefaultRelease@aar" tinker = "1.7.9" apkChannelPackage = "1.0.4" @@ -67,67 +53,6 @@ ext { leakcanary = '1.5.1' - libs = [ - supportV4 : "com.android.support:support-v4:${androidSupport}", - supportAppCompat : "com.android.support:appcompat-v7:${androidSupport}", - supportRecyclerView : "com.android.support:recyclerview-v7:${androidSupport}", - supportCardView : "com.android.support:cardview-v7:${androidSupport}", - supportDesign : "com.android.support:design:${androidSupport}", - supportAnnotation : "com.android.support:support-annotations:${androidSupport}", - supportPercent : "com.android.support:percent:${androidSupport}", - supportMultidex : "com.android.support:multidex:${multidex}", - rxJava : "io.reactivex:rxjava:${rxJava}", - rxAndroid : "io.reactivex:rxandroid:${rxAndroid}", - rxJava2 : "io.reactivex.rxjava2:rxjava:${rxJava2}", - rxAndroid2 : "io.reactivex.rxjava2:rxandroid:${rxAndroid2}", - rxLifecycle : "com.trello.rxlifecycle2:rxlifecycle:${rxLifecycle}", - rxLifecycleAndroid : "com.trello.rxlifecycle2:rxlifecycle-android:${rxLifecycle}", - rxLifecycleComponent : "com.trello.rxlifecycle2:rxlifecycle-components:${rxLifecycle}", - rxBinding : "com.jakewharton.rxbinding:rxbinding:${rxBinding}", - rxBinding2 : "com.jakewharton.rxbinding2:rxbinding:${rxBinding2}", - rxBindingDesign2 : "com.jakewharton.rxbinding2:rxbinding-design:${rxBinding2}", - rxBindingRecyclerView2 : "com.jakewharton.rxbinding2:rxbinding-recyclerview:${rxBinding2}", - rxBindingSupportV42 : "com.jakewharton.rxbinding2:rxbinding-support-v4:${rxBinding2}", - rxBindingSupportV72 : "com.jakewharton.rxbinding2:rxbinding-appcompat-v7:${rxBinding2}", - eventbus : "org.greenrobot:eventbus:${eventbus}", - eventbusApt : "org.greenrobot:eventbus-annotation-processor:${eventbusApt}", - butterKnife : "com.jakewharton:butterknife:${butterKnife}", - butterKnifeApt : "com.jakewharton:butterknife-compiler:${butterKnife}", - ormliteAndroid : "com.j256.ormlite:ormlite-android:${ormlite}", - ormliteCore : "com.j256.ormlite:ormlite-core:${ormlite}", - javaxAnnotation : "org.glassfish:javax.annotation:${javaxAnnotation}", - retrofit : "com.squareup.retrofit2:retrofit:${retrofit}", - retrofitWithGson : "com.squareup.retrofit2:converter-gson:${retrofit}", - retrofitWithRxJava : "com.squareup.retrofit2:adapter-rxjava:${retrofit}", - okHttp : "com.squareup.okhttp3:okhttp:${okHttp}", - okHttpLogInterceptor : "com.squareup.okhttp3:logging-interceptor:${okHttp}", - gson : "com.google.code.gson:gson:${gson}", - zxing : "com.google.zxing:core:${zxing}", - zxingAndroid : "com.google.zxing:android-core:${zxing}", - fresco : "com.facebook.fresco:fresco:${fresco}", - frescoAnimatedGif : "com.facebook.fresco:animated-gif:${fresco}", - systemBarTint : "com.readystatesoftware.systembartint:systembartint:${systemBarTint}", - switchButton : "com.kyleduo.switchbutton:library:${switchButton}", - facebook : "com.facebook.android:facebook-android-sdk:${facebook}", - flurry : "com.flurry.android:analytics:${flurry}", - debug : "ru.noties:debug:${debug}", - stetho : "com.facebook.stetho:stetho:${stetho}", - stethoWithOkHttp : "com.facebook.stetho:stetho-okhttp3:${stetho}", - swipeLayout : "com.daimajia.swipelayout:library:${swipeLayout}", - autoScrollViewPager : "cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:${autoScrollViewPager}", - circleImageView : "de.hdodenhof:circleimageview:${circleImageView}", - onesignal : "com.onesignal:OneSignal:${onesignal}", - google_message : "com.google.android.gms:play-services-gcm:${google_play_services}", - google_analytics : "com.google.android.gms:play-services-analytics:${google_play_services}", - google_location : "com.google.android.gms:play-services-location:${google_play_services}", - tinker_anno : "com.tencent.tinker:tinker-android-anno:${tinker}", - tinker_lib : "com.tencent.tinker:tinker-android-lib:${tinker}", - apkChannelPackage : "com.leon.channel:helper:${apkChannelPackage}", - weiboSDK : "com.sina.weibo.sdk:core:${weiboSDK}:openDefaultRelease@aar", - ] + crashlytics = '2.6.8@aar' - - test = [ - junit : "junit:junit:${jUnit}", - ] } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 1b0ce43730..0be0c7714b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,9 +15,6 @@ #Wed Jul 19 10:16:09 CST 2017 org.gradle.jvmargs=-Xmx2048m -XX\:MaxPermSize\=512m -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8 org.gradle.parallel=true -systemProp.http.proxyHost=127.0.0.1 -systemProp.http.proxyPort=8888 -android.useDeprecatedNdk=true # channel packages channel_file=channel.txt diff --git a/libraries/iosched/build.gradle b/libraries/iosched/build.gradle index 66ab96aacd..363dc8803c 100644 --- a/libraries/iosched/build.gradle +++ b/libraries/iosched/build.gradle @@ -2,9 +2,9 @@ apply plugin: 'com.android.library' dependencies { compile fileTree(dir: 'libs', exclude: 'android-support-*.jar', include: '*.jar') - compile libs.supportV4 - compile libs.supportAppCompat - compile libs.supportRecyclerView + compile "com.android.support:support-v4:${androidSupport}" + compile "com.android.support:appcompat-v7:${androidSupport}" + compile "com.android.support:recyclerview-v7:${androidSupport}" } android { diff --git a/scripts/compile2luac.gradle b/scripts/compile2luac.gradle deleted file mode 100644 index 736207f6d2..0000000000 --- a/scripts/compile2luac.gradle +++ /dev/null @@ -1,119 +0,0 @@ -import groovy.json.JsonSlurper -import org.apache.tools.ant.taskdefs.condition.Os - -def assetsDir = new File(projectDir, '../chhota-bheem-res/win32/') - -// read cocos studio build-cfg file -def config = null; -File f = file('build-cfg.json') -if (f.exists()) { - config = f.withReader { r -> - new JsonSlurper().parse(r) - } -} - -print(f) -print(config) - -// get local.properties and set -File propFile = new File('../local.properties'); -if (propFile.exists()) { - def Properties props = new Properties() - props.load(new FileInputStream(propFile)) - - print(props.get("COCOS_FRAMEWORKS")) - print(properties) - - properties.put('COCOS_FRAMEWORKS', props.get('COCOS_FRAMEWORKS')) -} - -// get and define ndk_module_path -String ndkModulePath = null; -String cocos_framework = properties.getProperty('COCOS_FRAMEWORKS') -def config_ndk_modules = config.ndk_module_path -//COCOS_FRAMEWORKS = cocos_framework -for (String path : config_ndk_modules) { - String module_path = path.replace('${COCOS_FRAMEWORKS}', cocos_framework) - if (ndkModulePath == null) { - ndkModulePath = module_path - } else { - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - ndkModulePath += ";" + new File(module_path).absolutePath - } else { - ndkModulePath += ":" + new File(module_path).absolutePath - } - } -} - -// copy resources defined by build-cfg.json, ref:${COCOS_FRAMEWORKS}/cocos2dx-3.9/tools/cocos2d-console/plugins/xxx} -task copyResources << { - // copy assets - config.copy_resources.each { res -> - copy { - from new File(projectDir, res.from.toString()).absolutePath - into new File(assetsDir, res.to.toString()).absolutePath - } -// println('from ' + new File(projectDir, res.from.toString()).absolutePath) -// println('to ' + new File(projectDir, assetsDir + File.separator + res.to.toString()).absolutePath) - } - - // copy config - config.must_copy_resources.each { cfg -> - copy { - from new File(projectDir, cfg.from.toString()).absolutePath - into new File(assetsDir, cfg.to.toString()).absolutePath - include '*' - exclude '' - } -// println('from ' + new File(projectDir, cfg.from.toString()).absolutePath) -// println('to ' + new File(projectDir, assetsDir + File.separator + cfg.to.toString()).absolutePath) - } -} - -task cleanResources << { - config.copy_resources.each { res -> - delete fileTree(new File(assetsDir, res.to.toString())) { - include '**/*' - } - } - - config.must_copy_resources.each { cfg -> - delete fileTree(new File(assetsDir, cfg.to.toString())) { - include '**/*' - } - } -} - -// delete *.lua -task deleteLuaSource << { - String lua_dir_src = new File(assetsDir, 'src').toString() - delete fileTree(lua_dir_src) { - include '**/*.lua' - exclude '**/*.luac' - } -} - -// compile lua src to assets/src -task buildLua(type: Exec, description: 'Compile lua via cocos command line tool') { - // read cocos studio cocos-project file - File jf = new File(rootProject.projectDir, '.cocos-project.json') - def jCfg = jf.withReader { r -> - new JsonSlurper().parse(r) - } - String engineVer = jCfg.engine_version - String cocos_cmd_path = cocos_framework + File.separator + engineVer + File.separator + 'tools' + File.separator \ - + 'cocos2d-console' + File.separator + 'bin' + File.separator + 'cocos' - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - cocos_cmd_path = cocos_cmd_path + '.bat' - } - - String lua_dir_src = new File(rootProject.projectDir, 'src').toString() - String lua_dir_dst = new File(assetsDir, 'src').toString() - commandLine "$cocos_cmd_path", 'luacompile', '-s', lua_dir_src, '-d', lua_dir_dst - doFirst { - copyResources.execute() - } - doLast { - deleteLuaSource.execute() - } -} \ No newline at end of file diff --git a/scripts/compress_resources.sh b/scripts/compress_resources.sh deleted file mode 100755 index 60a349a2ac..0000000000 --- a/scripts/compress_resources.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# ***************************************************************************** -# @author CsHeng -# @2016.2.17 初始pngquant版本 -# @2016.3.8 增加对音频的处理 -# -# 使用pngquant对图片素材进行压缩,压缩后gradle脚本copyResource会将../res目录copy到目的地 -# 使用lame处理mp3 -# 由于pngquant/lame是需要系统额外安装的,故不将此命令写入gradle脚本 -# Sample: brew install ImageMagick lame -# -# 选项: -# -s src dir of images, default ../res -# -# ***************************************************************************** - -CWD=$(cd "$(dirname "$0")"; pwd) -INPUT="${CWD}/../res" -while getopts "s:0:" arg -do - case ${arg} in - s) - INPUT=${OPTARG} - ;; - ?) - echo "unknown argument" - exit 1; - ;; - esac -done - -#find ${INPUT} -name '*.png' -exec bash -c 'echo $0 -f -o $0 & pngquant $0 -f -o $0' {} \; - -# compress pngs to 8bit color, keep alpha channel -images=$(find ${INPUT} -name '*.png') -for f in ${images} -do - echo pngquant ${f} -f -o ${f} - pngquant ${f} -f -o ${f} -done - -# convert mp3 to 64bit/44100KHz, normal is 96-128bit/44100KHz, --resample 22050 don't help -mp3s=$(find ${INPUT} -name '*.mp3') -for f in ${mp3s} -do - echo "mv ${f} ${f}.bak & lame --mp3input -b 64 ${f}.bak ${f} & rm ${f}.bak" - mv ${f} ${f}.bak - lame --mp3input -b 64 ${f}.bak ${f} - rm ${f}.bak -done diff --git a/scripts/dothestuff.sh b/scripts/dothestuff.sh deleted file mode 100755 index 8410dd4e68..0000000000 --- a/scripts/dothestuff.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!bin/bash -# replace file content 4566.com with 4566.com -find . -type f -exec sed -i 's/4399\.com/4566\.com/g' {} \; -# replace file content 4566.json with 4566.json -find . -type f -exec sed -i 's/4399\.json/4566\.json/g' {} \; -# replace file name 4566.json with 4566.json -find . -name '4399\.json' -exec bash -c 'mv $0 ${0/4399/4566}' {} \; -# add script relocation after tag -find . -name *.html -exec sed '//r relocation.txt' {} \; -# replace a10.com -find . -type f -exec sed -i 's/www\.a10\.com/www\.4566\.com/g' {} \; -# replace directories with 4399 -find . -name '*4399' -exec bash -c 'mv $0 ${0/4399/4566}' {} \; -# replace directories path with 4399 -find . -type f -exec sed -i 's/\.\/4399/\.\/4566/g' {} \; diff --git a/scripts/make_luacompile.bat b/scripts/make_luacompile.bat deleted file mode 100644 index 125f5b9998..0000000000 --- a/scripts/make_luacompile.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -cocos luacompile -s %~dp0..\src\ -d %~dp0..\src_out\ diff --git a/scripts/packDebugChannel.sh b/scripts/packDebugChannel.sh deleted file mode 100755 index 01d1b44fdc..0000000000 --- a/scripts/packDebugChannel.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/bin/bash - -SOURCE= -OUTPUTDIR= -CHNNAMES= -NAME= -VERSION= -EXTENSION= -METADIR= -#修改数量限制 -MAX_APPDEBUGCONFIG=1 -MAX_VOLLEYLOG=1 -MAX_DEBUG_VIEW=1 -MAX_DEBUG_SDK=20 -MAX_DEBUG_SDK_LOG=2 - -replaceSwitch() -{ -#*****************************************************************************# -#*******************************AppDebugConfig.java***************************# -#*****************************************************************************# -effect_AppDebugConfig=$( sed -n '/true/p' app/src/com/oplay/android/config/AppDebugConfig.java | wc -l ) -echo AppDebugConfig: effects ${effect_AppDebugConfig} lines. -if [ ${effect_AppDebugConfig} -le ${MAX_APPDEBUGCONFIG} ]; then - sed -i 's/true/false/g' app/src/com/oplay/android/config/AppDebugConfig.java - echo AppDebugConfig ....................................... OK -else - echo "AppDebugConfig ...................................... FAILED" -fi - -#*****************************************************************************# -#*******************************VolleyLog.java********************************# -#*****************************************************************************# -effect_VolleyLog=$( sed -n '/DEBUG \?= \?true/p' libraries/Android-Volley/src/com/android/volley/VolleyLog.java | wc -l ) -echo VolleyLog: effects ${effect_VolleyLog} lines. -if [ ${effect_VolleyLog} -le ${MAX_VOLLEYLOG} ]; then - sed -i 's/DEBUG \?= \?true/DEBUG = false/g' libraries/Android-Volley/src/com/android/volley/VolleyLog.java - echo VolleyLog ....................................... OK -else - echo "VolleyLog ...................................... FAILED" -fi -#*****************************************************************************# -#*******************************DebugView.java********************************# -#*****************************************************************************# -effect_Debug_View=$( sed -n '/true/p' libraries/YoumiUI/src/net/android/common/config/Debug_View.java | wc -l) -echo Debug_View: effects ${effect_Debug_View} lines. -if [ ${effect_VolleyLog} -le ${MAX_VOLLEYLOG} ]; then - sed -i 's/true/false/g' libraries/YoumiUI/src/net/android/common/config/Debug_View.java - echo Debug_View ....................................... OK -else - echo "Debug_View ...................................... FAILED" -fi -#*****************************************************************************# -#*******************************Debug_SDK.java********************************# -#*****************************************************************************# -effect_Debug_SDK=$( sed -n '/true/p' libraries/YoumiLibs/src/net/youmi/android/libs/common/debug/Debug_SDK.java | wc -l) -echo Debug_SDK: effects ${effect_Debug_SDK} lines. -if [ ${effect_VolleyLog} -le ${MAX_VOLLEYLOG} ]; then - sed -i 's/true/false/g' libraries/YoumiLibs/src/net/youmi/android/libs/common/debug/Debug_SDK.java - echo Debug_SDK ....................................... OK -else - echo "Debug_SDK ...................................... FAILED" -fi - -#*****************************************************************************# -#*******************************Debug_SDK_Log.java****************************# -#*****************************************************************************# -effect_Debug_SDK_Log=$( sed -n '/= \?true/p' libraries/YoumiLibs/src/net/youmi/android/libs/common/debug/Debug_SDK_Log.java | wc -l) -echo Debug_SDK_Log: effects ${effect_Debug_SDK_Log} lines. -if [ ${effect_VolleyLog} -le ${MAX_VOLLEYLOG} ]; then - sed -i 's/= \?true/= false/g' libraries/YoumiLibs/src/net/youmi/android/libs/common/debug/Debug_SDK_Log.java - echo Debug_SDK_Log ....................................... OK -else - echo "Debug_SDK_Log ...................................... FAILED" -fi -} - -replaceSwitch - -CWD=$(dirname $(readlink -f $0)) -${CWD}/../gradlew clean assembleRelease -x lint --parallel - -[ -z ${SOURCE} ] && SOURCE=${CWD}/../app/build/outputs/apk/app-release.apk -cp ${SOURCE} ~/ - -#setDefaultVar() -#{ -# # default arguments for channel 0 -# [ -z ${VERSION} ] && VERSION=4.2.0 -# [ -z ${NAME} ] && NAME=ouwan -## 内部测试默认渠道号 -# [ -z ${CHNNAMES} ] && CHNNAMES=400 -# # get current shell absolute dir -# CWD=$(dirname $(readlink -f $0)) -# [ -z ${SOURCE} ] && SOURCE=${CWD}/../app/build/outputs/apk/app-release.apk -# [ -z ${OUTPUTDIR} ] && OUTPUTDIR=${CWD}/.. -# [ -z ${EXTENSION} ] && EXTENSION=.ouwan -# [ -z ${METADIR} ] && METADIR=META-INF -#} -# -#while getopts :s:o:c:n:v:e: OPTION -#do -# case ${OPTION} in -# s) -# SOURCE=$OPTARG -# ;; -# o) -# OUTPUTDIR=$OPTARG -# ;; -# c) -# CHNNAMES=$OPTARG -# ;; -# n) -# NAME=$OPTARG -# ;; -# v) -# VERSION=$OPTARG -# ;; -# e) -# EXTENSION=$OPTARG -# ;; -# \?) -# printUsage -# ;; -# esac -#done - - -#setDefaultVar - - -#mkdir -p ${METADIR} -#mkdir -p ${OUTPUTDIR} -# -## spilt $CHNNAMES to array -#IFS=',' read -ra CHNARRAY <<< ${CHNNAMES} -# -#for i in ${CHNARRAY[@]} -#do -# DESTAPK=${OUTPUTDIR}/${NAME}_${VERSION}_${i}.apk -# CHNFILE=${METADIR}/$(echo ${i} | base64)${EXTENSION} -# touch ${CHNFILE} -# cp ${SOURCE} ${DESTAPK} -# echo Compressed ${CHNFILE} to ${DESTAPK} -# zip -q -m ${DESTAPK} ${CHNFILE} -#done -#rm -r ${METADIR} \ No newline at end of file diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000000..ab91c36afa --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# ***************************************************************************** +# @author CsHeng +# @2017.9.3 init +# +# 处理打包事务 +# +# +# ***************************************************************************** + +CWD=$(cd "$(dirname "$0")"; pwd) + +${CWD}/../gradlew clean channelPublishRelease -x lint --parallel \ No newline at end of file