Skip to content

Commit

Permalink
切到jitpack
Browse files Browse the repository at this point in the history
  • Loading branch information
shentianzhou committed Apr 19, 2021
1 parent 27d357e commit f1a28f4
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 79 deletions.
69 changes: 35 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,68 @@ sensitive information in the file。More importantly, the file is small but the
complete, which is very suitable for offline analysis of oom and other exceptions

## Apps using Tailor

| <img src="docs/xigua.png" alt="xigua" width="100"/> | <img src="docs/douyin.png" alt="douyin" width="100"/> | <img src="docs/huoshan.png" alt="huoshan" width="100"/> | <img src="docs/kaiyan.png" alt="kaiyan" width="100"/>
|:-----------:|:-------:|:-------:|:-------:|
| Xigua Video | Douyin | Huoshan | Kaiyan |
<img src="docs/xigua.png" width="100"/><img src="docs/douyin.png" width="100"/><img src="docs/huoshan.png" width="100"/><img src="docs/kaiyan.png" width="100"/>

## Get started
Step 1: Add the JitPack repository to your build file
```gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```

Step1: Add to your build.gradle
Step 2: Add the dependency
```gradle
implementation 'com.bytedance.tailor:library:1.0.8'
dependencies {
implementation 'com.github.bytedance:tailor:1.0.9'
}
```

Step2: For simple usage

```java
// Using Tailor to get a mini hprof file in exception callback
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "mini.hprof";
try {
Tailor.dumpHprofData(path, true);
} catch (IOException ex) {
ex.printStackTrace();
}
Step 3: Add code for simple usage
```Java
if (e instanceof java.lang.OutOfMemoryError) {
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "mini.hprof";
try {
Tailor.dumpHprofData(path, true);
} catch (IOException ex) {
ex.printStackTrace();
}
})
}
```

```Java
// Crop and compress the existing hprof files directly
Tailor.cropHprofData(source, target, true);
```

Step3: File upload
Step 4: Upload data
```shell
App needs to implement upload logic by itself
## !!! App needs to implement upload logic by itself
```

Step4: Data recovery(Python version 3.5 and above)
Step 5: Process data (Python version >= 3.5)
```shell
## Data recovery
python3 library/src/main/python/decode.py -i mini.hprof -o target.hprof
```

## Extra

In order to facilitate everyone to understand the file format of the hprof and the details of cropping
and compression, we provide three script implementations (Python version 3.5 and above)

```shell
// Hprof verify
## Hprof verify
python3 library/src/main/python/verify.py -i source.hprof
```

// Crop and compress
```shell
## Crop and compress
python3 library/src/main/python/encode.py -i source.hprof -o mini.hprof

// Data recovery
python3 library/src/main/python/decode.py -i mini.hprof -o target.hprof
```
## Support

## Extra
1. [Android Camera内存问题剖析](https://mp.weixin.qq.com/s/-oaN-bOqHDjN30UP1FMpgA)
2. [西瓜视频稳定性治理体系建设一:Tailor 原理及实践](https://mp.weixin.qq.com/s/DWOQ9MSTkKSCBFQjPswPIQ)

## Support
1. Communicate on [GitHub issues](https://github.com/bytedance/tailor/issues)
2. Mail: <a href="mailto:[email protected]">[email protected]</a>
3. WeChat: 429013449
Expand Down
67 changes: 36 additions & 31 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,70 @@ Tailor是西瓜Android团队开发的一款通用内存快照裁剪压缩工具
有任何敏感信息,更重要的是文件非常小的同时数据也相对完整,非常适合离线分析OOM及其他类型异常的调查定位。

## Apps using Tailor

| <img src="docs/xigua.png" alt="xigua" width="100"/> | <img src="docs/douyin.png" alt="douyin" width="100"/> | <img src="docs/huoshan.png" alt="huoshan" width="100"/> | <img src="docs/kaiyan.png" alt="kaiyan" width="100"/>
|:---------:|:-------:|:-------:|:-------:|
| 西瓜视频 | 抖音 | 火山 | 开言英语 |
<img src="docs/xigua.png" width="100"/><img src="docs/douyin.png" width="100"/><img src="docs/huoshan.png" width="100"/><img src="docs/kaiyan.png" width="100"/>

## Get started
Step 1: Add the JitPack repository to your build file
```gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```

Step1 添加依赖:
Step 2: Add the dependency
```gradle
implementation 'com.bytedance.tailor:library:1.0.8'
dependencies {
implementation 'com.github.bytedance:tailor:1.0.9'
}
```

Step2 代码接入:
Step 3: Add code for simple usage
```Java
// 在异常回调里通过Tailor获取快照,不同的app异常回调接口不同,可以根据app的实际情况调整,Ex:
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "mini.hprof";
try {
Tailor.dumpHprofData(path, true);
} catch (IOException ex) {
ex.printStackTrace();
}
// 在异常回调里通过 Tailor 获取快照
if (e instanceof java.lang.OutOfMemoryError) {
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "mini.hprof";
try {
Tailor.dumpHprofData(path, true);
} catch (IOException ex) {
ex.printStackTrace();
}
})
}
```

```Java
// 也可以直接对已经存在的hprof文件裁剪压缩
Tailor.cropHprofData(source, target, true);
```

Step3 数据上传:
Step 4: Upload data
```shell
应用需自己实现上传逻辑或相应的数据回捞功能
## !!! 应用需自己实现数据上传或回捞
```

Step4 数据还原:
Step 5: Process data (Python version 3.5以上)
```shell
// 还原快照文件(Python version 3.5以上)
## 还原数据, target.hprof 可通过 Android Studio 分析,通过 MAT 还需要 hprof-conv 转换
python3 library/src/main/python/decode.py -i mini.hprof -o target.hprof
```

## Extra

为了方便大家理解内存快照的文件格式及裁剪压缩细节,我们提供了三个脚本实现(Python version 3.5以上)
```shell
// 解析验证
## 解析验证
python3 library/src/main/python/verify.py -i source.hprof
```

// 裁剪压缩
```shell
## 裁剪压缩
python3 library/src/main/python/encode.py -i source.hprof -o mini.hprof

// 数据还原
python3 library/src/main/python/decode.py -i mini.hprof -o target.hprof
```
## Support

## Extra
1. [Android Camera内存问题剖析](https://mp.weixin.qq.com/s/-oaN-bOqHDjN30UP1FMpgA)
2. [西瓜视频稳定性治理体系建设一:Tailor 原理及实践](https://mp.weixin.qq.com/s/DWOQ9MSTkKSCBFQjPswPIQ)


## Support
1.[GitHub issues](https://github.com/bytedance/tailor/issues)上交流
2. 邮件: <a href="mailto:[email protected]">[email protected]</a>
3. 微信: 429013449
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ buildscript {
}

dependencies {
classpath 'com.novoda:bintray-release:0.9.2'
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}

allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
3 changes: 2 additions & 1 deletion demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
api project(":library")
// api project(":library")
implementation 'com.github.bytedance:tailor:1.0.8'
implementation 'com.android.support:appcompat-v7:28.0.0'
}
15 changes: 3 additions & 12 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'
apply plugin: 'com.github.dcendents.android-maven'

android {
compileSdkVersion 28

defaultConfig {
minSdkVersion 14
targetSdkVersion 28

externalNativeBuild {
cmake {
cppFlags "-fvisibility=hidden"
abiFilters 'armeabi-v7a', 'arm64-v8a'
arguments "-DANDROID_ARM_MODE=arm", "-DANDROID_STL=c++_shared"
cppFlags "-fvisibility=hidden"
}
}
}
Expand All @@ -24,20 +23,12 @@ android {
}
}

ndkVersion "21.4.7075529"
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
}
}

publish {
userOrg = 'shentianzhou'
groupId = 'com.bytedance.tailor'
artifactId = 'library'
publishVersion = '1.0.8'
desc = 'Tailor release'
website = 'https://github.com/bytedance/tailor'
}
}

dependencies {
Expand Down

0 comments on commit f1a28f4

Please sign in to comment.