'android:exported needs to be explicitly specified after add SonarQube in build.gradle
I created a simple Hello World project in Android Studio as an example in Jenkins pipeline, it works but I want add SonarQube analysis, so I add follow lines in build.gradle as documentation shows (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
}
I can build using ./gradle build
without problems, but when I execute ./gradlew sonarqube
I get following error:
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
I investigated and checked if in my /app/src/main/AndroidManifest.xml
has android:exported="true or false"
and it is.
<?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>
Is a bug or something? Thank you
Solution 1:[1]
Not sure if it's your case too: in my project the issue was caused by the the AndroidTest variant of the Manifest merger task which used a dated version of the androidx.test.ext:junit
library.
Just update this library to the latest version (currently 1.1.3) into my app build.gradle file, solved the issue.
Solution 2:[2]
Go To build.gradle
change your classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.10'
or any version to
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.13.4'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Vasily Kabunov |