Running app gives 2 app icons in Android Studio

后端 未结 6 1489
挽巷
挽巷 2020-12-28 12:13

I am running an app in Android Studio and it gives 2 app icons in Androi Studio.

Also, I have moved from Eclipse to Android Studio and now I\'m having trouble with h

相关标签:
6条回答
  • 2020-12-28 12:33

    The <intent-filter> that affects creating multiple launcher icon is the following one:

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

    Android Studio's manifest merger will always combine <intent-filter>s in library projects into main project's manifest. You may end up having multiple LAUNCHER intents in your synthesized manifest, thus having multiple launcher icons. To avoid this, simply remove the LAUNCHER intents from the library projects' manifest.

    0 讨论(0)
  • 2020-12-28 12:36

    There is most likely an imported Library project that has this intent filter.

    1. Open your app manifest
    2. At the bottom left click on "Merged Manifest"
    3. Search and find which library project has the attribute
    
          <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
          </intent-filter>
    4. Remove it and ensure that now the filter is only on your App's <Application >class activity.
    
    0 讨论(0)
  • 2020-12-28 12:45

    I got it! yes at last , i have to study gradles and stuff.

    Actually I have 2 android projects inside the Project, one is a library and the other one is the main app.

    I found out that when i imported those projects Android Studio (I exported the lib to gradle build from eclipse) doesn't care if that is a lib project or a main project. (Correct me if im wrong ).

    so the only thing to make it work is to remove the intent-filter of that lib-android-project.

    EDIT: @all solved it ! thanks to everyone, I never knew there was another AndroidManifest.xml , i thought eclipse removed it. and i thought Exporting it to gradle will remove it because it is checked as a library.

    thanks for all your help.

    0 讨论(0)
  • 2020-12-28 12:45

    When running android and doing debug, there is an another AndroidManifest.xml under src/debug. Make sure this manifest file matches the main one under src/main.

    0 讨论(0)
  • 2020-12-28 12:50

    i agree, since i made 2 activity(one for splash, one for main). In manifest i forgot to delete

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

    so in the end when i install app, i will have 2 app.

    0 讨论(0)
  • 2020-12-28 12:52

    You declare two intent filter, used only one Intent filter in the activity, on AndroidManifest.

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

    If you used two or more intent filter in AndroidManifest, then you will have two app icon, So remove it & set one intent filter.

    I hove this is usedful to you.

    0 讨论(0)
提交回复
热议问题