Skip to content

Commit 8e8a94d

Browse files
committed
add CrashReport and Upgrade
1 parent 6fb92b1 commit 8e8a94d

File tree

9 files changed

+141
-2
lines changed

9 files changed

+141
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/build
77
/captures
88
.externalNativeBuild
9+
/app/bugly

app/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@
1616

1717
apply plugin: 'com.android.application'
1818
apply plugin: 'org.greenrobot.greendao'
19+
apply plugin: 'bugly'
20+
//apply from: 'tinker-support.gradle'
1921

22+
bugly {
23+
appId = "03be19dd60"
24+
appKey = "ff11433f-8ef9-4f2c-a123-9bcbe6d0605e"
25+
debug = true
26+
}
2027
android {
2128
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
2229
defaultConfig {
@@ -134,6 +141,7 @@ dependencies {
134141
implementation rootProject.ext.dependencies["fragmentation"]
135142
implementation rootProject.ext.dependencies["fragmentation-swipeback"]
136143
implementation rootProject.ext.dependencies["crashreport_upgrade"]
144+
implementation rootProject.ext.dependencies["nativecrashreport"]
137145
implementation rootProject.ext.dependencies["logger"]
138146
implementation rootProject.ext.dependencies["ByeBurger"]
139147
implementation rootProject.ext.dependencies["stetho"]

app/proguard-rules.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@
242242
-keep public class com.tencent.bugly.**{*;}
243243
-keep class android.support.**{*;}
244244

245+
# tinker
246+
-dontwarn com.tencent.tinker.**
247+
-keep class com.tencent.tinker.** { *; }
248+
245249
################ autolayout ###############
246250
-keep class com.zhy.autolayout.** { *; }
247251
-keep interface com.zhy.autolayout.** { *; }

app/src/main/AndroidManifest.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
2323
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
2424
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
25+
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
26+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
27+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
28+
<uses-permission android:name="android.permission.READ_LOGS" />
29+
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
2530

2631
<application
2732
android:name=".app.WanAndroidApp"
@@ -71,6 +76,11 @@
7176
<activity android:name=".modules.todo.ui.TodoActivity" />
7277
<activity android:name=".modules.todo.ui.AddTodoActivity" />
7378

79+
<activity
80+
android:name="com.tencent.bugly.beta.ui.BetaActivity"
81+
android:configChanges="keyboardHidden|orientation|screenSize|locale"
82+
android:theme="@android:style/Theme.Translucent" />
83+
7484
<meta-data
7585
android:name="design_width_in_dp"
7686
android:value="360" />

app/src/main/java/com/forgetsky/wanandroid/app/WanAndroidApp.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
import android.content.Context;
2222
import android.support.v7.app.AppCompatDelegate;
2323

24+
import com.forgetsky.wanandroid.BuildConfig;
2425
import com.forgetsky.wanandroid.core.DataManager;
2526
import com.forgetsky.wanandroid.di.component.DaggerAppComponent;
2627
import com.forgetsky.wanandroid.di.module.AppModule;
2728
import com.forgetsky.wanandroid.di.module.HttpModule;
2829
import com.squareup.leakcanary.LeakCanary;
2930
import com.squareup.leakcanary.RefWatcher;
31+
import com.tencent.bugly.Bugly;
3032

3133
import javax.inject.Inject;
3234

@@ -68,6 +70,8 @@ public void onCreate() {
6870
}
6971

7072
refWatcher = setupLeakCanary();
73+
74+
Bugly.init(getApplicationContext(), "03be19dd60", BuildConfig.DEBUG);
7175
}
7276

7377
private RefWatcher setupLeakCanary() {

app/src/main/java/com/forgetsky/wanandroid/modules/main/ui/fragment/AboutFragment.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.forgetsky.wanandroid.modules.main.contract.AboutContract;
2929
import com.forgetsky.wanandroid.modules.main.presenter.AboutPresenter;
3030
import com.forgetsky.wanandroid.utils.CommonUtils;
31+
import com.tencent.bugly.beta.Beta;
3132

3233
import butterknife.BindView;
3334
import butterknife.OnClick;
@@ -77,6 +78,7 @@ private void showAboutContent() {
7778
void onClick(View view) {
7879
switch (view.getId()) {
7980
case R.id.about_upgrade:
81+
Beta.checkUpgrade();
8082
break;
8183
case R.id.about_website:
8284
CommonUtils.startArticleDetailActivity(_mActivity, -1,

app/tinker-support.gradle

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* (C) Copyright 2019, ForgetSky.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
apply plugin: 'com.tencent.bugly.tinker-support'
18+
19+
def bakPath = file("${buildDir}/bakApk/")
20+
21+
/**
22+
* 此处填写每次构建生成的基准包目录
23+
*/
24+
def baseApkDir = "app-0208-15-10-00"
25+
26+
/**
27+
* 对于插件各参数的详细解析请参考
28+
*/
29+
tinkerSupport {
30+
31+
// 开启tinker-support插件,默认值true
32+
enable = true
33+
34+
// 指定归档目录,默认值当前module的子目录tinker
35+
autoBackupApkDir = "${bakPath}"
36+
37+
// 是否启用覆盖tinkerPatch配置功能,默认值false
38+
// 开启后tinkerPatch配置不生效,即无需添加tinkerPatch
39+
overrideTinkerPatchConfiguration = true
40+
41+
// 编译补丁包时,必需指定基线版本的apk,默认值为空
42+
// 如果为空,则表示不是进行补丁包的编译
43+
// @{link tinkerPatch.oldApk }
44+
baseApk = "${bakPath}/${baseApkDir}/app-release.apk"
45+
46+
// 对应tinker插件applyMapping
47+
baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-release-mapping.txt"
48+
49+
// 对应tinker插件applyResourceMapping
50+
baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-release-R.txt"
51+
52+
// 构建基准包和补丁包都要指定不同的tinkerId,并且必须保证唯一性
53+
tinkerId = "base-1.0.1"
54+
55+
// 构建多渠道补丁时使用
56+
// buildAllFlavorsDir = "${bakPath}/${baseApkDir}"
57+
58+
// 是否启用加固模式,默认为false.(tinker-spport 1.0.7起支持)
59+
// isProtectedApp = true
60+
61+
// 是否开启反射Application模式.推荐false,但是会增加接入成本
62+
enableProxyApplication = true
63+
64+
// 是否支持新增非export的Activity(注意:设置为true才能修改AndroidManifest文件)
65+
supportHotplugComponent = true
66+
67+
}
68+
69+
/**
70+
* 一般来说,我们无需对下面的参数做任何的修改
71+
* 对于各参数的详细介绍请参考:
72+
* https://github.com/Tencent/tinker/wiki/Tinker-%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97
73+
*/
74+
tinkerPatch {
75+
//oldApk ="${bakPath}/${appName}/app-release.apk"
76+
ignoreWarning = false
77+
useSign = true
78+
dex {
79+
dexMode = "jar"
80+
pattern = ["classes*.dex"]
81+
loader = []
82+
}
83+
lib {
84+
pattern = ["lib/*/*.so"]
85+
}
86+
87+
res {
88+
pattern = ["res/*", "r/*", "assets/*", "resources.arsc", "AndroidManifest.xml"]
89+
ignoreChange = []
90+
largeModSize = 100
91+
}
92+
93+
packageConfig {
94+
}
95+
sevenZip {
96+
zipArtifact = "com.tencent.mm:SevenZip:1.1.10"
97+
// path = "/usr/local/bin/7za"
98+
}
99+
buildConfig {
100+
keepDexApply = false
101+
//tinkerId = "1.0.1-base"
102+
//applyMapping = "${bakPath}/${appName}/app-release-mapping.txt" // 可选,设置mapping文件,建议保持旧apk的proguard混淆方式
103+
//applyResourceMapping = "${bakPath}/${appName}/app-release-R.txt" // 可选,设置R.txt文件,通过旧apk文件保持ResId的分配
104+
}
105+
}

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ buildscript {
1212
dependencies {
1313
classpath 'com.android.tools.build:gradle:3.3.0'
1414
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
15+
classpath 'com.tencent.bugly:symtabfileuploader:latest.release'
16+
classpath "com.tencent.bugly:tinker-support:latest.release"
1517

1618
// NOTE: Do not place your application dependencies here; they belong
1719
// in the individual module build.gradle files

config.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ext {
55
buildToolsVersion : "28.0.0",
66
minSdkVersion : 21,
77
targetSdkVersion : 28,
8-
versionCode : 10102,
9-
versionName : "1.1.2",
8+
versionCode : 10103,
9+
versionName : "1.1.3",
1010
renderscriptTargetApi : 21
1111
]
1212

@@ -90,6 +90,9 @@ ext {
9090
"fragmentation" : "me.yokeyword:fragmentation:${version["fragmentationVersion"]}",
9191
"fragmentation-swipeback" : "me.yokeyword:fragmentation-swipeback:${version["fragmentationVersion"]}",
9292
"crashreport_upgrade" : "com.tencent.bugly:crashreport_upgrade:latest.release",
93+
"nativecrashreport" : "com.tencent.bugly:nativecrashreport:latest.release",
94+
"symtabfileuploader" : "com.tencent.bugly:symtabfileuploader:latest.release",
95+
"tinker" : "com.tencent.tinker:tinker-android-lib:latest.release",
9396
"logger" : "com.orhanobut:logger:2.1.1",
9497
"ByeBurger" : "com.github.githubwing:ByeBurger:1.2.3",
9598
"stetho" : "com.facebook.stetho:stetho:1.5.0",

0 commit comments

Comments
 (0)