Skip to content

Commit a20ca83

Browse files
hui.zhaohui.zhao
authored andcommitted
upgrade to 3.4.1
support multi process support debug and release
1 parent 50165fe commit a20ca83

File tree

9 files changed

+125
-43
lines changed

9 files changed

+125
-43
lines changed

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ install:
2828
- sdkmanager --list || true
2929

3030
script:
31-
- ./gradlew assembleRelease
31+
- ./gradlew clean && ./gradlew assembleRelease && ./gradlew copyForRelease
32+
- ./gradlew clean && ./gradlew assembleDebug && ./gradlew copyForDebug
3233

3334
notifications:
3435
email:
@@ -37,7 +38,9 @@ notifications:
3738
deploy:
3839
- provider: releases
3940
api_key: $GITHUB_TOKEN
40-
file: "./app/build/outputs/apk/release/app-release.apk"
41+
file:
42+
- "./github_release/app-release.apk"
43+
- "./github_release/app-debug.apk"
4144
skip_cleanup: true
4245
on:
4346
tags: true

app/build.gradle

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,54 @@ android {
1818
versionName rootProject.ext.REAL_VERSION_NAME
1919
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2020
}
21+
compileOptions {
22+
sourceCompatibility 1.8
23+
targetCompatibility 1.8
24+
}
2125
buildTypes {
2226
release {
23-
minifyEnabled false
27+
resValue("string", "android_god_eye_demo_name", "AndroidGodEyeDemo-release")
28+
minifyEnabled true
2429
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2530
signingConfig signingConfigs.release
31+
resValue("bool", "android_god_eye_manual_install", "false")
32+
resValue("bool", "android_god_eye_need_notification", "false")
33+
resValue("integer", "android_god_eye_monitor_port", "5390")
34+
resValue("string", "android_god_eye_install_assets_path", "android-godeye-config/install.config")
2635
}
2736
debug {
37+
applicationIdSuffix ".debug"
38+
resValue("string", "android_god_eye_demo_name", "AndroidGodEyeDemo-debug")
2839
minifyEnabled false
2940
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
30-
signingConfig signingConfigs.debug
41+
signingConfig signingConfigs.release
42+
resValue("bool", "android_god_eye_manual_install", "false")
43+
resValue("bool", "android_god_eye_need_notification", "true")
44+
resValue("integer", "android_god_eye_monitor_port", "5390")
45+
resValue("string", "android_god_eye_install_assets_path", "android-godeye-config/install.config")
3146
}
3247
}
33-
compileOptions {
34-
sourceCompatibility 1.8
35-
targetCompatibility 1.8
36-
}
3748
}
3849

3950
dependencies {
4051
implementation fileTree(include: ['*.jar'], dir: 'libs')
4152
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
4253
// Core module
4354
implementation "cn.hikyson.godeye:godeye-core:${VERSION_NAME}"
44-
// // Debug dashboard
45-
// debugImplementation "cn.hikyson.godeye:godeye-monitor:${VERSION_NAME}"
46-
implementation "cn.hikyson.godeye:godeye-monitor:${VERSION_NAME}"
55+
// Debug dashboard
56+
debugImplementation "cn.hikyson.godeye:godeye-monitor:${VERSION_NAME}"
4757
// Extra module, help to monitor network
4858
implementation "cn.hikyson.godeye:godeye-okhttp:${VERSION_NAME}"
4959
// Extra module, help to monitor crash/ANR
5060
implementation "cn.hikyson.godeye:godeye-xcrash:${VERSION_NAME}"
5161
// Extra module, help to monitor leak memory
52-
implementation "cn.hikyson.godeye:godeye-leakcanary:${VERSION_NAME}"
62+
debugImplementation "cn.hikyson.godeye:godeye-leakcanary:${VERSION_NAME}"
5363
}
5464

5565
apply plugin: 'cn.hikyson.methodcanary.plugin'
5666

5767
AndroidGodEye {
58-
enableMethodTracer true
68+
enableMethodTracer !gradle.startParameter.taskNames.contains("assembleRelease")
5969
enableLifecycleTracer true
6070
instrumentationRuleFilePath 'AndroidGodEye-MethodCanary.js'
6171
instrumentationRuleIncludeClassNamePrefix(['cn/hikyson/godeyedemo'])

app/proguard-rules.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
2121
#-renamesourcefileattribute SourceFile
22+
-dontwarn javax.annotation.**
23+
-dontwarn org.conscrypt.**
24+
-dontwarn org.codehaus.**

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
package="cn.hikyson.godeyedemo">
55

6+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
7+
<uses-permission android:name="android.permission.INTERNET" />
8+
69
<application
710
android:name=".MyApp"
8-
android:allowBackup="true"
11+
android:allowBackup="false"
912
android:icon="@mipmap/ic_launcher"
10-
android:label="@string/app_name"
13+
android:label="@string/android_god_eye_demo_name"
1114
android:supportsRtl="true">
1215
<activity android:name=".MainActivity">
1316
<intent-filter>
@@ -17,21 +20,12 @@
1720
</intent-filter>
1821
</activity>
1922

20-
<activity android:name=".LeakActivity"></activity>
23+
<activity android:name=".LeakActivity" />
2124

2225
<service
2326
android:name=".MyIntentService"
2427
android:exported="false"
25-
android:process=":test"></service>
26-
27-
<service
28-
android:name="cn.hikyson.godeye.core.internal.notification.LocalNotificationListenerService"
29-
android:enabled="true"
30-
android:exported="false"
31-
android:process="cn.hikyson.godeyedemo"
32-
tools:replace="android:process" />
28+
android:process=":test" />
3329
</application>
3430

35-
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
36-
3731
</manifest>

app/src/main/java/cn/hikyson/godeyedemo/MainActivity.java

Lines changed: 78 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,25 @@
1212
import android.widget.Toast;
1313

1414
import java.io.IOException;
15+
import java.util.List;
1516

17+
import cn.hikyson.godeye.core.GodEye;
1618
import cn.hikyson.godeye.core.GodEyeHelper;
1719
import cn.hikyson.godeye.core.exceptions.UninstallException;
20+
import cn.hikyson.godeye.core.internal.modules.crash.CrashInfo;
21+
import cn.hikyson.godeye.core.internal.modules.network.NetworkInfo;
22+
import cn.hikyson.godeye.core.internal.modules.sm.BlockInfo;
1823
import cn.hikyson.godeye.core.internal.modules.startup.StartupInfo;
19-
import cn.hikyson.godeye.monitor.GodEyeMonitor;
24+
import io.reactivex.android.schedulers.AndroidSchedulers;
25+
import io.reactivex.disposables.CompositeDisposable;
26+
import io.reactivex.functions.Consumer;
2027
import okhttp3.OkHttpClient;
2128
import okhttp3.Request;
2229
import okhttp3.Response;
2330
import xcrash.XCrash;
2431

2532
public class MainActivity extends Activity {
33+
CompositeDisposable mCompositeDisposable;
2634

2735
@Override
2836
protected void onCreate(Bundle savedInstanceState) {
@@ -47,11 +55,13 @@ public void run() {
4755
});
4856
}
4957
});
58+
observeWhenRelease();
5059
}
5160

5261
@Override
5362
protected void onDestroy() {
5463
super.onDestroy();
64+
cleanupWhenRlease();
5565
}
5666

5767
public void request(View view) {
@@ -102,19 +112,76 @@ public void jumpToLeak(View view) {
102112
}
103113

104114
private static String getNote() {
105-
String openAddress = "AndroidGodEye dashboard is available on [http://localhost:5390/index.html], use plugin to open it.";
106-
String condition = "Install Android Studio plugin(Named 'AndroidGodEye') [https://plugins.jetbrains.com/plugin/12114-androidgodeye] to view details.";
107-
String logcat = "You can find the address in logcat by search 'AndroidGodEye monitor is running at port'.";
108-
return openAddress + "\n\n" + condition + "\n\n" + logcat;
109-
}
110-
111-
private void openBrowser(String url) {
112-
Intent intent = new Intent(Intent.ACTION_VIEW);
113-
intent.setData(Uri.parse(url));
114-
startActivity(intent);
115+
if ("debug".equalsIgnoreCase(BuildConfig.BUILD_TYPE)) {
116+
String note1 = "This is a debug apk. Debug monitor is opened. Notification config is opened.";
117+
String openAddress = "AndroidGodEye dashboard is available on [http://localhost:5390/index.html], use plugin to open it.";
118+
String condition = "Install Android Studio plugin(Named 'AndroidGodEye') [https://plugins.jetbrains.com/plugin/12114-androidgodeye] to view details.";
119+
String logcat = "You can find the address in logcat by search 'AndroidGodEye monitor is running at port'.";
120+
return openAddress + "\n\n" + condition + "\n\n" + logcat;
121+
} else {
122+
String note1 = "This is a release apk. Debug monitor is closed. Notification config is closed.";
123+
return note1;
124+
}
115125
}
116126

117127
public void makeCrash(View view) {
118128
XCrash.testJavaCrash(true);
119129
}
130+
131+
private void observeWhenRelease() {
132+
if (!"debug".equalsIgnoreCase(BuildConfig.BUILD_TYPE)) {
133+
mCompositeDisposable = new CompositeDisposable();
134+
try {
135+
mCompositeDisposable.add(GodEye.instance().observeModule(GodEye.ModuleName.NETWORK, new Consumer<NetworkInfo>() {
136+
@Override
137+
public void accept(NetworkInfo networkInfo) throws Exception {
138+
AndroidSchedulers.mainThread().scheduleDirect(new Runnable() {
139+
@Override
140+
public void run() {
141+
Toast.makeText(MainActivity.this, "This is NetworkInfo message from release:" + networkInfo.summary, Toast.LENGTH_LONG).show();
142+
}
143+
});
144+
}
145+
}));
146+
} catch (UninstallException e) {
147+
e.printStackTrace();
148+
}
149+
try {
150+
mCompositeDisposable.add(GodEye.instance().observeModule(GodEye.ModuleName.SM, new Consumer<BlockInfo>() {
151+
@Override
152+
public void accept(BlockInfo blockInfo) throws Exception {
153+
AndroidSchedulers.mainThread().scheduleDirect(new Runnable() {
154+
@Override
155+
public void run() {
156+
Toast.makeText(MainActivity.this, "This is BlockInfo message from release:" + blockInfo.toString(), Toast.LENGTH_LONG).show();
157+
}
158+
});
159+
}
160+
}));
161+
} catch (UninstallException e) {
162+
e.printStackTrace();
163+
}
164+
try {
165+
mCompositeDisposable.add(GodEye.instance().observeModule(GodEye.ModuleName.CRASH, new Consumer<List<CrashInfo>>() {
166+
@Override
167+
public void accept(List<CrashInfo> crashInfos) throws Exception {
168+
AndroidSchedulers.mainThread().scheduleDirect(new Runnable() {
169+
@Override
170+
public void run() {
171+
Toast.makeText(MainActivity.this, "This is CrashInfo message from release:" + crashInfos.toString(), Toast.LENGTH_LONG).show();
172+
}
173+
});
174+
}
175+
}));
176+
} catch (UninstallException e) {
177+
e.printStackTrace();
178+
}
179+
}
180+
}
181+
182+
private void cleanupWhenRlease() {
183+
if (mCompositeDisposable != null) {
184+
mCompositeDisposable.dispose();
185+
}
186+
}
120187
}

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/src/main/res/values/styles.xml

Lines changed: 0 additions & 2 deletions
This file was deleted.

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,13 @@ ext {
6161
}
6262

6363
println "[VERSION] Version name is [" + rootProject.ext.REAL_VERSION_NAME + "] and parsed version code is [" + rootProject.ext.REAL_VERSION_CODE + "]."
64+
65+
task copyForRelease(type: Copy) {
66+
from './app/build/outputs/apk/release/app-release.apk'
67+
into "./github_release"
68+
}
69+
70+
task copyForDebug(type: Copy) {
71+
from './app/build/outputs/apk/debug/app-debug.apk'
72+
into "./github_release"
73+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ org.gradle.jvmargs=-Xmx1536m
1818
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1919
# org.gradle.parallel=true
2020

21-
VERSION_NAME=3.4.0
21+
VERSION_NAME=3.4.1
2222
METHOD_CANARY_VERSION_NAME=0.15.4
2323
USE_ALIYUN_REPO=false

0 commit comments

Comments
 (0)