1

I use the Cordova CLI Version: 3.4.0-0.1.3 and work on an Android project.

As far as I can google the CLI does not copy image resources from the www/res/icons folder, in spite of the documentation stating this: docs at cordova.apache.org/...

In different version of Cordova and Phonegap this seems to have been dealt with in different ways (eg: How to add app icon within phonegap projects?) but I can't seem to replicate any of these.

Where in the file structure should I copy these image resources? (to do manually what the command line interface does not do automatically)

Cordova 3.4 is the current version, and someone somewhere must have done this correct. Any ideas?

Edit: Adding details on files and folders from a the CLI commands: cordova create hello com.example.hello HelloWorld. Inside the new hello-folder: .

|____.DS_Store
|____config.xml
|____hooks
| |____README.md
|____merges
|____platforms
|____plugins
|____www
| |____css
| | |____index.css
| |____img
| | |____logo.png
| |____index.html
| |____js
| | |____index.js

If I add a platform: cordova platform add android, and check again:

.
|____.DS_Store
|____config.xml
|____hooks
| |____README.md
|____merges
| |____android
|____platforms
| |____android
| | |____.project
| | |____AndroidManifest.xml
| | |____assets
| | | |_____where-is-www.txt
| | | |____www
| | | | |____cordova.js
| | | | |____cordova_plugins.js
| | | | |____css
| | | | | |____index.css
| | | | |____img
| | | | | |____logo.png
| | | | |____index.html
| | | | |____js
| | | | | |____index.js
| | |____build.xml
| | |____cordova
| | | |____android_sdk_version
| | | |____build
| | | |____build.bat
| | | |____check_reqs
| | | |____clean
| | | |____clean.bat
| | | |____defaults.xml
| | | |____lib
| | | | |____android_sdk_version.js
| | | | |____appinfo.js
| | | | |____build.js
| | | | |____check_reqs.js
| | | | |____clean.js
| | | | |____device.js
| | | | |____emulator.js
| | | | |____exec.js
| | | | |____install-device
| | | | |____install-device.bat
| | | | |____install-emulator
| | | | |____install-emulator.bat
| | | | |____list-devices
| | | | |____list-devices.bat
| | | | |____list-emulator-images
| | | | |____list-emulator-images.bat
| | | | |____list-started-emulators
| | | | |____list-started-emulators.bat
| | | | |____log.js
| | | | |____run.js
| | | | |____spawn.js
| | | | |____start-emulator
| | | | |____start-emulator.bat
| | | |____log
| | | |____log.bat
| | | |____node_modules
| | | | |____.bin
| | | | | |____shjs
| | | | |____q
| | | | | |____benchmark
| | | | | | |____compare-with-callbacks.js
| | | | | | |____scenarios.js
| | | | | |____CONTRIBUTING.md
| | | | | |____LICENSE
| | | | | |____package.json
| | | | | |____q.js
| | | | | |____queue.js
| | | | | |____README.md
| | | | |____shelljs
| | | | | |____.documentup.json
| | | | | |____.jshintrc
| | | | | |____.npmignore
| | | | | |____.travis.yml
| | | | | |____bin
| | | | | | |____shjs
| | | | | |____global.js
| | | | | |____LICENSE
| | | | | |____make.js
| | | | | |____package.json
| | | | | |____README.md
| | | | | |____scripts
| | | | | | |____generate-docs.js
| | | | | | |____run-tests.js
| | | | | |____shell.js
| | | | | |____src
| | | | | | |____cat.js
| | | | | | |____cd.js
| | | | | | |____chmod.js
| | | | | | |____common.js
| | | | | | |____cp.js
| | | | | | |____dirs.js
| | | | | | |____echo.js
| | | | | | |____error.js
| | | | | | |____exec.js
| | | | | | |____find.js
| | | | | | |____grep.js
| | | | | | |____ls.js
| | | | | | |____mkdir.js
| | | | | | |____mv.js
| | | | | | |____popd.js
| | | | | | |____pushd.js
| | | | | | |____pwd.js
| | | | | | |____rm.js
| | | | | | |____sed.js
| | | | | | |____tempdir.js
| | | | | | |____test.js
| | | | | | |____to.js
| | | | | | |____toEnd.js
| | | | | | |____which.js
| | | |____run
| | | |____run.bat
| | | |____version
| | | |____version.bat
| | |____CordovaLib
| | | |____.project
| | | |____AndroidManifest.xml
| | | |____build.xml
| | | |____local.properties
| | | |____proguard-project.txt
| | | |____project.properties
| | | |____src
| | | | |____com
| | | | | |____squareup
| | | | | | |____okhttp
| | | | | | | |____Address.java
| | | | | | | |____Connection.java
| | | | | | | |____ConnectionPool.java
| | | | | | | |____Dispatcher.java
| | | | | | | |____Failure.java
| | | | | | | |____HttpResponseCache.java
| | | | | | | |____internal
| | | | | | | | |____AbstractOutputStream.java
| | | | | | | | |____Base64.java
| | | | | | | | |____DiskLruCache.java
| | | | | | | | |____Dns.java
| | | | | | | | |____FaultRecoveringOutputStream.java
| | | | | | | | |____http
| | | | | | | | | |____AbstractHttpInputStream.java
| | | | | | | | | |____HeaderParser.java
| | | | | | | | | |____HttpAuthenticator.java
| | | | | | | | | |____HttpDate.java
| | | | | | | | | |____HttpEngine.java
| | | | | | | | | |____HttpsEngine.java
| | | | | | | | | |____HttpsURLConnectionImpl.java
| | | | | | | | | |____HttpTransport.java
| | | | | | | | | |____HttpURLConnectionImpl.java
| | | | | | | | | |____OkResponseCacheAdapter.java
| | | | | | | | | |____Policy.java
| | | | | | | | | |____RawHeaders.java
| | | | | | | | | |____RequestHeaders.java
| | | | | | | | | |____ResponseHeaders.java
| | | | | | | | | |____RetryableOutputStream.java
| | | | | | | | | |____RouteSelector.java
| | | | | | | | | |____SpdyTransport.java
| | | | | | | | | |____Transport.java
| | | | | | | | | |____UnknownLengthHttpInputStream.java
| | | | | | | | |____NamedRunnable.java
| | | | | | | | |____Platform.java
| | | | | | | | |____spdy
| | | | | | | | | |____ErrorCode.java
| | | | | | | | | |____FrameReader.java
| | | | | | | | | |____FrameWriter.java
| | | | | | | | | |____HeadersMode.java
| | | | | | | | | |____Hpack.java
| | | | | | | | | |____Http20Draft06.java
| | | | | | | | | |____IncomingStreamHandler.java
| | | | | | | | | |____NameValueBlockReader.java
| | | | | | | | | |____Ping.java
| | | | | | | | | |____Settings.java
| | | | | | | | | |____Spdy3.java
| | | | | | | | | |____SpdyConnection.java
| | | | | | | | | |____SpdyStream.java
| | | | | | | | | |____Variant.java
| | | | | | | | |____StrictLineReader.java
| | | | | | | | |____tls
| | | | | | | | | |____DistinguishedNameParser.java
| | | | | | | | | |____OkHostnameVerifier.java
| | | | | | | | |____Util.java
| | | | | | | |____Job.java
| | | | | | | |____MediaType.java
| | | | | | | |____OkAuthenticator.java
| | | | | | | |____OkHttpClient.java
| | | | | | | |____OkResponseCache.java
| | | | | | | |____Request.java
| | | | | | | |____Response.java
| | | | | | | |____ResponseSource.java
| | | | | | | |____Route.java
| | | | | | | |____RouteDatabase.java
| | | | | | | |____TunnelRequest.java
| | | | |____org
| | | | | |____apache
| | | | | | |____cordova
| | | | | | | |____App.java
| | | | | | | |____AuthenticationToken.java
| | | | | | | |____CallbackContext.java
| | | | | | | |____Config.java
| | | | | | | |____CordovaActivity.java
| | | | | | | |____CordovaArgs.java
| | | | | | | |____CordovaChromeClient.java
| | | | | | | |____CordovaInterface.java
| | | | | | | |____CordovaPlugin.java
| | | | | | | |____CordovaResourceApi.java
| | | | | | | |____CordovaWebView.java
| | | | | | | |____CordovaWebViewClient.java
| | | | | | | |____DirectoryManager.java
| | | | | | | |____DroidGap.java
| | | | | | | |____ExifHelper.java
| | | | | | | |____ExposedJsApi.java
| | | | | | | |____FileHelper.java
| | | | | | | |____IceCreamCordovaWebViewClient.java
| | | | | | | |____JSONUtils.java
| | | | | | | |____LinearLayoutSoftKeyboardDetect.java
| | | | | | | |____LOG.java
| | | | | | | |____NativeToJsMessageQueue.java
| | | | | | | |____PluginEntry.java
| | | | | | | |____PluginManager.java
| | | | | | | |____PluginResult.java
| | | | | | | |____ScrollEvent.java
| | | | | | | |____Whitelist.java
| | |____custom_rules.xml
| | |____libs
| | |____local.properties
| | |____platform_www
| | | |____cordova.js
| | |____proguard-project.txt
| | |____project.properties
| | |____res
| | | |____drawable
| | | | |____icon.png
| | | |____drawable-hdpi
| | | | |____icon.png
| | | |____drawable-ldpi
| | | | |____icon.png
| | | |____drawable-mdpi
| | | | |____icon.png
| | | |____drawable-xhdpi
| | | | |____icon.png
| | | |____values
| | | | |____strings.xml
| | | |____xml
| | | | |____config.xml
| | |____src
| | | |____com
| | | | |____example
| | | | | |____hello
| | | | | | |____HelloWorld.java
|____plugins
| |____android.json
|____www
| |____css
| | |____index.css
| |____img
| | |____logo.png
| |____index.html
| |____js
| | |____index.js

I still do not have any www/res/icons folder, and I do not have any success with overwriting the image-files in the platforms/android folder.

Community
  • 1
  • 1
Eiriks
  • 479
  • 2
  • 11
  • 20

4 Answers4

0

Like the previous versions, Cordova 3.4 also uses the same location to refer the icons.

i.e.,

    res/icon/android/icon-36-ldpi.png
    res/icon/ios/icon-57.png
    res/icon/bada/icon-128.png
    res/icon/icon-80/icon-36-ldpi.png etc.,

and for screen it resides,

res/screen/screen-hdpi-landscape.png etc.,

If you are targetting on specific platform or using eclipse, you can locate icons in

platform/android/res/drawable/icon.png

after build you can locate the icons in the crunch folder,

i.e., res/crunch/drawable/icon.png

Only difference I found in the latest version is missing the library file,

i.e., cordova3.4.jar file.

For version 3.2 it builds automatically and resides in the lib folder but in the latest version we have to create it manually and add to the build-in path. click here to create if it is missing.

Also latest version concentrated on security so in eclipse initially the files inside assets folder will be added to ignore list. If we wanted to overwrite we have to remove www and res folder from the ignore list by pointing to properties.

Hope my answer is useful.

Vinith
  • 1,264
  • 14
  • 25
  • 2
    Ok. I tried what I think you say here: I created a folder `res/icon/android` inside the `www` folder and filled this with my icons `{icon-36-ldpi.png, icon-48-mdpi.png, icon-48-mdpi.png, icon-96-xhdpi.png}`. I then run `cordova run android`, but still I get the old [cordova icon](http://kangaroopunch.com/wp-content/uploads/sites/2/2013/04/cordova_bot.png) on the android device (and on the android emulator). Either I put the files the wrong place, or the cordova CLI does not copy the icons to where ever they in-the-end should be. Can you confirm any of these options? – Eiriks Mar 23 '14 at 12:54
  • You dont want to create any folders, by default it'll be available boss. just create a sample app using command prompt and let me know the structure what u got. Thanks – Vinith Mar 24 '14 at 12:18
  • Your edit clearly shows the 'res' folder. res/icon folder is for old versions and for you res/drawable refers both. Just build your project and see. – Vinith Mar 25 '14 at 10:35
0

Please check the AndroidManifest.xml for android:icon if it is pointing to the right icon path (@drawable/icon).

newfurniturey
  • 37,556
  • 9
  • 94
  • 102
Jibin
  • 1
0

Eiriks, I had the same issue where my project retained the default icon and did not generate the res dir directory under www. I'm not sure if its a bug under cordova 3.4, irrespective of that, I added my icon files 'icon.png' to /platform/android/res/drawable/.

There are 5 drawable directories, each with an icon.png file of different dimensions; drawable, drawable-hdpi, drawable-ldpi, drawable-mdpi, drawable-xhdpi. After which, go to /platform/android/cordova and run clean.bat.

You can now build and run your project and you'll see your custom launch icon.

Jasper Giscombe
  • 313
  • 1
  • 5
0

@Eiriks, add the following lines in your config.xml

    <platform name="android">
        <icon src="www/res/icon/android/icon-36-ldpi.png" density="ldpi" />
        <icon src="www/res/icon/android/icon-48-mdpi.png" density="mdpi" />
        <icon src="www/res/icon/android/icon-72-hdpi.png" density="hdpi" />
        <icon src="www/res/icon/android/icon-96-xhdpi.png" density="xhdpi" />
    </platform>

    <platform name="ios">
        <icon src="www/res/icon/ios/icon-57.png" width="57" height="57" />
        <icon src="www/res/icon/ios/icon-72.png" width="72" height="72" />
        <icon src="www/res/icon/ios/icon-57-2x.png" width="114" height="114" />
        <icon src="www/res/icon/ios/icon-72-2x.png" width="144" height="144" /> 
    </platform>

and then add your icons on the specified paths and will all work like a charm

paishin
  • 258
  • 1
  • 5
  • 15