Skip to content

Commit

Permalink
upgrade to 3.4.1
Browse files Browse the repository at this point in the history
support multi process
support debug and release
  • Loading branch information
hui.zhao authored and hui.zhao committed Mar 27, 2020
1 parent 50165fe commit a20ca83
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 43 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ install:
- sdkmanager --list || true

script:
- ./gradlew assembleRelease
- ./gradlew clean && ./gradlew assembleRelease && ./gradlew copyForRelease
- ./gradlew clean && ./gradlew assembleDebug && ./gradlew copyForDebug

notifications:
email:
Expand All @@ -37,7 +38,9 @@ notifications:
deploy:
- provider: releases
api_key: $GITHUB_TOKEN
file: "./app/build/outputs/apk/release/app-release.apk"
file:
- "./github_release/app-release.apk"
- "./github_release/app-debug.apk"
skip_cleanup: true
on:
tags: true
Expand Down
32 changes: 21 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,54 @@ android {
versionName rootProject.ext.REAL_VERSION_NAME
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
buildTypes {
release {
minifyEnabled false
resValue("string", "android_god_eye_demo_name", "AndroidGodEyeDemo-release")
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
resValue("bool", "android_god_eye_manual_install", "false")
resValue("bool", "android_god_eye_need_notification", "false")
resValue("integer", "android_god_eye_monitor_port", "5390")
resValue("string", "android_god_eye_install_assets_path", "android-godeye-config/install.config")
}
debug {
applicationIdSuffix ".debug"
resValue("string", "android_god_eye_demo_name", "AndroidGodEyeDemo-debug")
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
resValue("bool", "android_god_eye_manual_install", "false")
resValue("bool", "android_god_eye_need_notification", "true")
resValue("integer", "android_god_eye_monitor_port", "5390")
resValue("string", "android_god_eye_install_assets_path", "android-godeye-config/install.config")
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// Core module
implementation "cn.hikyson.godeye:godeye-core:${VERSION_NAME}"
// // Debug dashboard
// debugImplementation "cn.hikyson.godeye:godeye-monitor:${VERSION_NAME}"
implementation "cn.hikyson.godeye:godeye-monitor:${VERSION_NAME}"
// Debug dashboard
debugImplementation "cn.hikyson.godeye:godeye-monitor:${VERSION_NAME}"
// Extra module, help to monitor network
implementation "cn.hikyson.godeye:godeye-okhttp:${VERSION_NAME}"
// Extra module, help to monitor crash/ANR
implementation "cn.hikyson.godeye:godeye-xcrash:${VERSION_NAME}"
// Extra module, help to monitor leak memory
implementation "cn.hikyson.godeye:godeye-leakcanary:${VERSION_NAME}"
debugImplementation "cn.hikyson.godeye:godeye-leakcanary:${VERSION_NAME}"
}

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

AndroidGodEye {
enableMethodTracer true
enableMethodTracer !gradle.startParameter.taskNames.contains("assembleRelease")
enableLifecycleTracer true
instrumentationRuleFilePath 'AndroidGodEye-MethodCanary.js'
instrumentationRuleIncludeClassNamePrefix(['cn/hikyson/godeyedemo'])
Expand Down
3 changes: 3 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-dontwarn javax.annotation.**
-dontwarn org.conscrypt.**
-dontwarn org.codehaus.**
20 changes: 7 additions & 13 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
xmlns:tools="http://schemas.android.com/tools"
package="cn.hikyson.godeyedemo">

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".MyApp"
android:allowBackup="true"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:label="@string/android_god_eye_demo_name"
android:supportsRtl="true">
<activity android:name=".MainActivity">
<intent-filter>
Expand All @@ -17,21 +20,12 @@
</intent-filter>
</activity>

<activity android:name=".LeakActivity"></activity>
<activity android:name=".LeakActivity" />

<service
android:name=".MyIntentService"
android:exported="false"
android:process=":test"></service>

<service
android:name="cn.hikyson.godeye.core.internal.notification.LocalNotificationListenerService"
android:enabled="true"
android:exported="false"
android:process="cn.hikyson.godeyedemo"
tools:replace="android:process" />
android:process=":test" />
</application>

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

</manifest>
89 changes: 78 additions & 11 deletions app/src/main/java/cn/hikyson/godeyedemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,25 @@
import android.widget.Toast;

import java.io.IOException;
import java.util.List;

import cn.hikyson.godeye.core.GodEye;
import cn.hikyson.godeye.core.GodEyeHelper;
import cn.hikyson.godeye.core.exceptions.UninstallException;
import cn.hikyson.godeye.core.internal.modules.crash.CrashInfo;
import cn.hikyson.godeye.core.internal.modules.network.NetworkInfo;
import cn.hikyson.godeye.core.internal.modules.sm.BlockInfo;
import cn.hikyson.godeye.core.internal.modules.startup.StartupInfo;
import cn.hikyson.godeye.monitor.GodEyeMonitor;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.functions.Consumer;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import xcrash.XCrash;

public class MainActivity extends Activity {
CompositeDisposable mCompositeDisposable;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -47,11 +55,13 @@ public void run() {
});
}
});
observeWhenRelease();
}

@Override
protected void onDestroy() {
super.onDestroy();
cleanupWhenRlease();
}

public void request(View view) {
Expand Down Expand Up @@ -102,19 +112,76 @@ public void jumpToLeak(View view) {
}

private static String getNote() {
String openAddress = "AndroidGodEye dashboard is available on [http://localhost:5390/index.html], use plugin to open it.";
String condition = "Install Android Studio plugin(Named 'AndroidGodEye') [https://plugins.jetbrains.com/plugin/12114-androidgodeye] to view details.";
String logcat = "You can find the address in logcat by search 'AndroidGodEye monitor is running at port'.";
return openAddress + "\n\n" + condition + "\n\n" + logcat;
}

private void openBrowser(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
if ("debug".equalsIgnoreCase(BuildConfig.BUILD_TYPE)) {
String note1 = "This is a debug apk. Debug monitor is opened. Notification config is opened.";
String openAddress = "AndroidGodEye dashboard is available on [http://localhost:5390/index.html], use plugin to open it.";
String condition = "Install Android Studio plugin(Named 'AndroidGodEye') [https://plugins.jetbrains.com/plugin/12114-androidgodeye] to view details.";
String logcat = "You can find the address in logcat by search 'AndroidGodEye monitor is running at port'.";
return openAddress + "\n\n" + condition + "\n\n" + logcat;
} else {
String note1 = "This is a release apk. Debug monitor is closed. Notification config is closed.";
return note1;
}
}

public void makeCrash(View view) {
XCrash.testJavaCrash(true);
}

private void observeWhenRelease() {
if (!"debug".equalsIgnoreCase(BuildConfig.BUILD_TYPE)) {
mCompositeDisposable = new CompositeDisposable();
try {
mCompositeDisposable.add(GodEye.instance().observeModule(GodEye.ModuleName.NETWORK, new Consumer<NetworkInfo>() {
@Override
public void accept(NetworkInfo networkInfo) throws Exception {
AndroidSchedulers.mainThread().scheduleDirect(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "This is NetworkInfo message from release:" + networkInfo.summary, Toast.LENGTH_LONG).show();
}
});
}
}));
} catch (UninstallException e) {
e.printStackTrace();
}
try {
mCompositeDisposable.add(GodEye.instance().observeModule(GodEye.ModuleName.SM, new Consumer<BlockInfo>() {
@Override
public void accept(BlockInfo blockInfo) throws Exception {
AndroidSchedulers.mainThread().scheduleDirect(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "This is BlockInfo message from release:" + blockInfo.toString(), Toast.LENGTH_LONG).show();
}
});
}
}));
} catch (UninstallException e) {
e.printStackTrace();
}
try {
mCompositeDisposable.add(GodEye.instance().observeModule(GodEye.ModuleName.CRASH, new Consumer<List<CrashInfo>>() {
@Override
public void accept(List<CrashInfo> crashInfos) throws Exception {
AndroidSchedulers.mainThread().scheduleDirect(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "This is CrashInfo message from release:" + crashInfos.toString(), Toast.LENGTH_LONG).show();
}
});
}
}));
} catch (UninstallException e) {
e.printStackTrace();
}
}
}

private void cleanupWhenRlease() {
if (mCompositeDisposable != null) {
mCompositeDisposable.dispose();
}
}
}
3 changes: 0 additions & 3 deletions app/src/main/res/values/strings.xml

This file was deleted.

2 changes: 0 additions & 2 deletions app/src/main/res/values/styles.xml

This file was deleted.

10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,13 @@ ext {
}

println "[VERSION] Version name is [" + rootProject.ext.REAL_VERSION_NAME + "] and parsed version code is [" + rootProject.ext.REAL_VERSION_CODE + "]."

task copyForRelease(type: Copy) {
from './app/build/outputs/apk/release/app-release.apk'
into "./github_release"
}

task copyForDebug(type: Copy) {
from './app/build/outputs/apk/debug/app-debug.apk'
into "./github_release"
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ org.gradle.jvmargs=-Xmx1536m
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

VERSION_NAME=3.4.0
VERSION_NAME=3.4.1
METHOD_CANARY_VERSION_NAME=0.15.4
USE_ALIYUN_REPO=false

0 comments on commit a20ca83

Please sign in to comment.