Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hi-bugly
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蒋俊
hi-bugly
Commits
c00cb0fe
提交
c00cb0fe
authored
3月 11, 2024
作者:
jiangjun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加 bugly 初始化方法
上级
ae0ded9e
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
138 行增加
和
33 行删除
+138
-33
build.gradle
android/build.gradle
+9
-0
HiBuglyPlugin.java
...oid/src/main/java/com/example/hi_bugly/HiBuglyPlugin.java
+43
-22
AndroidManifest.xml
example/android/app/src/main/AndroidManifest.xml
+3
-0
Debug.xcconfig
example/ios/Flutter/Debug.xcconfig
+1
-0
Release.xcconfig
example/ios/Flutter/Release.xcconfig
+1
-0
Podfile
example/ios/Podfile
+38
-0
main.dart
example/lib/main.dart
+12
-4
hi_bugly.dart
lib/hi_bugly.dart
+10
-1
hi_bugly_method_channel.dart
lib/hi_bugly_method_channel.dart
+13
-3
hi_bugly_platform_interface.dart
lib/hi_bugly_platform_interface.dart
+4
-1
hi_bugly_test.dart
test/hi_bugly_test.dart
+4
-2
没有找到文件。
android/build.gradle
浏览文件 @
c00cb0fe
...
...
@@ -31,5 +31,13 @@ android {
defaultConfig
{
minSdkVersion
16
ndk
{
// 设置支持的SO库架构
abiFilters
'armeabi'
//, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
}
}
}
dependencies
{
implementation
'com.tencent.bugly:crashreport:4.1.9.2'
}
\ No newline at end of file
android/src/main/java/com/example/hi_bugly/HiBuglyPlugin.java
浏览文件 @
c00cb0fe
...
...
@@ -2,37 +2,58 @@ package com.example.hi_bugly;
import
androidx.annotation.NonNull
;
import
com.tencent.bugly.crashreport.CrashReport
;
import
io.flutter.embedding.engine.plugins.FlutterPlugin
;
import
io.flutter.plugin.common.MethodCall
;
import
io.flutter.plugin.common.MethodChannel
;
import
io.flutter.plugin.common.MethodChannel.MethodCallHandler
;
import
io.flutter.plugin.common.MethodChannel.Result
;
/** HiBuglyPlugin */
/**
* HiBuglyPlugin
*/
public
class
HiBuglyPlugin
implements
FlutterPlugin
,
MethodCallHandler
{
/// The MethodChannel that will the communication between Flutter and native Android
///
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
/// when the Flutter Engine is detached from the Activity
private
MethodChannel
channel
;
/// The MethodChannel that will the communication between Flutter and native Android
///
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
/// when the Flutter Engine is detached from the Activity
private
MethodChannel
channel
;
private
FlutterPluginBinding
flutterPluginBinding
;
@Override
public
void
onAttachedToEngine
(
@NonNull
FlutterPluginBinding
flutterPluginBinding
)
{
channel
=
new
MethodChannel
(
flutterPluginBinding
.
getBinaryMessenger
(),
"hi_bugly"
);
channel
.
setMethodCallHandler
(
this
);
}
@Override
public
void
onAttachedToEngine
(
@NonNull
FlutterPluginBinding
flutterPluginBinding
)
{
this
.
flutterPluginBinding
=
flutterPluginBinding
;
channel
=
new
MethodChannel
(
flutterPluginBinding
.
getBinaryMessenger
(),
"hi_bugly"
);
channel
.
setMethodCallHandler
(
this
);
}
@Override
public
void
onMethodCall
(
@NonNull
MethodCall
call
,
@NonNull
Result
result
)
{
if
(
call
.
method
.
equals
(
"getPlatformVersion"
))
{
result
.
success
(
"Android "
+
android
.
os
.
Build
.
VERSION
.
RELEASE
);
}
else
{
result
.
notImplemented
();
@Override
public
void
onMethodCall
(
@NonNull
MethodCall
call
,
@NonNull
Result
result
)
{
switch
(
call
.
method
)
{
case
"getPlatformVersion"
:
result
.
success
(
"Android "
+
android
.
os
.
Build
.
VERSION
.
RELEASE
);
break
;
case
"initialize"
:
String
appID
=
""
;
boolean
debug
=
false
;
if
(
call
.
hasArgument
(
"appID"
))
{
appID
=
call
.
argument
(
"appID"
);
}
if
(
call
.
hasArgument
(
"debug"
))
{
debug
=
Boolean
.
TRUE
.
equals
(
call
.
argument
(
"debug"
));
}
CrashReport
.
initCrashReport
(
flutterPluginBinding
.
getApplicationContext
(),
appID
,
debug
);
result
.
success
(
true
);
break
;
default
:
result
.
notImplemented
();
break
;
}
}
}
@Override
public
void
onDetachedFromEngine
(
@NonNull
FlutterPluginBinding
binding
)
{
channel
.
setMethodCallHandler
(
null
);
}
@Override
public
void
onDetachedFromEngine
(
@NonNull
FlutterPluginBinding
binding
)
{
channel
.
setMethodCallHandler
(
null
);
}
}
example/android/app/src/main/AndroidManifest.xml
浏览文件 @
c00cb0fe
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.example.hi_bugly_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"
/>
<application
android:label=
"hi_bugly_example"
android:name=
"${applicationName}"
...
...
example/ios/Flutter/Debug.xcconfig
浏览文件 @
c00cb0fe
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
example/ios/Flutter/Release.xcconfig
浏览文件 @
c00cb0fe
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
example/ios/Podfile
0 → 100644
浏览文件 @
c00cb0fe
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV
[
'COCOAPODS_DISABLE_STATS'
]
=
'true'
project
'Runner'
,
{
'Debug'
=>
:debug
,
'Profile'
=>
:release
,
'Release'
=>
:release
,
}
def
flutter_root
generated_xcode_build_settings_path
=
File
.
expand_path
(
File
.
join
(
'..'
,
'Flutter'
,
'Generated.xcconfig'
),
__FILE__
)
unless
File
.
exist?
(
generated_xcode_build_settings_path
)
raise
"
#{
generated_xcode_build_settings_path
}
must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File
.
foreach
(
generated_xcode_build_settings_path
)
do
|
line
|
matches
=
line
.
match
(
/FLUTTER_ROOT\=(.*)/
)
return
matches
[
1
].
strip
if
matches
end
raise
"FLUTTER_ROOT not found in
#{
generated_xcode_build_settings_path
}
. Try deleting Generated.xcconfig, then run flutter pub get"
end
require
File
.
expand_path
(
File
.
join
(
'packages'
,
'flutter_tools'
,
'bin'
,
'podhelper'
),
flutter_root
)
flutter_ios_podfile_setup
target
'Runner'
do
flutter_install_all_ios_pods
File
.
dirname
(
File
.
realpath
(
__FILE__
))
end
post_install
do
|
installer
|
installer
.
pods_project
.
targets
.
each
do
|
target
|
flutter_additional_ios_build_settings
(
target
)
end
end
example/lib/main.dart
浏览文件 @
c00cb0fe
...
...
@@ -31,8 +31,8 @@ class _MyAppState extends State<MyApp> {
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try
{
platformVersion
=
await
_hiBuglyPlugin
.
getPlatformVersion
()
??
'Unknown platform version'
;
platformVersion
=
await
_hiBuglyPlugin
.
getPlatformVersion
()
??
'Unknown platform version'
;
}
on
PlatformException
{
platformVersion
=
'Failed to get platform version.'
;
}
...
...
@@ -54,8 +54,16 @@ class _MyAppState extends State<MyApp> {
appBar:
AppBar
(
title:
const
Text
(
'Plugin example app'
),
),
body:
Center
(
child:
Text
(
'Running on:
$_platformVersion
\n
'
),
body:
Column
(
children:
[
Text
(
'Running on:
$_platformVersion
\n
'
),
MaterialButton
(
onPressed:
()
{
_hiBuglyPlugin
.
initialize
(
appID:
'123456'
,
debug:
true
);
},
child:
const
Text
(
'初始化'
),
),
],
),
),
);
...
...
lib/hi_bugly.dart
浏览文件 @
c00cb0fe
import
'hi_bugly_platform_interface.dart'
;
class
HiBugly
{
Future
<
String
?>
getPlatformVersion
()
{
return
HiBuglyPlatform
.
instance
.
getPlatformVersion
();
}
Future
<
bool
?>
initialize
({
required
String
appID
,
bool
debug
=
false
,
})
{
return
HiBuglyPlatform
.
instance
.
initialize
(
appID:
appID
,
debug:
debug
,
);
}
}
lib/hi_bugly_method_channel.dart
浏览文件 @
c00cb0fe
...
...
@@ -11,12 +11,22 @@ class MethodChannelHiBugly extends HiBuglyPlatform {
@override
Future
<
String
?>
getPlatformVersion
()
async
{
final
version
=
await
methodChannel
.
invokeMethod
<
String
>(
'getPlatformVersion'
);
final
version
=
await
methodChannel
.
invokeMethod
<
String
>(
'getPlatformVersion'
);
return
version
;
}
@override
Future
<
bool
?>
initialize
()
async
{
return
await
methodChannel
.
invokeMethod
(
'initialize'
);
Future
<
bool
?>
initialize
({
required
String
appID
,
bool
debug
=
false
,
})
async
{
return
await
methodChannel
.
invokeMethod
(
'initialize'
,
{
'appID'
:
appID
,
'debug'
:
debug
,
},
);
}
}
lib/hi_bugly_platform_interface.dart
浏览文件 @
c00cb0fe
...
...
@@ -27,7 +27,10 @@ abstract class HiBuglyPlatform extends PlatformInterface {
throw
UnimplementedError
(
'platformVersion() has not been implemented.'
);
}
Future
<
bool
?>
initialize
()
{
Future
<
bool
?>
initialize
({
required
String
appID
,
bool
debug
=
false
,
})
{
throw
UnimplementedError
(
'initialize() has not been implemented.'
);
}
}
test/hi_bugly_test.dart
浏览文件 @
c00cb0fe
...
...
@@ -7,12 +7,14 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart';
class
MockHiBuglyPlatform
with
MockPlatformInterfaceMixin
implements
HiBuglyPlatform
{
@override
Future
<
String
?>
getPlatformVersion
()
=>
Future
.
value
(
'42'
);
@override
Future
<
bool
?>
initialize
()
{
Future
<
bool
?>
initialize
({
required
appID
,
bool
debug
=
false
,
})
{
// TODO: implement initialize
throw
UnimplementedError
();
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论