Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
umeng-crash
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
flutter-plugin
umeng-crash
Commits
2ebb2c4d
Commit
2ebb2c4d
authored
Sep 08, 2021
by
汪林玲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
082e1fd5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
9 deletions
+23
-9
example/android/app/src/main/AndroidManifest.xml
example/android/app/src/main/AndroidManifest.xml
+6
-0
example/lib/app.dart
example/lib/app.dart
+11
-6
example/lib/global_settings.dart
example/lib/global_settings.dart
+3
-3
example/lib/main.dart
example/lib/main.dart
+3
-0
No files found.
example/android/app/src/main/AndroidManifest.xml
View file @
2ebb2c4d
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
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
android:name=
".myApp"
android:label=
"umeng_crash_example"
...
...
example/lib/app.dart
View file @
2ebb2c4d
...
...
@@ -27,9 +27,6 @@ class _MyAppState extends State<MyApp> {
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
;
setState
(()
{
...
...
@@ -44,9 +41,17 @@ class _MyAppState extends State<MyApp> {
appBar:
AppBar
(
title:
const
Text
(
'Plugin example app'
),
),
body:
Center
(
child:
Text
(
'Running on:
$_platformVersion
\n
'
),
),
body:
Column
(
children:
[
TextButton
(
child:
Text
(
'onKillProcess'
),
onPressed:
(){
UmengCrash
.
onKillProcess
();
},),
TextButton
(
child:
Text
(
'AssertionError'
),
onPressed:
(){
throw
AssertionError
();
},),
TextButton
(
child:
Text
(
'FormatException'
),
onPressed:
(){
throw
FormatException
(
"message"
);
},)
],),
),
);
}
...
...
example/lib/global_settings.dart
View file @
2ebb2c4d
...
...
@@ -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
.
_
();
static
Future
<
Null
>
init
()
async
{
///初始化
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
)
));
}
}
example/lib/main.dart
View file @
2ebb2c4d
import
'package:flutter/material.dart'
;
import
'package:umeng_crash/umeng_crash.dart'
;
import
'dart:async'
;
import
'app.dart'
;
import
'global_settings.dart'
;
...
...
@@ -15,6 +16,7 @@ void handleError(void body) {
// debug时,直接将异常信息打印。
FlutterError
.
dumpErrorToConsole
(
details
);
}
UmengCrash
.
generateCustomLog
(
e:
'
${details.exception}
'
,
type:
'
${details.stack}
'
);
};
/// 使用runZonedGuarded捕获Flutter未捕获的异常
...
...
@@ -30,6 +32,7 @@ void handleError(void body) {
}
void
main
(
)
async
{
WidgetsFlutterBinding
.
ensureInitialized
();
await
GlobalSettings
.
init
();
handleError
(
runApp
(
MyApp
()));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment