flutter 面向Android 12及更高版本的应用需要为“android:exported”指定显式值

uinbv5nw  于 2022-11-25  发布在  Flutter
关注(0)|答案(1)|浏览(250)

`

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.core_project"
    xmlns:tools="http://schemas.android.com/tools"
    >
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

    <application
        android:name=".Application"
        android:label="My App"
        android:icon="@mipmap/ic_launcher"
        android:usesCleartextTraffic="true"
        tools:replace="allowBackup"
        android:allowBackup="false"
        android:requestLegacyExternalStorage="true">
        

        <meta-data
            android:name="io.flutter.embedding.android.SplashScreenDrawable"
            android:resource="@drawable/launch_background"/>
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/ic_default_tray" />
        <meta-data 
            android:name="com.google.firebase.messaging.default_notification_color" 
            android:resource="@color/colorIconNotificationTray" />

        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <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>

        <!-- Begin FlutterDownloader customization -->
        <!-- disable default Initializer -->
        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="${applicationId}.androidx-startup"
            android:exported="false"
            tools:node="merge">
            <meta-data
                android:name="androidx.work.WorkManagerInitializer"
                android:value="androidx.startup"
                tools:node="remove" />
        </provider>

        <!-- declare customized Initializer -->
        <provider
            android:name="vn.hunghd.flutterdownloader.FlutterDownloaderInitializer"
            android:authorities="${applicationId}.flutter-downloader-init"
            android:exported="false">
            <meta-data
                android:name="vn.hunghd.flutterdownloader.MAX_CONCURRENT_TASKS"
                android:value="5" />
        </provider>

        <activity
            android:screenOrientation="portrait"
            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"
            android:exported="true"
            >
            
            <meta-data
                android:name="com.google.firebase.messaging.default_notification_channel_id"
                android:value="channel id"/>
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
             <meta-data
            android:name="com.google.firebase.ml.vision.DEPENDENCIES"
            android:value="barcode" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

              <!-- Branch URI Scheme -->
            <intent-filter>
                <data android:scheme="mydestiny" android:host="open" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>

            <!-- Branch App Links -->
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="https" android:host="mydestiny.app.link" />
                <!-- example-alternate domain is required for App Links when the Journeys/Web SDK and Deepviews are used inside your website.  -->
                <data android:scheme="https" android:host="mydestiny-alternate.app.link" />
            </intent-filter>
        </activity>
         <!-- Branch init -->
        <meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_XXXXXXXXXXXXXXXXXXXXXXXXXX" />
        <meta-data android:name="io.branch.sdk.BranchKey.test" android:value="secret_live_XXXXXXXXXXXXXXXXXXXXXXXXXX" />
        <meta-data android:name="io.branch.sdk.TestMode" android:value="false" /> 
    </application>
</manifest>

我的build. gradle(:app)文件:

defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.core_project"
        minSdkVersion 23
        targetSdkVersion 31
        versionCode 1
        versionName "1.0."
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

显示的错误
执行任务":app:processDebugMainManifest"失败。 Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value forandroid:exportedwhen the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
我知道该如何解决此问题吗?
有什么想法我可以解决这个问题吗?我已经添加android:exported ="true"

a14dhokn

a14dhokn1#

在您的AndroidManifest.xml中,将第一个共享文件android:exported="true"添加到您的activity中的application
例如如下:

<activity
    android:name=".MainActivity"
    android:exported="true"

相关问题