idea使用android遇到的一些问题

新建项目后注意更改项目结构

image

修改AndroidManifest.xml

Manifest merger failed : 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.错误
在activity后的 android:name 后添加 android:exported = "true"
image
报错的 <action android:name="android.intent.action.MAIN" />不要删除

修改app中的build.gradle配置

将最小的SDK版本修改为当前使用的版本或者以下
image

然后启动,项目就可以正常运行了

使用android11变更

以 Android 11 为目标平台 (目标 API level 为 30) 的应用默认将只能检测到部分过滤后的已安装应用。如果想获取更多别的已安装应用列表信息,则需要在应用内的 Android manifest 中添加 元素,从而拓宽访问范围。

	<manifest package="com.example.game">
  <queries>
   <!-- 声明所要进行交互的应用名 -->
    <package android:name="com.example.store" />
    <package android:name="com.example.service" />

    <!--
        声明要查询的 intents

        例如下列标签声明了一个自定义的分享视图的 intent
    -->

    <intent>
      <action android:name="android.intent.action.SEND" />
      <data android:mimeType="image/jpeg" />
    </intent>

  </queries>

  ...
  
</manifest>

Manifest merger failed with multiple errors, see logs错误
在项目级别的 build.gradle 文件中将相关依赖升级到上图中对应的版本。

dependencies {
        // classpath 'com.android.tools.build:gradle:4.0.0'
        classpath 'com.android.tools.build:gradle:4.0.1'
    }
}
posted @ 2021-09-13 09:04  kokurachiyo  阅读(493)  评论(0)    收藏  举报