eclipse 无法更改Android应用程序的默认图标?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16010313/
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
Can't change the default icon of Android app?
提问by Edwin Alex
I am facing a problem. I have converted a javascript application to Android app by using phonegap, cordova and eclipse. The App works cool.
我正面临一个问题。我已经使用 phonegap、cordova 和 eclipse 将一个 javascript 应用程序转换为 Android 应用程序。该应用程序很酷。
But the problem is, it always displays cordova icon as app icon. I replaced all the icons in the "project/res"
folder. But still it shows the default icon only?
但问题是,它总是将cordova icon显示为 app icon。我替换了"project/res"
文件夹中的所有图标。但它仍然只显示默认图标吗?
I googled it and came to know that i have to change in the manifest file. So, i changed in the AndroidManifest.XML
with the code,
我用谷歌搜索它并知道我必须在清单文件中进行更改。所以,我改变AndroidManifest.XML
了代码,
android:icon="@drawable/icon"
"icon"is my image name.
“图标”是我的图像名称。
What is the problem here? Why i am not getting my own icon? I am new to this Android Environment.
这里有什么问题?为什么我没有得到自己的图标?我是这个 Android 环境的新手。
I followed this article http://smartgap.wordpress.com/2012/08/11/customizing-launch-icon-on-eclipsephonegap-application/
我跟着这篇文章http://smartgap.wordpress.com/2012/08/11/customizing-launch-icon-on-eclipsephonegap-application/
My Manifest File :
我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
package="com.mage.edunxt" android:versionName="1.0" android:versionCode="1" android:hardwareAccelerated="true">
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:hardwareAccelerated="true"
android:debuggable="true">
<activity android:name="EduNxtQTIPlayer" android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/>
</manifest>
回答by Leo
I had to do the following
我必须执行以下操作
- add all the files to my res/Drawables folders
- set the icon attribute on the activity in the manifest.xml. It gave me the option to browse for the files setup in my Drawable directories.
- I had to do a clean for it to work.
- 将所有文件添加到我的 res/Drawables 文件夹中
- 在 manifest.xml 中设置活动的图标属性。它让我可以选择浏览 Drawable 目录中设置的文件。
- 我必须清理它才能工作。
The clean is really important it seems to keep using the old icons until you clean.
清洁非常重要,似乎一直使用旧图标直到您清洁为止。
In eclipse Project->Clean
在 Eclipse Project->Clean
回答by Edwin Alex
I got it worked by doing these.
我通过做这些事情得到了它。
I just put my icon in all the folders inside "project/bin/res"
also.
我也只是将我的图标放在里面的所有文件夹中"project/bin/res"
。
Then i added the following line in config.xmlunder "project/res/xml"
.
然后我在config.xml下添加了以下行"project/res/xml"
。
<icon src="icon.png" />
Now it is working cool.
现在它运行起来很酷。
回答by techtinkerer
i have been building locally using phonegap CLI. No Eclipse and ran into multiple problems as looking at root folder ( useless for local builds.. Phonegap: how about spewing some notes when building ).
我一直在使用 phonegap CLI 在本地构建。没有 Eclipse 并且在查看根文件夹时遇到了多个问题(对本地构建没用。Phonegap:构建时吐出一些笔记怎么样)。
I finally copied individual icon files of different sizes to drawable* folders.
我最终将不同大小的单个图标文件复制到 drawable* 文件夹中。
drawable-hdpi drawable-ldpi drawable-mdpi drawable-xhdpi
drawable-hdpi drawable-ldpi drawable-mdpi drawable-xhdpi
this wasted LOOOOOOOTof my time.
这浪费LOOOOOOOT我的时间。
回答by Elixander Chen
Make changes in <project location>\platforms\android\ant-build\res and not <project location>\platforms\android\res
在 <project location>\platforms\android\ant-build\res 而不是 <project location>\platforms\android\res 中进行更改
For some people making changes in the latter location may have worked, but having noticed Phonegap copying from \android\res into \android\ant-build\res, I decided to check in there and found a separate set of drawable folders containing the default phonegap icon.
对于某些人来说,在后一个位置进行更改可能有效,但是注意到 Phonegap 从 \android\res 复制到 \android\ant-build\res,我决定在那里检查并找到一组单独的可绘制文件夹,其中包含默认值电话间隙图标。
Changing those finally worked.
改变那些终于奏效了。
Since I'm building and running locally and not using Adobe PhoneGap Build, changing icons in <project location>\www\res\icon\android won't work either.
由于我是在本地构建和运行,而不是使用 Adobe PhoneGap Build,因此更改 <project location>\www\res\icon\android 中的图标也不起作用。
回答by Neon Warge
I also would like to share my answer on this one in case they can't get it to work using the steps provided by previous users.
我还想分享我对此的回答,以防他们无法使用以前用户提供的步骤使其正常工作。
I can't get mine to work using the steps provided here and I am able to figure it out by using mipmaps. I generated icon sizes using this open source project which is great: Android Asset Studio
我无法使用此处提供的步骤使我的工作正常工作,但我可以通过使用 mipmap 来解决问题。我使用这个很棒的开源项目生成了图标大小:Android Asset Studio
I notice now that the generated icons are now placed in mipmap folders not on drawables. I think this what the google want us to do to separate the drawables from icons. Having done this I reference the newly imported mipmap folders using this:
我现在注意到生成的图标现在放在 mipmap 文件夹中,而不是放在可绘制对象上。我认为这是谷歌希望我们做的将可绘制对象与图标分开的事情。完成此操作后,我使用此引用新导入的 mipmap 文件夹:
android:icon="@mipmap/ic_launcher"
And here is the folder structure:
这是文件夹结构:
res/
mipmap-mdpi/ic_launcher.png (48x48 pixels)
mipmap-hdpi/ic_launcher.png (72x72)
mipmap-xhdpi/ic_launcher.png (96x96)
mipmap-xxhdpi/ic_launcher.png (144x144)
mipmap-xxxhdpi/ic_launcher.png (192x192)
I cleaned and rebuilt the project and I can now see the icon! But theres a catch. It was added on later version of android (v4.3 as stated here link). There is not much documentation on this if this will work on older version of android.
我清理并重建了项目,现在我可以看到图标了!但有一个问题。它被添加到更高版本的 android(v4.3,如此处链接所述)。如果这适用于旧版本的 android,则没有太多关于此的文档。
回答by Jonatan Ka?mierczak
The info provided on the PhoneGap web page explains that, but it may be not so clear at the first glance (link: http://docs.build.phonegap.com/en_US/configuring_icons_and_splash.md.html#_icons).
PhoneGap 网页上提供的信息对此进行了解释,但乍一看可能不太清楚(链接:http: //docs.build.phonegap.com/en_US/configuring_icons_and_splash.md.html#_icons)。
Simple explanation: just copy your icon to the app root directory and call it icon.png. That's all what you need.
简单解释:只需将您的图标复制到应用程序根目录并命名为 icon.png。这就是你所需要的。
In my case I made sure, that the icon has size 96x96px (bigger somehow didn't work, but could be my fault). And also after upload and rebuild, the app content was not updated - so I needed to repeat upload+rebuild few times.
在我的情况下,我确定图标的大小为 96x96px(更大的不知何故不起作用,但可能是我的错)。而且在上传和重建之后,应用程序内容没有更新 - 所以我需要重复上传+重建几次。