Home » Android » Android project showing up with a duplicate app upon deployment

Android project showing up with a duplicate app upon deployment

Posted by: admin June 15, 2020 Leave a comment

Questions:

My directory structure is as follows:

Project
--libraries
----volley
--myapplication
----libs
------android-support-v4.jar
------etc.jar

Volley is an imported library project. Everything runs fine with the application, but when it’s installed, 2 different apps show up on the android app list with the same name and icon. One of them works as expected, and the other seems to be some empty activity and crashes upon execution with the error:

 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.myapplication/com.libs.volley.ACTIVITY_ENTRY_NAME}: java.lang.ClassNotFoundException: Didn't find class "com.libs.volley.ACTIVITY_ENTRY_NAME" on path: /data/app/com.example.myapplication-1.apk

I’ve tried cleaning and rebuilding and uninstalling from the device itself, to no avail. All I would like to do is to get rid of this extra app.

AndroidManifest.xml

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

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="18" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />

<application
    android:allowBackup="true"
    android:icon="@drawable/app_icon"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.myapplication.MainActivity"
        android:label="@string/app_name" >


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

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
    android:name=".AppConfigActivity"
        android:windowSoftInputMode="stateHidden"
        android:label="Application configuration"/>
    <activity
        android:name=".BoothSelectActivity"
        android:label="Booth Select"/>
    <activity
        android:name=".InactiveActivity"
        android:label="Inactive Activity"/>
    <activity
        android:name=".QRReaderActivity"
        android:windowSoftInputMode="stateHidden"
        android:label="QR Reader Activity"/>
    <activity
        android:name=".ProductsActivity"
        android:windowSoftInputMode="stateHidden"
        android:label="Products Activity"/>

</application>

Any help would be much appreciated.

My build.gradle file

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.1.1"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 18
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile files('libs/commons-codec-1.4.jar')
    compile files('libs/android-async-http-1.4.3.jar')
    compile files('libs/gson-2.2.4.jar')
    compile files('libs/zbar.jar')
    compile project(':libraries:volley')
}

task copyNativeLibs(type: Copy) {
    from(new File('src/main/libs')) { include '**' }
    into new File(buildDir, 'native-libs')
}

tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }

clean.dependsOn 'cleanCopyNativeLibs'

tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
    pkgTask.jniDir new File(buildDir, 'native-libs')
}   

My settings.gradle

include  ':myapplicationname', ':libraries:volley'
How to&Answers:

If an imported library has an Activity that also contains a launcher, it will create another application. To prevent this, make sure no other Activities have the following marks in the AndroidManifest of each project.

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

Answer:

Check on the file Project/.idea/modules.xml and remove the second module you don’t want to show up.

The file should look like this.

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/module2.iml" filepath="$PROJECT_DIR$/module2.iml" />
<module fileurl="file://$PROJECT_DIR$/module1.iml" filepath="$PROJECT_DIR$/module1.iml" />
</modules>
</component>
</project>