【发布时间】:2022-01-17 05:33:53
【问题描述】:
我在 Android Studio 中创建了一个简单的 Hello World 项目,作为 Jenkins 管道中的示例,它可以工作,但我想添加 SonarQube 分析,因此我在 build.gradle 中添加了后续行,如文档所示 (https://plugins.gradle.org/plugin/org.sonarqube)
buildscript {
repositories {
google()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: "org.sonarqube"
task clean(type: Delete) {
delete rootProject.buildDir
}
我可以毫无问题地使用./gradle build 构建,但是当我执行./gradlew sonarqube 时出现以下错误:
android:exported needs to be explicitly specified for <activity>. 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
我调查并检查了我的/app/src/main/AndroidManifest.xml 中是否有android:exported="true or false",并且确实如此。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.holapromad">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HolaPromad">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
是错误还是什么?谢谢
【问题讨论】:
标签: android-studio gradle sonarqube