Skip to content

Commit 564df67

Browse files
committed
更新gradle版本,更新渠道打包插件为walle
1 parent 76bdd9e commit 564df67

16 files changed

+318
-148
lines changed

app/build.gradle

Lines changed: 66 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'com.jakewharton.butterknife'
3+
apply plugin: 'walle'
34

45
// 加载配置文件
56
final Properties properties = new Properties()
@@ -59,11 +60,7 @@ android {
5960
buildConfigField 'String', 'WEIBO_APP_SECRET', '"' + weiboAppSecret + '"'
6061
buildConfigField 'String', 'QQ_APP_ID', '"' + qqAppId + '"'
6162
buildConfigField 'String', 'QQ_APP_SECRET', '"' + qqAppSecret + '"'
62-
63-
64-
manifestPlaceholders = [
65-
UMENG_APPKEY: umengAppKey
66-
]
63+
buildConfigField 'String', 'UMENG_APPKEY', '"' + umengAppKey + '"'
6764

6865
ndk {
6966
// fix bug #504 64位系统webView问题
@@ -77,83 +74,91 @@ android {
7774
minifyEnabled false
7875
debuggable true
7976
// applicationIdSuffix '.debug'
80-
manifestPlaceholders = [
81-
UMENG_CHANNEL: 'DEV'
82-
]
77+
// manifestPlaceholders = [
78+
// UMENG_CHANNEL: 'DEV'
79+
// ]
8380
signingConfig signingConfigs.release
8481
}
8582
release {
8683
minifyEnabled false
8784
signingConfig signingConfigs.release
8885
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
8986
}
90-
beta {
91-
initWith release
92-
versionNameSuffix rootProject.hasProperty("buildNum") ? '.' + rootProject.property("buildNum") + '_beta' : ''
93-
}
9487
}
9588
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
9689

97-
// 渠道包定义,默认定义的名称就是渠道名称
98-
productFlavors {
99-
Dev {} // 测试
100-
// baidu {} // 百度手机助手
101-
yinyongbao {} // 应用宝
102-
// m360 {} // 360手机助手
103-
pp {} // PP助手
104-
meizu {} // 魅族
105-
xiaomi {} // 小米商店
106-
huawei {} // 华为商店
107-
official {} // 官方版本
108-
fir{} // fir内测平台版本
109-
}
90+
// // 渠道包定义,默认定义的名称就是渠道名称
91+
// productFlavors {
92+
// Dev {} // 测试
93+
//// baidu {} // 百度手机助手
94+
// yinyongbao {} // 应用宝
95+
//// m360 {} // 360手机助手
96+
// pp {} // PP助手
97+
// meizu {} // 魅族
98+
// xiaomi {} // 小米商店
99+
// huawei {} // 华为商店
100+
// official {} // 官方版本
101+
// fir{} // fir内测平台版本
102+
// }
103+
//
104+
// // 批量渠道包值替换
105+
// productFlavors.all { flavor ->
106+
// flavor.manifestPlaceholders = [UMENG_CHANNEL: name, BUGLY_CHANNEL: name]
107+
// }
110108

111-
// 批量渠道包值替换
112-
productFlavors.all { flavor ->
113-
flavor.manifestPlaceholders = [UMENG_CHANNEL: name, BUGLY_CHANNEL: name]
114-
}
109+
}
115110

111+
walle {
112+
// 指定渠道包的输出路径
113+
apkOutputFolder = new File("${project.buildDir}/outputs/channels")
114+
// 定制渠道包的APK的文件名称
115+
apkFileNameFormat = '${appName}-${buildType}-v${versionName}-${channel}.apk'
116+
// 渠道配置文件
117+
// channelFile = new File("${project.getProjectDir()}/config.json")
118+
configFile = new File("${project.getProjectDir()}/config.json")
116119
}
117120

118121
dependencies {
119-
compile fileTree(include: ['*.jar'], dir: 'libs')
120-
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
122+
implementation fileTree(dir: 'libs', include: ['*.jar'])
123+
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
121124
exclude group: 'com.android.support', module: 'support-annotations'
122125
})
123-
testCompile 'junit:junit:4.12'
124-
compile "com.android.support:appcompat-v7:${rootProject.ext.supportVersion}"
125-
compile "com.android.support:design:${rootProject.ext.supportVersion}"
126-
compile "com.android.support:cardview-v7:${rootProject.ext.supportVersion}"
127-
compile 'com.android.support:multidex:1.0.1'
128-
debugCompile project(path: ':sdk', configuration: 'debug')
129-
betaCompile project(path: ':sdk', configuration: 'release')
130-
releaseCompile project(path: ':sdk', configuration: 'release')
131-
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
132-
compile 'com.jakewharton:butterknife:8.8.1'
133-
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
134-
compile 'in.srain.cube:ultra-ptr:1.0.11'
135-
compile 'com.github.raee:XRecyclerView:1.3.3'
136-
compile 'com.makeramen:roundedimageview:2.3.0'
137-
compile 'com.github.bumptech.glide:glide:4.0.0'
126+
testImplementation 'junit:junit:4.12'
127+
implementation 'com.android.support:multidex:1.0.2'
128+
129+
implementation project(':sdk')
130+
131+
annotationProcessor rootProject.ext.butterknifeCompiler
132+
implementation rootProject.ext.appcompat
133+
implementation rootProject.ext.design
134+
implementation rootProject.ext.cardview
135+
implementation rootProject.ext.butterknife
136+
implementation rootProject.ext.rxjava
137+
138+
implementation 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
139+
implementation 'in.srain.cube:ultra-ptr:1.0.11'
140+
implementation 'com.github.raee:XRecyclerView:1.3.3'
141+
implementation 'com.makeramen:roundedimageview:2.3.0'
142+
implementation 'com.github.bumptech.glide:glide:4.0.0'
138143
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
139-
compile 'com.umeng.analytics:analytics:6.1.3'
140-
compile 'org.greenrobot:eventbus:3.0.0'
141-
compile 'me.imid.swipebacklayout.lib:library:1.0.0'
142-
compile 'com.github.chrisbanes:PhotoView:2.1.2'
143-
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
144-
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
145-
compile 'com.tencent.bugly:crashreport_upgrade:1.3.3'
146-
compile 'eu.davidea:flexible-adapter:5.0.0-rc2'
144+
implementation 'com.umeng.analytics:analytics:6.1.3'
145+
implementation 'org.greenrobot:eventbus:3.1.1'
146+
implementation 'me.imid.swipebacklayout.lib:library:1.1.0'
147+
implementation 'com.github.chrisbanes:PhotoView:2.1.2'
148+
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.1'
149+
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
150+
151+
implementation 'eu.davidea:flexible-adapter:5.0.0-rc2'
147152
// LeanCloud 基础包
148-
compile 'cn.leancloud.android:avoscloud-sdk:v4.4.3'
153+
implementation 'cn.leancloud.android:avoscloud-sdk:v4.4.3'
149154
// LeanCloud 用户反馈包
150-
compile 'cn.leancloud.android:avoscloud-feedback:v4.4.3@aar'
151-
compile 'io.reactivex.rxjava2:rxjava:2.1.0'
155+
implementation 'cn.leancloud.android:avoscloud-feedback:v4.4.3@aar'
152156
// 主题切换
153-
compile 'skin.support:skin-support:2.1.2'
154-
compile 'skin.support:skin-support-design:1.2.5'
155-
compile 'com.kyleduo.switchbutton:library:1.4.6'
156-
compile 'com.google.code.gson:gson:2.8.0'
157+
implementation 'skin.support:skin-support:2.1.2'
158+
implementation 'skin.support:skin-support-design:1.2.5'
159+
implementation 'com.kyleduo.switchbutton:library:1.4.6'
160+
implementation 'com.google.code.gson:gson:2.8.0'
161+
implementation 'com.meituan.android.walle:library:1.1.6'
157162
}
158163

159164
// 热更新

app/channel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Dev
2+
yinyongbao
3+
pp
4+
meizu
5+
xiaomi
6+
huawei
7+
official

app/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"channelInfoList": [
3+
{
4+
"channel": "xiaomi",
5+
"extraInfo": {
6+
"UMENG_CHANNEL": "xiaomi"
7+
}
8+
}
9+
]
10+
}

app/src/main/AndroidManifest.xml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,32 @@
2424
<activity
2525
android:name=".activity.LauncherActivity"
2626
android:theme="@style/AppTheme.NoActionBar.FullScreen">
27-
<!-- <intent-filter>
27+
<intent-filter>
2828
<action android:name="android.intent.action.MAIN"/>
2929

3030
<category android:name="android.intent.category.LAUNCHER"/>
31-
</intent-filter>-->
31+
</intent-filter>
3232
</activity>
3333

3434
<!--主界面-->
3535
<activity
3636
android:name=".activity.MainActivity"
3737
android:theme="@style/AppTheme.Dark">
38-
<intent-filter>
38+
<!-- <intent-filter>
3939
<action android:name="android.intent.action.MAIN"/>
4040
4141
<category android:name="android.intent.category.LAUNCHER"/>
42-
</intent-filter>
42+
</intent-filter>-->
4343
</activity>
4444

4545
<activity
4646
android:name=".activity.TestActivity"
4747
android:label="博客园测试"
48-
4948
android:theme="@style/AppTheme.Dark">
50-
<!-- <intent-filter>
51-
<action android:name="android.intent.action.MAIN"/>
52-
<category android:name="android.intent.category.LAUNCHER"/>
53-
</intent-filter>-->
49+
<!-- <intent-filter>
50+
<action android:name="android.intent.action.MAIN"/>
51+
<category android:name="android.intent.category.LAUNCHER"/>
52+
</intent-filter>-->
5453
</activity>
5554

5655
<!--博文-->
@@ -240,12 +239,12 @@
240239
android:enabled="true"
241240
android:exported="false"/>
242241

243-
<meta-data
242+
<!-- <meta-data
244243
android:name="UMENG_APPKEY"
245-
android:value="${UMENG_APPKEY}"/>
246-
<meta-data
244+
android:value="${UMENG_APPKEY}"/>-->
245+
<!-- <meta-data
247246
android:name="UMENG_CHANNEL"
248-
android:value="${UMENG_CHANNEL}"/>
247+
android:value="${UMENG_CHANNEL}"/>-->
249248

250249

251250
</application>

app/src/main/java/com/rae/cnblogs/CnblogsApplication.java

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
import android.content.Context;
55
import android.content.pm.PackageManager;
66
import android.support.multidex.MultiDex;
7+
import android.text.TextUtils;
78

89
import com.avos.avoscloud.AVOSCloud;
910
import com.avos.avoscloud.feedback.FeedbackThread;
11+
import com.meituan.android.walle.WalleChannelReader;
1012
import com.rae.cnblogs.sdk.UserProvider;
1113
import com.rae.cnblogs.sdk.bean.UserInfoBean;
1214
import com.rae.cnblogs.sdk.db.DbFactory;
1315
import com.rae.swift.session.SessionManager;
16+
import com.squareup.leakcanary.LeakCanary;
1417
import com.tencent.bugly.Bugly;
1518
import com.tencent.tinker.loader.app.TinkerApplication;
1619
import com.tencent.tinker.loader.shareutil.ShareConstants;
@@ -36,24 +39,22 @@ public void onCreate() {
3639
super.onCreate();
3740

3841
// 级别较高的初始化操作
39-
if (!BuildConfig.DEBUG) {
42+
if (BuildConfig.DEBUG) {
43+
if (!LeakCanary.isInAnalyzerProcess(this)) {
44+
LeakCanary.install(this);
45+
}
46+
} else {
4047
// 正式环境
4148
Bugly.init(getApplication(), BuildConfig.BUGLY_APP_ID, false);
42-
} else {
43-
// 开发环境
4449
}
4550

46-
// if (!LeakCanary.isInAnalyzerProcess(this)) {
47-
// LeakCanary.install(this);
48-
// }
49-
5051
DbFactory.init(this);
52+
initUmengConfig();
5153

5254
// LeanCloud用户反馈初始化,要在主线程
5355
AVOSCloud.initialize(getApplication(), BuildConfig.LEAN_CLOUD_APP_ID, BuildConfig.LEAN_CLOUD_APP_KEY);
5456
FeedbackThread.getInstance();
5557

56-
MobclickAgent.setCatchUncaughtExceptions(BuildConfig.DEBUG);
5758

5859
// 加载皮肤
5960
SkinCompatManager.withoutActivity(getApplication()).loadSkin();
@@ -68,7 +69,7 @@ public void onCreate() {
6869
public void run() {
6970
UserProvider.init(getApplication());
7071
SessionManager.initWithConfig(new SessionManager.ConfigBuilder().context(getApplication()).userClass(UserInfoBean.class).build());
71-
initUmengShareConfig();
72+
7273
}
7374
}).start();
7475
}
@@ -84,11 +85,13 @@ public void clearCache() {
8485
new AppDataManager(this).clearCache();
8586
}
8687

87-
8888
/**
8989
* 友盟分享
9090
*/
91-
private void initUmengShareConfig() {
91+
private void initUmengConfig() {
92+
MobclickAgent.setCatchUncaughtExceptions(false);
93+
// 初始化友盟
94+
MobclickAgent.startWithConfigure(new MobclickAgent.UMAnalyticsConfig(this, BuildConfig.UMENG_APPKEY, getChannel()));
9295
UMShareAPI.get(getApplication());
9396
PlatformConfig.setWeixin(AppConstant.WECHAT_APP_ID, AppConstant.WECHAT_APP_SECRET);
9497
PlatformConfig.setSinaWeibo(AppConstant.WEIBO_APP_ID, AppConstant.WEIBO_APP_SECRET, "http://www.raeblog.com/cnblogs/index.php/share/weibo/redirect");
@@ -104,15 +107,8 @@ public Application getApplication() {
104107
* 获取渠道包
105108
*/
106109
public String getChannel() {
107-
try {
108-
return getPackageManager()
109-
.getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA)
110-
.metaData
111-
.getString("UMENG_CHANNEL", "official");
112-
} catch (Exception e) {
113-
e.printStackTrace();
114-
}
115-
return "official";
110+
String channel = WalleChannelReader.getChannel(this.getApplicationContext());
111+
return TextUtils.isEmpty(channel) ? "UNKNOWN" : channel;
116112
}
117113

118114
@Override

app/src/main/java/com/rae/cnblogs/activity/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class MainActivity extends BaseActivity {
6666
protected void onCreate(Bundle savedInstanceState) {
6767
super.onCreate(savedInstanceState);
6868
setContentView(R.layout.activity_main);
69-
69+
AppUI.toastInCenter(this, "渠道:" + getChannel());
7070
// if (!BuildConfig.DEBUG) {
7171
// // 跳启动页
7272
// startActivity(new Intent(this, LauncherActivity.class));

app/src/main/java/com/rae/cnblogs/activity/TestActivity.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
import android.os.Environment;
66
import android.support.annotation.Nullable;
77
import android.util.Log;
8-
import android.widget.ImageView;
98
import android.widget.TextView;
109

10+
import com.rae.cnblogs.AppUI;
1111
import com.rae.cnblogs.R;
12-
import com.rae.cnblogs.RaeImageLoader;
1312
import com.rae.cnblogs.ThemeCompat;
13+
import com.rae.cnblogs.sdk.CnblogsApiFactory;
14+
import com.rae.cnblogs.sdk.CnblogsApiProvider;
1415
import com.tencent.bugly.beta.tinker.TinkerManager;
1516

1617
import java.io.File;
@@ -27,14 +28,10 @@ public class TestActivity extends BaseActivity {
2728
@BindView(R.id.tv_message)
2829
TextView mMsgView;
2930

30-
@BindView(R.id.img_background)
31-
ImageView mImageView;
32-
3331
@Override
3432
protected void onCreate(@Nullable Bundle savedInstanceState) {
3533
super.onCreate(savedInstanceState);
3634
setContentView(R.layout.activity_test);
37-
RaeImageLoader.displayImage("https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=2082469064,1467337990&fm=173&s=BAD3E14C5DC3B97014E554030300E0C1&w=218&h=146&img.JPEG", mImageView);
3835
}
3936

4037
@OnClick(R.id.btn_main)
@@ -48,6 +45,12 @@ public void onTestClick() {
4845
// AppUI.toastInCenter(this, "我是热更新!");
4946
}
5047

48+
@OnClick(R.id.btn_sdk_patch_test)
49+
public void onSdkPatchClick() {
50+
CnblogsApiProvider provider = CnblogsApiFactory.getInstance(this);
51+
AppUI.toastInCenter(this, "SDK版本号:" + provider.getApiVersion());
52+
}
53+
5154

5255
@OnClick(R.id.btn_patch_test)
5356
public void onPatchClick() {

0 commit comments

Comments
 (0)