raj kavadia
raj kavadia

Reputation: 1053

Two apps installed with same package name

I am having a project in android studio in which I have only 1 package and while generating signed apk or debugging the app it installs 2 apk files, both are opening the same apk. I am not sure where the problem is. Can I get some suggestions?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.myapplication">
<uses-permission
    android:name="android.permission.INSTALL_LOCATION_PROVIDER"
    tools:ignore="ProtectedPermissions" />
<application
    android:name="androidx.multidex.MultiDexApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:hardwareAccelerated="true"
    android:screenOrientation="portrait"
    android:supportsRtl="true"
    android:testOnly="false"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true"
    tools:ignore="GoogleAppIndexingWarning,HardcodedDebugMode"
    tools:targetApi="m">
    <activity android:name="com.example.myapplication.Activity.ImageViewer" />
    <activity
        android:name="com.example.myapplication.Fragments.LeadManagement.ProcessingLeadUpdate"
        android:theme="@style/AppTheme.NoActionBar" >
    </activity>
    <activity
        android:name="com.example.myapplication.Activity.Splash"
        android:configChanges="orientation|screenSize|keyboardHidden"
        android:noHistory="false"
        android:theme="@style/AppTheme.NoActionBar"
        android:usesCleartextTraffic="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.myapplication.Activity.MainActivity"
        android:configChanges="orientation|screenSize|keyboardHidden"
        android:label="@string/app_name"
        android:noHistory="false"
        android:theme="@style/AppTheme.NoActionBar"
        android:usesCleartextTraffic="true"
        android:windowSoftInputMode="adjustResize" />
    <activity
        android:name="com.schibstedspain.leku.LocationPickerActivity"
        android:label="@string/leku_title_activity_location_picker"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar"
        android:windowSoftInputMode="adjustPan">
        <meta-data
            android:name="android.app.searchable"
            android:resource="@xml/leku_searchable" />
    </activity>
</application>

I think the problem is in the manifest file, so I am posting the manifest file here. the build.gradle file in app level

apply plugin: 'com.android.application'

android {
compileSdkVersion 28

configurations {
    all {
        exclude module: 'httpclient'
        exclude module: 'json'
        exclude group: 'org.apache.httpcomponents'
    }
}
defaultConfig {
    applicationId "com.example.myapplication"
    minSdkVersion 17
    targetSdkVersion 28
    multiDexEnabled true
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

buildTypes {
    release {
        proguardFiles getDefaultProguardFile('proguard-android- 
optimize.txt'), 'proguard-rules.pro'
        debuggable false
    }
}
compileOptions {
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha05'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha06'
implementation 'com.fasterxml.jackson.core:jackson-core:2.9.8'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.8'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
implementation 'com.squareup.okhttp3:okhttp:3.14.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
implementation 'com.goebl:david-webb:1.3.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.airbnb.android:lottie:3.0.0'
implementation 'com.github.aliumujib:Nibo:2.0'
implementation 'com.google.guava:guava:27.1-android'
implementation 'androidx.fragment:fragment:1.0.0'
implementation('com.schibstedspain.android:leku:6.1.1') {
    exclude group: 'com.google.android.gms'
    exclude group: 'androidx.appcompat'
}
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-places:16.1.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.maps.android:android-maps-utils:0.5'
implementation 'com.github.prabhat1707:EasyWayLocation:1.0'
implementation 'com.ryanjeffreybrooks:indefinitepagerindicator:1.0.10'
implementation 'androidx.viewpager:viewpager:1.0.0'
implementation 'com.github.sharish:ShimmerRecyclerView:v1.3'
implementation 'com.facebook.shimmer:shimmer:0.4.0'
implementation 'com.github.developer-shivam:Crescento:1.2.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'com.camerakit:camerakit:1.0.0-beta3.11'
implementation 'com.camerakit:jpegkit:0.1.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31'
implementation 'com.github.PauloLinhares09:RetroPicker:1.2.3-Beta1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'
implementation 'com.jsibbold:zoomage:1.2.0'
implementation 'id.zelory:compressor:2.1.0'
compile 'com.github.hkk595:Resizer:v1.5'

}

Upvotes: 2

Views: 2432

Answers (3)

Daniel Cettour
Daniel Cettour

Reputation: 304

In my case, in my AndroidManifest I had the following line twice:

<action android:name="android.intent.action.MAIN" />

Just make sure you have it only once:

    <activity
        android:name=".activity.SplashActivity"
        android:exported="true"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" /> // this line shouldn't be repeated in the AndroidManifest file
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Upvotes: 0

If you are using customized SplashScreen, check into the AndroidManifest.xml file located on android\app\src\main\AndroidManifest.xml and look for the intent-filter tag like this:

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Certifies that you have only one statement of the preview snippet of code, preferably in the .SplashActivity statement, like this:

<activity
    android:name=".SplashActivity"
    android:theme="@style/SplashScreenTheme"
    android:label="@string/app_name"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

and your .MainActivity don't need to have intent-filter inside and will be like:

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
    android:launchMode="singleTask"
    android:windowSoftInputMode="adjustResize"
    android:exported="true">
    <!-- ! DON'T ENNABLE the intent-filter tag here in the same time with .SplashActivity
     to avoid duplicated app installation -->
    <!-- <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter> -->
</activity>

Upvotes: 0

Deˣ
Deˣ

Reputation: 4371

It feels like your application is picking up activity from some library.

  1. Open the AndroidManifest file. click on Merged Manifest tab (in the bottom of the IDE).
  2. Search for Activity having LAUNCHER intent-filter.
  3. If there is any LAUNCHER Activity other than yours, that is the culprit.
  4. You can modify or update your library AndroidManifest file and remove the activity from the launcher. If that library is not your own and you can't update the AndroidManifest file, you should try some other library.

Here it go, now create your signed build or debug, you will have only one launcher icon.

Upvotes: 7

Related Questions