Browse Source

添加bugly检测

调味吧台
liup 5 months ago
parent
commit
f817d44ad7
7 changed files with 100 additions and 16 deletions
  1. +12
    -1
      app/build.gradle
  2. +3
    -0
      app/proguard-rules.pro
  3. +53
    -0
      app/src/main/java/com/bonait/bnframework/MainApplication.java
  4. +6
    -6
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java
  5. +2
    -0
      app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java
  6. +23
    -9
      app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml
  7. +1
    -0
      gradle.properties

+ 12
- 1
app/build.gradle View File

@@ -19,6 +19,10 @@ android {
versionName rootProject.ext.versionName
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
multiDexEnabled true
ndk {
// 设置支持的SO库架构
abiFilters 'armeabi' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
}
}
buildTypes {
release {
@@ -129,7 +133,7 @@ dependencies {


//leak 内存泄漏检测
// debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-3'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-3'

//Modbus
implementation 'com.github.licheedev:Modbus4Android:2.0.2'
@@ -170,4 +174,11 @@ dependencies {
implementation 'com.contrarywind:Android-PickerView:3.2.6'

implementation 'com.github.xingshuangs:iot-communication:1.5.0'

//日志工具 可定位代码行数
api 'com.apkfuns.logutils:library:1.7.5'

//腾讯bugly
//sdk地址 https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=1.0.0
implementation 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如4.0.3
}

+ 3
- 0
app/proguard-rules.pro View File

@@ -19,3 +19,6 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-dontwarn com.tencent.bugly.**
-keep public class com.tencent.bugly.**{*;}

+ 53
- 0
app/src/main/java/com/bonait/bnframework/MainApplication.java View File

@@ -7,6 +7,7 @@ import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import android.util.Log;

import androidx.core.content.ContextCompat;
@@ -48,9 +49,13 @@ import com.orhanobut.logger.FormatStrategy;
import com.orhanobut.logger.Logger;
import com.orhanobut.logger.PrettyFormatStrategy;
import com.qmuiteam.qmui.arch.QMUISwipeBackActivityManager;
import com.tencent.bugly.crashreport.CrashReport;

import org.litepal.LitePal;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.IdentityHashMap;
@@ -82,5 +87,53 @@ public class MainApplication extends Application {
context = getApplicationContext();
ConfigName.getInstance().dishesCon = this;
ConfigName.getInstance().app = this;
if(ConfigName.TEST){
initBugly();
}
}

/**
* 腾讯bugly 异常检测上班
*/
public void initBugly() {
Context context = getApplicationContext();
// 获取当前包名
String packageName = context.getPackageName();
// 获取当前进程名
String processName = getProcessName(android.os.Process.myPid());
// 设置是否为上报进程
CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context);
strategy.setUploadProcess(processName == null || processName.equals(packageName));
// 初始化Bugly
CrashReport.initCrashReport(getApplicationContext(), "0ccad7391a", true);
}

/**
* 获取进程号对应的进程名
*
* @param pid 进程号
* @return 进程名
*/
private static String getProcessName(int pid) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader("/proc/" + pid + "/cmdline"));
String processName = reader.readLine();
if (!TextUtils.isEmpty(processName)) {
processName = processName.trim();
}
return processName;
} catch (Throwable throwable) {
throwable.printStackTrace();
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (IOException exception) {
exception.printStackTrace();
}
}
return null;
}
}

+ 6
- 6
app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java View File

@@ -682,9 +682,9 @@ public class MakeGoodFragment extends BaseFragment {
public void run() {
String msg = msg2;

if(ConfigName.TEST){
msg = " |03cb1364-8b85-446a-b00b-d3657de1a19f| | ";
}
// if(ConfigName.TEST){
// msg = " |03cb1364-8b85-446a-b00b-d3657de1a19f| | ";
// }
if ((msg != null) && (((String) msg).length() > 2) && ((String) msg).contains("|")) {
//拿到扫码数据
//例如 ORD001|P0003|A001,M002,T001|2
@@ -728,9 +728,9 @@ public class MakeGoodFragment extends BaseFragment {
}
BPA_GOODS good = QueryDB.GetGoodsforeignKeyId(goodid);
ConfigName.getInstance();
if(ConfigName.TEST){
good = QueryDB.GetGoodsId(goodid);
}
// if(ConfigName.TEST){
// good = QueryDB.GetGoodsId(goodid);
// }
if (good == null) {
message = "没有查询到该商品!";
mHandler.sendEmptyMessage(1);


+ 2
- 0
app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java View File

@@ -51,6 +51,7 @@ import com.mobsandgeeks.saripaar.annotation.NotEmpty;
import com.mobsandgeeks.saripaar.annotation.Order;
import com.mobsandgeeks.saripaar.annotation.Password;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import com.tencent.bugly.crashreport.CrashReport;

import org.litepal.LitePal;

@@ -114,6 +115,7 @@ public class LoginActivity extends BaseActivity implements Validator.ValidationL
initUser();
initEvent();
initData();
CrashReport.testJavaCrash();
}

/**


+ 23
- 9
app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml View File

@@ -135,16 +135,17 @@
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:orientation="vertical">
<Button
android:id="@+id/control_switch_shoudong"
android:layout_width="120dp"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:background="@drawable/silosbuttonbj"
android:text="出料"
android:textColor="@color/white"
android:textSize="18sp"/>
<!-- <Button-->
<!-- android:id="@+id/control_switch_shoudong"-->
<!-- android:layout_width="120dp"-->
<!-- android:layout_height="70dp"-->
<!-- android:layout_centerHorizontal="true"-->
<!-- android:background="@drawable/silosbuttonbj"-->
<!-- android:text="出料"-->
<!-- android:textColor="@color/white"-->
<!-- android:textSize="18sp"/>-->

<Button
android:layout_marginTop="@dimen/dp_10"
@@ -214,6 +215,19 @@
android:textColor="@color/white"
android:textSize="18sp"/>

<Button
android:id="@+id/control_switch_shoudong"
android:layout_marginLeft="10dp"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:background="@drawable/bg"
android:text="出料"
android:visibility="visible"
android:textColor="@color/white"
android:textSize="18sp"/>

</LinearLayout>

<LinearLayout


+ 1
- 0
gradle.properties View File

@@ -13,4 +13,5 @@ org.gradle.jvmargs=-Xmx2048m
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true
android.useDeprecatedNdk=true


Loading…
Cancel
Save