Tencent /mars
Mars is a cross-platform network component developed by WeChat.
★ 17,667⑂ 3,689👁 761⑃ 253● 1,125▤ 6
+1
日增长
17,667
stars
3,689
forks
761
watchers
253
prs
1,125
issues
6
releases
README
Mars

(中文版本请参看这里)
Mars is a cross-platform infrastructure component developed by WeChat Mobile Team.
It has been proved to be effective by billions of WeChat users.
1. Cross platform, easy to deploy if you are developing multi-platform or multi-business application.
2. Suitable for small amount data transmission
3. Mobile platform friendly, low power and traffic consumption
4. A network solution fit for mobile application
!mars
comm: common library, including socket, thread, message queue, coroutine, etc.
Xlog: a reliable log component with high-performance.
SDT: a network detection component.
STN: a signaling network component, the major part of Mars.
Samples
Start with sample usage here.
Getting started
python scripts only support python3.10 or higher
Choose Android or iOS/OS X or Windows.
Android
You can use either mars-wrapper or mars-core. We recommend you to use mars-wrapper when you just want to build a sample or demo, while mars-core is preferred to be used in your APP.
mars-wrapper
Add dependencies by adding the following lines to your app/build.gradle.
xml
dependencies {
compile 'com.tencent.mars:mars-wrapper:1.2.5'
}
OR
mars-core
Add dependencies by adding the following lines to your app/build.gradle.
xml
dependencies {
compile 'com.tencent.mars:mars-core:1.2.5'
}
OR
mars-xlog
If you just want to user xlog, add dependencies by adding the following lines to your app/build.gradle.
note: xlog is included in mars-core and mars-wrapper.
xml
dependencies {
compile 'com.tencent.mars:mars-xlog:1.2.5'
}
If you read here, make sure you have added dependencies of mars-wrapper, mars-core or mars-xlog.
Xlog Init
Initialize Xlog when your APP starts. Remember to use an exclusive folder to save the log files, no other files are acceptable in the folder since they would be removed by the cleansing function in Xlog automatically.
When multiple processes is used in your app, make sure that each process owns its exclusive log file.
java
System.loadLibrary("c++_shared");
System.loadLibrary("marsxlog");
final String SDCARD = Environment.getExternalStorageDirectory().getAbsolutePath();
final String logPath = SDCARD + "/marssample/log";
// this is necessary, or may crash for SIGBUS
final String cachePath = this.getFilesDir() + "/xlog"
//init xlog
Xlog xlog = new Xlog();
Log.setLogImp(xlog);
if (BuildConfig.DEBUG) {
Log.setConsoleLogOpen(true);
Log.appenderOpen(Xlog.LEVEL_DEBUG, Xlog.AppednerModeAsync, "", logPath, logFileName, 0);
} else {
Log.setConsoleLogOpen(false);
Log.appenderOpen(Xlog.LEVEL_INFO, Xlog.AppednerModeAsync, "", logPath, logFileName, 0);
}
Uninitialized Xlog when your app exits
java
Log.appenderClose();
STN Init
If you add dependencies of mars-core to your project, you need to initialize and release STN.
Initialize Top issues
#1221Xlog 有计划支持鸿蒙吗?有大概的时间节点吗16 comments · 2024-01-31#599mars crash 求解16 comments · 2019-05-06#526最新版本无法编译,求解!ndk版本16b,Python版本2.7.1515 comments · 2019-01-28#833Android mars版本1.2.4 初始化报错闪退14 comments · 2020-08-10#586app为厂商白名单运行在后台的时候,几分钟后就无法建立连接了。但是微信可以14 comments · 2019-04-16#662pthread_detachd调用导致crash13 comments · 2019-07-24#101flowlimit的数值单位问题12 comments · 2017-01-15#828接入新版本报错11 comments · 2020-08-03
Latest release
v1.3.0 v1.3.0 2019-04-011. ndk 升级为 ndk-r16b 编译 2. 构建方案改为 cmake 3. stl 库从 stlport_shared 改为 c++_shared