美文网首页
Flutter flutter_bugly 接入详解

Flutter flutter_bugly 接入详解

作者: StevenHu_Sir | 来源:发表于2019-10-10 09:57 被阅读0次

1.导入依赖

# 异常上报
flutter_bugly: ^0.2.7

2.项目配置

在android/app/build.gradle的android下加入

defaultConfig {
        ndk {
            //设置支持的SO库架构
            abiFilters 'armeabi-v7a'//, 'arm64-v8a', 'x86', 'x86_64'
        }
    }

3.AndroidX 配置报错 路径 android/app/src/main/AndroidManifest.xml

报错描述:The Gradle failure may have been because of AndroidX incompatibiliti

报错里有提示在manifest里加tools:replace="android:authorities"和android:resource,记得在最外层加上xmlns:tools="http://schemas.android.com/tools"

改动后的最新的manifest

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.fenpeiduixiang.www">

    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

    <!-- 录音 -->
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!-- 录音 -->

    <!-- gio -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <!-- gio -->

    <!--相机📷-->
    <uses-permission android:name="android.permission.CAMERA"/>
    <!-- 这个权限用于进行网络定位 -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <!-- 这个权限用于访问GPS定位 -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>



    <application
        android:name=".MyApplication"
        android:label="分配对象"
        android:icon="@mipmap/launcher_icon">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>

            <intent-filter>
                <data android:scheme="growing.6e39e77220bacd04"/>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>

        </activity>

        <!-- 高德 -->
        <meta-data android:name="com.amap.api.v2.apikey" android:value="75b97cdfc82e48ffe87736db04138011"> </meta-data>
        <!-- 高德 -->

        <!-- flutter_qq -->
        <activity
            android:name="com.tencent.connect.common.AssistActivity"
            android:configChanges="orientation|keyboardHidden"
            android:screenOrientation="behind"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <activity
            android:name="com.tencent.tauth.AuthActivity"
            android:launchMode="singleTask"
            android:noHistory="true" >
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="1108025070" />
            </intent-filter>
        </activity>
        <!-- flutter_qq -->

        <!-- cropper -->
        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
        <!-- cropper -->


        <uses-library android:name="org.apache.http.legacy" android:required="false" />

        <provider
            android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
            android:authorities="${applicationId}.flutter_downloader.provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileProvider"
            android:exported="false"
            android:grantUriPermissions="true"
            tools:replace="android:authorities">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/filepaths"
                tools:replace="android:resource" />
        </provider>
    </application>
</manifest>

4、使用

import 'package:flutter_bugly/flutter_bugly.dart';
//使用flutter异常上报
void main()=>FlutterBugly.postCatchedException((){
  runApp(MyApp());
});
FlutterBugly.init(androidAppId: "your android app id",iOSAppId: "your iOS app id");

5.release打包(Android)

64-bit

flutter build apk --release --target-platform android-arm64

32-bit(目前配合armeabi-v7a可以打出32位64位通用包)

flutter build apk --release --target-platform android-arm

相关文章

网友评论

      本文标题:Flutter flutter_bugly 接入详解

      本文链接:https://www.haomeiwen.com/subject/izlopctx.html