You've already forked CC-Framework.CrashReport
init project
This commit is contained in:
9
Assets/CHANGELOG.md
Normal file
9
Assets/CHANGELOG.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# [1.0.0]
|
||||
|
||||
基础版本.
|
||||
|
||||
# [1.0.1]
|
||||
|
||||
### 修复
|
||||
|
||||
* 优化package.json文件
|
||||
7
Assets/CHANGELOG.md.meta
Normal file
7
Assets/CHANGELOG.md.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fca4353ab66a48e4ebe5032dc5057c7a
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Editor.meta
Normal file
8
Assets/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38a208b96bc4bfe45a74e6f2433f520b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Editor/CarshEditor.asmdef
Normal file
14
Assets/Editor/CarshEditor.asmdef
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "CarshEditor",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Assets/Editor/CarshEditor.asmdef.meta
Normal file
7
Assets/Editor/CarshEditor.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eefc1e2f6ea9bd341bb892303ac533ff
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
219
Assets/Editor/CrashPostProcessBuildAndroid.cs
Normal file
219
Assets/Editor/CrashPostProcessBuildAndroid.cs
Normal file
@@ -0,0 +1,219 @@
|
||||
#if UNITY_ANDROID && UNITY_2018_2_OR_NEWER
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Android;
|
||||
|
||||
namespace Editor
|
||||
{
|
||||
public class CrashPostProcessBuildAndroid : IPostGenerateGradleAndroidProject
|
||||
{
|
||||
private static readonly XNamespace AndroidNamespace = "http://schemas.android.com/apk/res/android";
|
||||
private static readonly XNamespace ToolsNamespace = "http://schemas.android.com/tools";
|
||||
private static readonly string networkConfigXml = "network_security_config";
|
||||
|
||||
public int callbackOrder { get; }
|
||||
|
||||
public void OnPostGenerateGradleAndroidProject (string path)
|
||||
{
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
var manifestPath = Path.Combine (path, "src/main/AndroidManifest.xml");
|
||||
var launcherManifestPath = Path.Combine (path, "../launcher/src/main/AndroidManifest.xml");
|
||||
#else
|
||||
var manifestPath = Path.Combine(path, "unityLibrary/src/main/AndroidManifest.xml");
|
||||
#endif
|
||||
// var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml");
|
||||
XDocument manifest;
|
||||
XDocument launcherManifest;
|
||||
try
|
||||
{
|
||||
manifest = XDocument.Load (manifestPath);
|
||||
launcherManifest = XDocument.Load (launcherManifestPath);
|
||||
}
|
||||
#pragma warning disable 0168
|
||||
catch (IOException exception)
|
||||
#pragma warning restore 0168
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get the `manifest` element.
|
||||
var elementManifest = manifest.Element ("manifest");
|
||||
if (elementManifest == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var elementApplication = elementManifest.Element ("application");
|
||||
if (elementApplication == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//增加必要权限
|
||||
AddPermission ("android.permission.INTERNET" , elementManifest);
|
||||
AddPermission ("android.permission.ACCESS_NETWORK_STATE" , elementManifest);
|
||||
AddPermission ("android.permission.ACCESS_WIFI_STATE" , elementManifest);
|
||||
AddPermission ("android.permission.READ_PHONE_STATE" , elementManifest);
|
||||
AddPermission ("android.permission.READ_LOGS" , elementManifest);
|
||||
manifest.Save (manifestPath);
|
||||
launcherManifest.Save (launcherManifestPath);
|
||||
processNetworkConfigXml (path);
|
||||
}
|
||||
|
||||
public static void AddPermission (string permission , XElement manifest)
|
||||
{
|
||||
var metaData = new XElement ("uses-permission");
|
||||
metaData.Add (new XAttribute (AndroidNamespace + "name", permission));
|
||||
|
||||
//判断是否已经添加过了
|
||||
var isExist = manifest.Descendants ().Any (element =>
|
||||
element.Name.LocalName.Equals ("uses-permission") && element.Attribute (AndroidNamespace + "name")!.Value.Equals (permission));
|
||||
|
||||
if (!isExist)
|
||||
{
|
||||
manifest.Add (metaData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void processNetworkConfigXml (string path)
|
||||
{
|
||||
// bool isChina = true;
|
||||
//在application标签加上:android:networkSecurityConfig="@xml/network_security_config"
|
||||
var hasAdd = addNetworkSecurityConfigInApplication (path);
|
||||
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
var resXmlPath = Path.Combine (path, "src/main/res/xml");
|
||||
#else
|
||||
var resXmlPath = Path.Combine(path, "unityLibrary/src/main/res/xml");
|
||||
#endif
|
||||
|
||||
var rexXmlDir = Path.Combine (resXmlPath, $"{networkConfigXml}.xml");
|
||||
if (File.Exists (rexXmlDir) || !hasAdd)
|
||||
{
|
||||
// FileUtil.DeleteFileOrDirectory (rexXmlDir);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!Directory.Exists (resXmlPath))
|
||||
{
|
||||
Directory.CreateDirectory (resXmlPath);
|
||||
}
|
||||
|
||||
// var fromScriptableObject = MonoScript.FromScriptableObject(this);
|
||||
var xmlPath = GetScriptsPath (nameof(CrashPostProcessBuildAndroid));
|
||||
saveFile ($"{xmlPath}/{networkConfigXml}.xml", resXmlPath);
|
||||
}
|
||||
|
||||
public static void saveFile (string filePathName , string toFilesPath)
|
||||
{
|
||||
FileInfo file = new FileInfo (filePathName);
|
||||
string newFileName = file.Name;
|
||||
file.CopyTo (toFilesPath + "/" + newFileName, true);
|
||||
}
|
||||
|
||||
public static string GetScriptsPath (string scriptName)
|
||||
{
|
||||
string[] path = UnityEditor.AssetDatabase.FindAssets (scriptName);
|
||||
if (path.Length > 1)
|
||||
{
|
||||
// Debug.LogError("有同名文件"+_scriptName+"获取路径失败");
|
||||
return null;
|
||||
}
|
||||
|
||||
//将字符串中得脚本名字和后缀统统去除掉
|
||||
string _path = AssetDatabase.GUIDToAssetPath (path[0]).Replace ((@"/" + scriptName + ".cs"), "");
|
||||
return _path;
|
||||
}
|
||||
|
||||
private static bool addNetworkSecurityConfigInApplication (string path)
|
||||
{
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
var manifestPath = Path.Combine (path, "src/main/AndroidManifest.xml");
|
||||
#else
|
||||
var manifestPath = Path.Combine(path, "unityLibrary/src/main/AndroidManifest.xml");
|
||||
#endif
|
||||
// var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml");
|
||||
XDocument manifest;
|
||||
try
|
||||
{
|
||||
manifest = XDocument.Load (manifestPath);
|
||||
}
|
||||
#pragma warning disable 0168
|
||||
catch (IOException exception)
|
||||
#pragma warning restore 0168
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the `manifest` element.
|
||||
var elementManifest = manifest.Element ("manifest");
|
||||
if (elementManifest == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var elementApplication = elementManifest.Element ("application");
|
||||
if (elementApplication == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//这个设置主要是为了适配9.0以上的机器
|
||||
//<uses-library android:name="org.apache.http.legacy" android:required="false" />
|
||||
var usesLibraryElements = elementApplication.Descendants ().Where (element => element.Name.LocalName.Equals ("uses-library"));
|
||||
XElement httpLegacyElement = GetElementByName (usesLibraryElements, "org.apache.http.legacy");
|
||||
if (httpLegacyElement == null)
|
||||
{
|
||||
elementApplication.Add (createHttpLegacyElement ());
|
||||
}
|
||||
manifest.Save (manifestPath);
|
||||
|
||||
//handle anythink_network_security_config.xml
|
||||
XAttribute networkConfigAttribute = elementApplication.Attribute (AndroidNamespace + "networkSecurityConfig");
|
||||
if (networkConfigAttribute == null)
|
||||
{
|
||||
// networkConfigAttribute.Remove ();
|
||||
elementApplication.Add (new XAttribute (AndroidNamespace + "networkSecurityConfig", $"@xml/{networkConfigXml}"));
|
||||
manifest.Save (manifestPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static XElement createHttpLegacyElement ()
|
||||
{
|
||||
var httpFeautre = new XElement ("uses-library");
|
||||
httpFeautre.Add (new XAttribute (AndroidNamespace + "name", "org.apache.http.legacy"));
|
||||
httpFeautre.Add (new XAttribute (AndroidNamespace + "required", "false"));
|
||||
|
||||
return httpFeautre;
|
||||
}
|
||||
|
||||
private static XElement GetElementByName (IEnumerable<XElement> elements, string name)
|
||||
{
|
||||
foreach (var element in elements)
|
||||
{
|
||||
var attributes = element.Attributes ();
|
||||
if (attributes.Any (attribute => attribute.Name.Namespace.Equals (AndroidNamespace)
|
||||
&& attribute.Name.LocalName.Equals ("name")
|
||||
&& attribute.Value.Equals (name)))
|
||||
{
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
3
Assets/Editor/CrashPostProcessBuildAndroid.cs.meta
Normal file
3
Assets/Editor/CrashPostProcessBuildAndroid.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f18dedb872e45c2a275c42c9f7f9e90
|
||||
timeCreated: 1712028515
|
||||
7
Assets/Editor/network_security_config.xml
Normal file
7
Assets/Editor/network_security_config.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="true" />
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="true">android.bugly.qq.com</domain>
|
||||
</domain-config>
|
||||
</network-security-config>
|
||||
7
Assets/Editor/network_security_config.xml.meta
Normal file
7
Assets/Editor/network_security_config.xml.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8eb860204d25d2499b4051b35d3ab74
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins.meta
Normal file
8
Assets/Plugins.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09f8e7a6d04765546a4f225a1499b330
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
5
Assets/Plugins/BuglyPlugins.meta
Normal file
5
Assets/Plugins/BuglyPlugins.meta
Normal file
@@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5cef439187fbb41ab879da2b95ac4291
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
5
Assets/Plugins/BuglyPlugins/Android.meta
Normal file
5
Assets/Plugins/BuglyPlugins/Android.meta
Normal file
@@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 694411f45e4e64facb88eebfc2e1df1c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
8
Assets/Plugins/BuglyPlugins/Android/libs.meta
Normal file
8
Assets/Plugins/BuglyPlugins/Android/libs.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab0e0a3ff5e56d2488ab6a3b23fd3b61
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb7b442d8e32443e5856838741007f70
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/BuglyPlugins/Android/libs/armeabi-v7a/libBugly.so
Normal file
BIN
Assets/Plugins/BuglyPlugins/Android/libs/armeabi-v7a/libBugly.so
Normal file
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 432060a129574479db0cfd441cdf3d69
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/BuglyPlugins/Android/libs/armeabi.meta
Normal file
8
Assets/Plugins/BuglyPlugins/Android/libs/armeabi.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 594eacd11ce124d4eaafa7da7b0960e1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/BuglyPlugins/Android/libs/armeabi/libBugly.so
Normal file
BIN
Assets/Plugins/BuglyPlugins/Android/libs/armeabi/libBugly.so
Normal file
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b1ab29305b192b4a9e5b8d68cb54fd3
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/BuglyPlugins/Android/libs/bugly-4.1.9.2.aar
Normal file
BIN
Assets/Plugins/BuglyPlugins/Android/libs/bugly-4.1.9.2.aar
Normal file
Binary file not shown.
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0781c6de80d1d3c4daba0010f99c1ded
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/BuglyPlugins/Android/libs/buglyagent.jar
Normal file
BIN
Assets/Plugins/BuglyPlugins/Android/libs/buglyagent.jar
Normal file
Binary file not shown.
32
Assets/Plugins/BuglyPlugins/Android/libs/buglyagent.jar.meta
Normal file
32
Assets/Plugins/BuglyPlugins/Android/libs/buglyagent.jar.meta
Normal file
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1db231dca0f72420cb880590f799d7d5
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Plugins/BuglyPlugins/Android/libs/x86.meta
Normal file
9
Assets/Plugins/BuglyPlugins/Android/libs/x86.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79531ba82725e4071861c982307805c3
|
||||
folderAsset: yes
|
||||
timeCreated: 1443426231
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/BuglyPlugins/Android/libs/x86/libBugly.so
Normal file
BIN
Assets/Plugins/BuglyPlugins/Android/libs/x86/libBugly.so
Normal file
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16eaf0ec67588418783d6f5311aa71ce
|
||||
timeCreated: 1497948394
|
||||
licenseType: Free
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
platformData:
|
||||
Android:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Runtime.meta
Normal file
8
Assets/Runtime.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5a0b159cecc51c4998c390006eee498
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1080
Assets/Runtime/BuglyAgent.cs
Normal file
1080
Assets/Runtime/BuglyAgent.cs
Normal file
File diff suppressed because it is too large
Load Diff
8
Assets/Runtime/BuglyAgent.cs.meta
Normal file
8
Assets/Runtime/BuglyAgent.cs.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be621fe31508b4f2ab134ee879ec97b4
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
27
Assets/Runtime/BuglyCallback.cs
Normal file
27
Assets/Runtime/BuglyCallback.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
// ----------------------------------------
|
||||
//
|
||||
// BuglyCallbackDelegate.cs
|
||||
//
|
||||
// Author:
|
||||
// Yeelik, <bugly@tencent.com>
|
||||
//
|
||||
// Copyright (c) 2015 Bugly, Tencent. All rights reserved.
|
||||
//
|
||||
// ----------------------------------------
|
||||
//
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public abstract class BuglyCallback
|
||||
{
|
||||
// The delegate of callback handler which Call the Application.RegisterLogCallback(Application.LogCallback)
|
||||
/// <summary>
|
||||
/// Raises the application log callback handler event.
|
||||
/// </summary>
|
||||
/// <param name="condition">Condition.</param>
|
||||
/// <param name="stackTrace">Stack trace.</param>
|
||||
/// <param name="type">Type.</param>
|
||||
public abstract void OnApplicationLogCallbackHandler (string condition, string stackTrace, LogType type);
|
||||
|
||||
}
|
||||
|
||||
8
Assets/Runtime/BuglyCallback.cs.meta
Normal file
8
Assets/Runtime/BuglyCallback.cs.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78e76f643d1884dcab602d5fe79b08e1
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
80
Assets/Runtime/BuglyInit.cs
Normal file
80
Assets/Runtime/BuglyInit.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
// ----------------------------------------
|
||||
//
|
||||
// BuglyInit.cs
|
||||
//
|
||||
// Author:
|
||||
// Yeelik, <bugly@tencent.com>
|
||||
//
|
||||
// Copyright (c) 2015 Bugly, Tencent. All rights reserved.
|
||||
//
|
||||
// ----------------------------------------
|
||||
//
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class BuglyInit : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Your Bugly App ID. Every app has a special identifier that allows Bugly to associate error monitoring data with your app.
|
||||
/// Your App ID can be found on the "Setting" page of the app you are trying to monitor.
|
||||
/// </summary>
|
||||
/// <example>A real App ID looks like this: 90000xxxx</example>
|
||||
private const string BuglyAppID = "YOUR APP ID GOES HERE";
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
// Enable the debug log print
|
||||
BuglyAgent.ConfigDebugMode (false);
|
||||
// Config default channel, version, user
|
||||
BuglyAgent.ConfigDefault (null, null, null, 0);
|
||||
// Config auto report log level, default is LogSeverity.LogError, so the LogError, LogException log will auto report
|
||||
BuglyAgent.ConfigAutoReportLogLevel (LogSeverity.LogError);
|
||||
// Config auto quit the application make sure only the first one c# exception log will be report, please don't set TRUE if you do not known what are you doing.
|
||||
BuglyAgent.ConfigAutoQuitApplication (false);
|
||||
// If you need register Application.RegisterLogCallback(LogCallback), you can replace it with this method to make sure your function is ok.
|
||||
BuglyAgent.RegisterLogCallback (null);
|
||||
|
||||
// Init the bugly sdk and enable the c# exception handler.
|
||||
BuglyAgent.InitWithAppId (BuglyAppID);
|
||||
|
||||
// TODO Required. If you do not need call 'InitWithAppId(string)' to initialize the sdk(may be you has initialized the sdk it associated Android or iOS project),
|
||||
// please call this method to enable c# exception handler only.
|
||||
BuglyAgent.EnableExceptionHandler ();
|
||||
|
||||
// TODO NOT Required. If you need to report extra data with exception, you can set the extra handler
|
||||
BuglyAgent.SetLogCallbackExtrasHandler (MyLogCallbackExtrasHandler);
|
||||
|
||||
Destroy (this);
|
||||
}
|
||||
|
||||
// Extra data handler to packet data and report them with exception.
|
||||
// Please do not do hard work in this handler
|
||||
static Dictionary<string, string> MyLogCallbackExtrasHandler ()
|
||||
{
|
||||
// TODO Test log, please do not copy it
|
||||
BuglyAgent.PrintLog (LogSeverity.Log, "extra handler");
|
||||
|
||||
// TODO Sample code, please do not copy it
|
||||
Dictionary<string, string> extras = new Dictionary<string, string> ();
|
||||
extras.Add ("ScreenSolution", string.Format ("{0}x{1}", Screen.width, Screen.height));
|
||||
extras.Add ("deviceModel", SystemInfo.deviceModel);
|
||||
extras.Add ("deviceName", SystemInfo.deviceName);
|
||||
extras.Add ("deviceType", SystemInfo.deviceType.ToString ());
|
||||
|
||||
extras.Add ("deviceUId", SystemInfo.deviceUniqueIdentifier);
|
||||
extras.Add ("gDId", string.Format ("{0}", SystemInfo.graphicsDeviceID));
|
||||
extras.Add ("gDName", SystemInfo.graphicsDeviceName);
|
||||
extras.Add ("gDVdr", SystemInfo.graphicsDeviceVendor);
|
||||
extras.Add ("gDVer", SystemInfo.graphicsDeviceVersion);
|
||||
extras.Add ("gDVdrID", string.Format ("{0}", SystemInfo.graphicsDeviceVendorID));
|
||||
|
||||
extras.Add ("graphicsMemorySize", string.Format ("{0}", SystemInfo.graphicsMemorySize));
|
||||
extras.Add ("systemMemorySize", string.Format ("{0}", SystemInfo.systemMemorySize));
|
||||
extras.Add ("UnityVersion", Application.unityVersion);
|
||||
|
||||
BuglyAgent.PrintLog (LogSeverity.LogInfo, "Package extra data");
|
||||
return extras;
|
||||
}
|
||||
}
|
||||
|
||||
8
Assets/Runtime/BuglyInit.cs.meta
Normal file
8
Assets/Runtime/BuglyInit.cs.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a717f6955eddf4463ad541714a1b5483
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
91
Assets/Runtime/CrashConfig.cs
Normal file
91
Assets/Runtime/CrashConfig.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Runtime
|
||||
{
|
||||
[CreateAssetMenu (menuName = "CrashConfig")]
|
||||
public class CrashConfig : ScriptableObject
|
||||
{
|
||||
private const string BuglyGUID = "BuglyGUID";
|
||||
|
||||
[SerializeField] private string BuglyAppID;
|
||||
[SerializeField] private string BuglyChannel;
|
||||
[SerializeField] private bool HasDebugMode;
|
||||
[SerializeField] private bool EnableCrashReport;
|
||||
public event Action<string, string, LogType> LogCallbackEvent;
|
||||
public bool HasInit => this._hasInit;
|
||||
|
||||
private bool _hasInit;
|
||||
private static CrashConfig _instance;
|
||||
|
||||
private static CrashConfig Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = Resources.Load<CrashConfig> (nameof(CrashConfig));
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = CreateInstance<CrashConfig> ();
|
||||
// 自定义资源保存路径
|
||||
string path = "Assets/Resources";
|
||||
//如果项目总不包含该路径,创建一个
|
||||
if (!Directory.Exists (path))
|
||||
{
|
||||
Directory.CreateDirectory (path);
|
||||
}
|
||||
UnityEditor.AssetDatabase.CreateAsset (_instance, path + $"/{nameof(CrashConfig)}.asset");
|
||||
UnityEditor.AssetDatabase.Refresh ();
|
||||
}
|
||||
#endif
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
[RuntimeInitializeOnLoadMethod (RuntimeInitializeLoadType.AfterSceneLoad)]
|
||||
private static void OnEnableCrashReport ()
|
||||
{
|
||||
if (Instance != null && Instance.EnableCrashReport)
|
||||
{
|
||||
Instance.InitCrash ();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitCrash ()
|
||||
{
|
||||
if (this._hasInit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this._hasInit = true;
|
||||
var buglyGuid = PlayerPrefs.HasKey (BuglyGUID) ? PlayerPrefs.GetString (BuglyGUID) : Guid.NewGuid ().ToString ();
|
||||
PlayerPrefs.SetString (BuglyGUID, buglyGuid);
|
||||
|
||||
// 开启SDK的日志打印,发布版本请务必关闭
|
||||
if (this.HasDebugMode)
|
||||
{
|
||||
BuglyAgent.ConfigDebugMode (true);
|
||||
}
|
||||
|
||||
// 注册日志回调,替换使用 'Application.RegisterLogCallback(Application.LogCallback)'注册日志回调的方式
|
||||
BuglyAgent.RegisterLogCallback (OnLogCallBack);
|
||||
|
||||
BuglyAgent.ConfigDefault (this.BuglyChannel, Application.version , buglyGuid , 0);
|
||||
|
||||
BuglyAgent.InitWithAppId (this.BuglyAppID);
|
||||
|
||||
// 如果你确认已在对应的iOS工程或Android工程中初始化SDK,那么在脚本中只需启动C#异常捕获上报功能即可
|
||||
BuglyAgent.EnableExceptionHandler ();
|
||||
}
|
||||
|
||||
private void OnLogCallBack (string condition, string stacktrace, LogType type)
|
||||
{
|
||||
this.LogCallbackEvent?.Invoke (condition, stacktrace, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Runtime/CrashConfig.cs.meta
Normal file
3
Assets/Runtime/CrashConfig.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 629b16a8ebee41a2b7e74748deb97933
|
||||
timeCreated: 1712026840
|
||||
3
Assets/Runtime/CrashRuntime.asmdef
Normal file
3
Assets/Runtime/CrashRuntime.asmdef
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "CrashRuntime"
|
||||
}
|
||||
7
Assets/Runtime/CrashRuntime.asmdef.meta
Normal file
7
Assets/Runtime/CrashRuntime.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65e2e7312783df74897ad85f7b1afc1c
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scenes.meta
Normal file
8
Assets/Scenes.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 131a6b21c8605f84396be9f6751fb6e3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1035
Assets/Scenes/SampleScene.unity
Normal file
1035
Assets/Scenes/SampleScene.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Scenes/SampleScene.unity.meta
Normal file
7
Assets/Scenes/SampleScene.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cda990e2423bbf4892e6590ba056729
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/Scenes/SampleTest.cs
Normal file
33
Assets/Scenes/SampleTest.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Diagnostics;
|
||||
|
||||
public class SampleTest : MonoBehaviour
|
||||
{
|
||||
|
||||
public void Test1 ()
|
||||
{
|
||||
// //获取Unity的Activity Class
|
||||
// using (var activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
||||
// {
|
||||
// //获取对应的实例化对象,这两句都是固定写法
|
||||
// using (var activityContext = activityClass.GetStatic<AndroidJavaObject>("currentActivity"))
|
||||
// {
|
||||
// activityContext.Call ("Test1");
|
||||
// }
|
||||
// }
|
||||
// UnityEngine.Diagnostics.Utils.NativeAssert ("测试原生断言");
|
||||
UnityEngine.Diagnostics.Utils.ForceCrash (ForcedCrashCategory.AccessViolation);
|
||||
}
|
||||
|
||||
public void Test2 ()
|
||||
{
|
||||
BuglyAgent.ReportException ("测试2" , "测试异常" , "测试异常信息 ");
|
||||
}
|
||||
|
||||
public void Test3 ()
|
||||
{
|
||||
BuglyAgent.ReportException ("测试3" , "测试异常" , "测试异常信息 ");
|
||||
}
|
||||
}
|
||||
11
Assets/Scenes/SampleTest.cs.meta
Normal file
11
Assets/Scenes/SampleTest.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c675d2e692371d4c96ff83aac4144ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Assets/package.json
Normal file
23
Assets/package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "com.foldcc.cc-framework.crashreport",
|
||||
"displayName": "CC-Framework.CrashReport",
|
||||
"description": "Crash检测, 异常上报",
|
||||
"version": "1.0.0",
|
||||
"unity": "2022.1",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://private.lightyears.ltd:18640/foldcc/CC-Framework.CrashReport"
|
||||
},
|
||||
"author": {
|
||||
"name": "foldcc",
|
||||
"email": "lhyuau@qq.com",
|
||||
"url": "https://gitee.com/foldcc"
|
||||
},
|
||||
"dependencies":
|
||||
{
|
||||
},
|
||||
"keywords": [
|
||||
"Framework"
|
||||
]
|
||||
}
|
||||
7
Assets/package.json.meta
Normal file
7
Assets/package.json.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bdc75239432ff3458a7b98e29519e6d
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user