对我来说,添加 android:exported="true" 并不能解决问题

MH-*_*ani 6 android manifest gradle kotlin android-studio

看到这个问题从主屏幕快捷方式启动时,应用程序未安装错误

AndroidManifest.xml:

<application
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/Theme.AppTheme">
        <activity
                android:name=".ui.activity.MainActivity"
                android:screenOrientation="fullSensor"
                android:label="@string/app_name"
                android:exported="true"
                android:configChanges="orientation|screenSize">
            <intent-filter
                    >
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter
                    >
                <action android:name="android.intent.action.VIEW"/>
                <data android:scheme="app" android:host="appname"
                />
                <category android:name="android.intent.category.BROWSABLE"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
            <nav-graph android:value="@navigation/nav_graph_main"
                    />
        </activity>
</application>
Run Code Online (Sandbox Code Playgroud)

摇篮[应用程序]:

defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 19
        targetSdkVersion 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

> Task :app:processDebugMainManifest FAILED
/home/mhrohani/IdeaProjects/PrjName/app/src/main/AndroidManifest.xml Error:
    android:exported needs to be explicitly specified for <receiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
/home/mhrohani/IdeaProjects/PrjName/app/src/main/AndroidManifest.xml Error:
    android:exported needs to be explicitly specified for <receiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


Execution failed for task ':app:processDebugMainManifest'.
Run Code Online (Sandbox Code Playgroud)

项目和 android studio 配置:

Gradle :                 ** 7.1.1 **  
Android Gradle Plugin :  ** 7.0.0 **  
Android Studio Version : ** Arctic fox 2020.3.1 **  
OS :                     ** Linux Ubuntu **
Run Code Online (Sandbox Code Playgroud)

我正在尝试重建和同步项目,但不起作用。

b4h*_*r4m 2

请注意错误文本

android:exported 需要为接收者显式指定

这意味着您必须在主/依赖项清单中查找接收器,如果您在主清单上找到此标签,则必须添加android:exported的值,如果您在主清单中找不到接收器标签,那么您应该在其他依赖项清单中搜索,我将逐步向您展示

1-在 Android Studio 上打开清单文件

2-在底部单击合并清单

3-按顺序打开所有依赖项清单并查找不包含android:exported 的依赖项清单

4-我确信会找到这个标签,找到它后只需复制整个标签并将其添加到主清单中,不要忘记添加android:exported的值到它

例子:

依赖项清单文件之一内的接收者标记:

<receiver
        android:name="com.moduletop.push.UserPresentBroadcastReceiver"
        android:enabled="false" >
        <intent-filter>
            <action android:name="android.intent.action.USER_PRESENT" />
        </intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)

在主清单中添加此标签:

<receiver
        tools:node="merge"
        android:exported="false"
        android:name="com.moduletop.push.UserPresentBroadcastReceiver"
        android:enabled="false" >
        <intent-filter>
            <action android:name="android.intent.action.USER_PRESENT" />
        </intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)