Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating to Android Studio will cause multiple apps being installed for "single main project multiple library projects"

I have

  • Single main project which defines <action android:name="android.intent.action.MAIN" /> and <category android:name="android.intent.category.LAUNCHER" />
  • Multiple library projects, with some of them defines <action android:name="android.intent.action.MAIN" /> and <category android:name="android.intent.category.LAUNCHER" />

While I'm using Eclipse to build & run single main project with multiple library projects, only 1 app will be installed.

However, if I migrate to Android Studio to build & run single main project with multiple library projects, multiple apps will be installed,

depending on how many projects (regardless main project or library projects) define <action android:name="android.intent.action.MAIN" /> and <category android:name="android.intent.category.LAUNCHER" />

I was wondering, is there any configuration I had done wrong in Android Studio, which causes multiple app to be installed, when I build & run the projects?

Currently, my only workaround is to remove those lines (<action android:name="android.intent.action.MAIN" /> and <category android:name="android.intent.category.LAUNCHER" />) from all library projects' AndroidManifest.xml. Is that common & correct way, to import project libraries in Android Studio? As in Eclipse, those lines don't install extra apps into my device.

This is how my Project Structure looks like

enter image description here

As you can see the first folder icon, looks different than rest of the folder icons. I guess that indicate, the first folder icon is main project, the others are library projects.

If there is only 1 main project, how come there can be multiple apps being installed?

like image 793
Cheok Yan Cheng Avatar asked Nov 02 '14 07:11

Cheok Yan Cheng


1 Answers

In Eclipse only the AndroidManifest.xml from main app project is used. In Android Studio (and Gradle build system) all the manifests are merged together.

The following lines inside an <activity> element in your manifest indicate that that activity should be shown in the launcher menu. If you do not wish this, remove those lines.

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

All of this is intended behavior.

like image 78
Eugen Pechanec Avatar answered Sep 28 '22 17:09

Eugen Pechanec