Reputation: 490
I'm making an app using Android Studio v0.5.9, which has a library project as a dependency. But, every time I run the project two apks having the same name and icon, are deployed to my device. The first apk(app) contains my main module, whereas, the second one is the library project itself. However, when I run the same project from Eclipse, only one apk is deployed and it works perfectly.
Here are some screenshots of the problem -
First App(My module) -
Second App(library project) -
top-level build.gradle
file -
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
}
}
main module build.gradle
file -
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
packageName 'com.Swap.Rooms'
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.android.support:appcompat-v7:19.+'
compile project(':lib')
}
library project build.gradle
file -
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
packageName "com.jfeinstein.jazzyviewpager"
minSdkVersion 4
targetSdkVersion 17
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile files('libs/nineoldandroids-2.4.0.jar')
}
settings.gradle
-
include ':app'
include ':lib'
Please help me to fix this. Thanks in advance!!
Upvotes: 3
Views: 6289
Reputation: 916
It took me time to realize where the issue was.But finaly worked out for me.
The issue is with the Manifest.xml
file. It means that you have two activities set as LAUNCHER
.
just remove the code simmilar to the one below from the activity that is not your LAUNCHER
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Upvotes: 3
Reputation: 2634
The specific element in the ApplicationManifest.xml, that affects creating multiple launcher icons is the <intent-filter>
containing <category android:name="android.intent.category.LAUNCHER"/>
. Removing this <intent-filter>
will give you control over the number of launcher icons. You can read a bit more elaborate SO answer here.
Upvotes: 5
Reputation: 1178
Eugen Martynov answer is correct but i decided to reiterate what he said in layman's terms.
Go through your libraries and check their AndroidManifest.xml
. One of them should have an <application>
tag in it. Remove the tag and the double app problem will be solved.
Upvotes: 6
Reputation: 20130
Maybe this will be helpful for others.
Gradle is doing manifest merge for library projects as well. So issue was to keep AndroidManifes.xml
unchanged from library. It had application
node for demo purposes and this node was successfully merged to main AndroidManifest.xml
.
I'm going to submit issue to Google since I think it should prevent or warn about such situation.
Upvotes: 7