dingjia_li
dingjia_li

Reputation: 21

Two same icons for one application after run

I am developing an Automotive OS Media app, but for my project, I always get two same icons on my emulator after running. Since my project is an Automotive OS app, there is no android.intent.action.MAIN and android.intent.category.LAUNCHER - I mean, there is no duplicates of them to cause my problem.

My project has two modules - one is Automotive application, another one is Media Service Library (named common). Below are AndroidManifest.xml and build.gradle files for two parts.

AndroidManifest.xml (automotive)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.automotivemusic">

    <uses-feature
        android:name="android.hardware.type.automotive"
        android:required="true" />

    <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.AppCompat">

        <activity android:name=".SignInActivity">
            <intent-filter>
                <action android:name="android.intent.action.ACTION_SIGN_IN" />
            </intent-filter>
        </activity>

        <service
            android:name=".AutomotiveMusicService"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="android.media.browse.MediaBrowserService"/>
            </intent-filter>
        </service>

    </application>

</manifest>

build.gradle (automotive)

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 29

    defaultConfig {
        applicationId "com.example.automotivemusic"
        minSdkVersion 28
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation project(path: ':common')
    implementation 'androidx.media:media:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.1.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

AndroidManifest.xml (common)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.common">

    <application>
        <service
            android:name="com.example.common.MusicService"
            android:exported="true">
            <intent-filter>
                <action android:name="android.media.browse.MediaBrowserService" />
            </intent-filter>
        </service>
    </application>

</manifest>

build.gradle (common)

plugins {
    id 'com.android.library'
}

android {
    compileSdkVersion 29

    defaultConfig {
        minSdkVersion 28
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'androidx.media:media:1.1.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Upvotes: 2

Views: 335

Answers (1)

A-run
A-run

Reputation: 490

Android automotive platform is showing two icons because your application has two MediaBrowserService(AutomotiveMusicService and MusicService).

The automotive platform scans for Media application installed in the platform based on intent-filter"android.media.browse.MediaBrowserService", hence two icons.

Upvotes: 2

Related Questions