运行应用程序在 Android Studio 中提供 2 个应用程序图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25763896/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Running app gives 2 app icons in Android Studio
提问by david
I am running an app in Android Studio and it gives 2 app icons in Androi Studio.
我在 Android Studio 中运行一个应用程序,它在 Androi Studio 中提供了 2 个应用程序图标。
Also, I have moved from Eclipse to Android Studio and now I'm having trouble with how to make the color of logcat same as in Eclipse.
另外,我已经从 Eclipse 转移到了 Android Studio,现在我在如何使 logcat 的颜色与 Eclipse 中相同时遇到了麻烦。
My question is that there are 2 app icons when I run the app, and when I uninstall it, 2 of them have been removed. Is that normal in Android Studio? I have found that Android Studio can copy keys from Eclipse.
我的问题是当我运行应用程序时有 2 个应用程序图标,当我卸载它时,其中 2 个已被删除。这在 Android Studio 中正常吗?我发现 Android Studio 可以从 Eclipse 复制密钥。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mytrack.ph"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- Google Map v.2 permissions -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- GCM permissions -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.example.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
<!-- Writing Persmission -->
<uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" />
<uses-permission android:name="android.permission.WRITE_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.READ_CONTACT"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity android:name="com.mytrack.ph.SplashActivity"
android:label="@string/app_name"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@style/splashScreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.mytrack.ph.LoginActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/google_map_api_key"/>
<activity android:name="com.facebook.LoginActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
<service android:name="com.my.track.service.MyTrackService"></service>
<receiver
android:name="com.my.track.service.MyTrackGcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.my.track.service" />
</intent-filter>
</receiver>
<service android:name="com.my.track.service.MyTrackGcmIntentService" />
<activity android:name="NavigationMenuActivity"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:permission="com.google.android.c2dm.permission.SEND" >
></activity>
<receiver android:name="com.my.track.results.ConnectionChangeReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
</receiver>
</application>
</manifest>
I though this is normal in android studio. Running an app gives 2 launcher icons. PS:
我虽然这在android studio中很正常。运行应用程序会提供 2 个启动器图标。PS:
my AndroidManifest.xml
is inside mainfolder and I used eclipse to export to gradle build.
我AndroidManifest.xml
在主文件夹中,我使用 eclipse 导出到 gradle build。
Im using Android Studio 0.8.6 thanks.
我使用 Android Studio 0.8.6 谢谢。
回答by david
I got it! yes at last , i have to study gradles and stuff.
我知道了!是的,最后,我必须学习 gradles 之类的东西。
Actually I have 2 android projects inside the Project, one is a library and the other one is the main app.
实际上我在项目中有 2 个 android 项目,一个是库,另一个是主应用程序。
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 ).
我发现当我导入这些项目时,Android Studio(我从 eclipse 将 lib 导出到 gradle build)并不关心这是一个 lib 项目还是一个主项目。(如果我错了纠正我 )。
so the only thing to make it work is to remove the intent-filter
of that lib-android-project.
所以让它工作的唯一方法是删除intent-filter
那个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.
编辑:@all 解决了它!感谢大家,我从来不知道还有另一个 AndroidManifest.xml ,我以为 eclipse 删除了它。我认为将它导出到 gradle 会删除它,因为它被检查为一个库。
thanks for all your help.
感谢你的帮助。
回答by Kita
The <intent-filter>
that affects creating multiple launcher icon is the following one:
该<intent-filter>
影响创建多个启动器图标是下列操作之一:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
Android Studio's manifest mergerwill 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.
Android Studio 的manifest 合并将始终将<intent-filter>
库项目中的 s合并到主项目的 manifest 中。您最终可能会LAUNCHER
在合成清单中拥有多个意图,从而拥有多个启动器图标。为避免这种情况,只需LAUNCHER
从库项目的清单中删除意图。
回答by vicky mahale
You declare two intent filter, used only one Intent filter in the activity, on AndroidManifest.
您在 AndroidManifest 上声明了两个 Intent 过滤器,在活动中仅使用了一个 Intent 过滤器。
<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.
如果您在 AndroidManifest 中使用了两个或多个 Intent 过滤器,那么您将有两个应用程序图标,因此将其删除并设置一个 Intent 过滤器。
I hove this is usedful to you.
我希望这对你有用。
回答by Rio Cat
i agree, since i made 2 activity(one for splash, one for main). In manifest i forgot to delete
我同意,因为我做了 2 个活动(一个用于飞溅,一个用于主要)。在清单中我忘了删除
<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.
所以最后当我安装应用程序时,我会有 2 个应用程序。
回答by Sugoi Reed
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.
回答by Souverain Premier
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.
在运行android并进行调试时,src/debug下还有一个AndroidManifest.xml。确保此清单文件与 src/main 下的主要清单文件匹配。