4

I am facing a problem. I have converted a javascript application to Android app by using phonegap, cordova and eclipse. The App works cool.

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?

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,

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.

I followed this article 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> 
Edwin Alex
  • 5,118
  • 4
  • 28
  • 50
  • Can you dig-out all the resources in the folder of the imported App and see where this "ion" is hidden, can this be somehow embedded in the code itself, meaning it's built pixel by pixel? – g00dy Apr 15 '13 at 08:01
  • @g00dy Thanks for the reply. Can you exaplain me little bit clearly? because i am totally new to this environment – Edwin Alex Apr 15 '13 at 08:03
  • Did you remove the default icon from all of the drawable folders? Try uninstalling the app and reinstalling it. Also, there is the possibility that you have used tools that are not free or come with some license requiring that you use their icon. Because of this they may be setting the icon programmatically. – dcow Apr 15 '13 at 08:03
  • What is the format of your icon? – mmBs Apr 15 '13 at 08:04
  • @DavidCowden i didnt remove the old icon. But i renamed it. Also, i uninstalled and installed. but no use. Then this is not any tool's icon. This is my own icon. I just want to use it for my App. – Edwin Alex Apr 15 '13 at 08:05
  • @mmBs it is a png file – Edwin Alex Apr 15 '13 at 08:06
  • You just renamed the old icon - right? How come you expect just your icon to be displayed? If I understand this well, you just changed the name of the file or you changed the name inside the application, please explain with more details what have you done. – g00dy Apr 15 '13 at 08:17
  • @g00dy Sorry for the inconvenience. I put my icon inside "res" folder. Already there is a cordova icon which is displayed currently. I renamed this cordova icon with another name and keep my icon with the name "icon". – Edwin Alex Apr 15 '13 at 08:20
  • @Edwin Alex Why don't you do the following: Place your icon in the folder where the cordova icon is. Then remane the cordova icon to "cordovaOld" and then remane your to the exact name that cordova uses for its icon (like "cordova" or whatever). See if that fixes it, if not, there's another place where this App takes this resource and you have to find it, then do the same thing there. It should do it, if not either the icon is created from bits (inside the code somewhere - less likely or the resource is somwhere hidden - even more less likely). – g00dy Apr 15 '13 at 08:27
  • @g00dy Actually right now i am doing the same what you have suggested first. But no use. I think it takes from another place from your point – Edwin Alex Apr 15 '13 at 08:30
  • @Edwin Alex You wrote that you put the icon to the `res` folder, but in this folder there are other folders - like `drawable`etc. Did you put icon to `drawable` folder? – mmBs Apr 15 '13 at 08:31
  • @mmBs ya. i put inside all folders with the corresponding names. For your reference i followed this article http://smartgap.wordpress.com/2012/08/11/customizing-launch-icon-on-eclipsephonegap-application/ – Edwin Alex Apr 15 '13 at 08:32
  • And you changed each of the drawable icons (meaning you replaced the default one with yours) in each of the folders (which in fact correspond to your device's resolution and pixel density)? – g00dy Apr 15 '13 at 08:47
  • @Edwin Alex, can you please provide complete manifest file – Nanashi Apr 15 '13 at 09:06
  • @g00dy yes.. You are right – Edwin Alex Apr 15 '13 at 09:20
  • @Nanashi I updated my post with the manifest code. Please see that – Edwin Alex Apr 15 '13 at 09:21
  • @Edwin Alex, please correct me if i am wrong; name of your icon is "icon.png" which you have placed under res/drawable (all four folder) and yet you are getting cordova image. right? – Nanashi Apr 15 '13 at 10:15
  • @Nanashi ya.absolutely.. That is my biggest headache. i cannot find a solution so far – Edwin Alex Apr 15 '13 at 10:26
  • @Edwin Alex, if you are building your app using phonegap build services, then you might have specified icon name in config.xml (res/xml) – Nanashi Apr 15 '13 at 10:40
  • @Nanashi i am building using phonegap build services only. but i don't know how to specify in config.xml. I checked this file. There is no option to specify that – Edwin Alex Apr 15 '13 at 10:49
  • @Nanashi OMG. Thanks. I added this line in config.xml and now it works. Thank you so much.. – Edwin Alex Apr 15 '13 at 11:13

6 Answers6

7

I had to do the following

  1. add all the files to my res/Drawables folders
  2. 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.
  3. I had to do a clean for it to work.

The clean is really important it seems to keep using the old icons until you clean.

In eclipse Project->Clean

Leo
  • 1,495
  • 23
  • 41
5

I got it worked by doing these.

I just put my icon in all the folders inside "project/bin/res" also.

Then i added the following line in config.xml under "project/res/xml".

<icon src="icon.png" /> 

Now it is working cool.

Edwin Alex
  • 5,118
  • 4
  • 28
  • 50
  • More details are available in the Apache Cordova documentation. https://cordova.apache.org/docs/en/latest/config_ref/images.html – anirus Jun 20 '16 at 03:08
2

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 ).

I finally copied individual icon files of different sizes to drawable* folders.

drawable-hdpi drawable-ldpi drawable-mdpi drawable-xhdpi

this wasted LOOOOOOOT of my time.

techtinkerer
  • 1,280
  • 2
  • 15
  • 26
0

Make changes in <project location>\platforms\android\ant-build\res and not <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.

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.

Elixander Chen
  • 119
  • 1
  • 6
0

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

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:

 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.

Neon Warge
  • 1,817
  • 6
  • 29
  • 53
0

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).

Simple explanation: just copy your icon to the app root directory and call it icon.png. That's all what you need.

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.

Jonatan Kaźmierczak
  • 1,821
  • 2
  • 15
  • 9