【问题标题】:android:exported="true" not working and not letting flutter app be installed in phoneandroid:exported="true" 不工作并且不允许在手机中安装颤振应用程序
【发布时间】:2022-07-29 20:09:17
【问题描述】:

我正在用 Flutter 开发一个应用程序。它曾经工作正常,我一直在安装它,在手机上使用它 2 个月。今天突然,当我运行这个命令flutter run时出现以下错误。

adb: failed to install D: \Flutter BLE May 2022\ SW_Mobile_Platform\ build\ app\ outputs\ flutter - apk\ app.apk: Failure[INSTALL_PARSE_FAILED_MANIFEST_MALFORMED:
    Failed parse during installPackageLI: /data/app / vmdl116305539.tmp / base.apk(at Binary XML file line #187):
org.altbeacon.beacon.startup.StartupBroadcastReceiver: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when
intent filters are present]

我已经在我的活动清单中添加了android:exported="true"。这是我的Manifest 文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ble_app_flutter">

    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
    <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.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

    <uses-feature
        android:name="android.hardware.bluetooth.le"
        android:required="true" />
    <application
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
        android:label="ble_app_flutter"
        android:usesCleartextTraffic="true">
        <activity
            android:name=".BLEActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:exported="true"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
                android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme" />
            <meta-data
                android:name="io.flutter.embedding.android.SplashScreenDrawable"
                android:resource="@drawable/launch_background" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

【问题讨论】:

    标签: android flutter dart


    【解决方案1】:

    您只需更新 altbeacon 库。就像你说的,你确实需要显式声明 Exported 属性,但是在 lib 中,在广播接收器的启动时,制作 lib 的开发人员没有指定它:

    来自处理该错误的 github 提交:

    https://github.com/AltBeacon/android-beacon-library/commit/a61d049d05fb425a1078646221aa6b619aa80350

    【讨论】:

      猜你喜欢
      • 2020-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多