Commit 2ebb2c4d authored by 汪林玲's avatar 汪林玲

更新

parent 082e1fd5
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.umeng.crash.plugin.umeng_crash_example"> package="com.umeng.crash.plugin.umeng_crash_example">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application <application
android:name=".myApp" android:name=".myApp"
android:label="umeng_crash_example" android:label="umeng_crash_example"
......
...@@ -27,9 +27,6 @@ class _MyAppState extends State<MyApp> { ...@@ -27,9 +27,6 @@ class _MyAppState extends State<MyApp> {
platformVersion = 'Failed to get platform version.'; platformVersion = 'Failed to get platform version.';
} }
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return; if (!mounted) return;
setState(() { setState(() {
...@@ -44,9 +41,17 @@ class _MyAppState extends State<MyApp> { ...@@ -44,9 +41,17 @@ class _MyAppState extends State<MyApp> {
appBar: AppBar( appBar: AppBar(
title: const Text('Plugin example app'), title: const Text('Plugin example app'),
), ),
body: Center( body:Column(children: [
child: Text('Running on: $_platformVersion\n'), TextButton(child:Text('onKillProcess'),onPressed:(){
), UmengCrash.onKillProcess();
},),
TextButton(child:Text('AssertionError'),onPressed:(){
throw AssertionError();
},),
TextButton(child:Text('FormatException'),onPressed:(){
throw FormatException("message");
},)
],),
), ),
); );
} }
......
...@@ -7,14 +7,14 @@ class GlobalSettings { ...@@ -7,14 +7,14 @@ class GlobalSettings {
/// ///
/// 发布渠道如小米、华为、等 /// 发布渠道如小米、华为、等
/// ///
static const APP_CHANNEL = String.fromEnvironment('APP_CHANNEL'); static const APP_CHANNEL = String.fromEnvironment('APP_CHANNEL',defaultValue:'test');
static const UMENG_APPKEY = String.fromEnvironment('UMENG_APPKEY'); static const UMENG_APPKEY = '6130b199695f794bbd9cb984';
GlobalSettings._(); GlobalSettings._();
static Future<Null> init() async { static Future<Null> init() async {
///初始化 ///初始化
UmengCrash.preInit(appKey: UMENG_APPKEY, channel: APP_CHANNEL).whenComplete( UmengCrash.preInit(appKey: UMENG_APPKEY, channel: APP_CHANNEL).whenComplete(
() => UmengCrash.init(appKey: UMENG_APPKEY, channel: APP_CHANNEL)); () => Future.delayed(Duration(seconds:5),()=>UmengCrash.init(appKey: UMENG_APPKEY, channel: APP_CHANNEL)));
} }
} }
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:umeng_crash/umeng_crash.dart';
import 'dart:async'; import 'dart:async';
import 'app.dart'; import 'app.dart';
import 'global_settings.dart'; import 'global_settings.dart';
...@@ -15,6 +16,7 @@ void handleError(void body) { ...@@ -15,6 +16,7 @@ void handleError(void body) {
// debug时,直接将异常信息打印。 // debug时,直接将异常信息打印。
FlutterError.dumpErrorToConsole(details); FlutterError.dumpErrorToConsole(details);
} }
UmengCrash.generateCustomLog(e:'${details.exception}', type: '${details.stack}');
}; };
/// 使用runZonedGuarded捕获Flutter未捕获的异常 /// 使用runZonedGuarded捕获Flutter未捕获的异常
...@@ -30,6 +32,7 @@ void handleError(void body) { ...@@ -30,6 +32,7 @@ void handleError(void body) {
} }
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized();
await GlobalSettings.init(); await GlobalSettings.init();
handleError(runApp(MyApp())); handleError(runApp(MyApp()));
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment