phonegap icon/splash screen path for cli build - android

While creating my app I issues the command:
phonegap create appdir com.site.myapp myapp
so now the appdir folder has the following.
-.cordova
-hooks
-platforms
-plugins
-www
-config.xml-----(config.xml is generated at top level)
In my www folder i have one index.html and one image that I want to use as my icon
www
-index.html
-icon.png
1)so which do I give the path for the tag in the config.xml file?
2)where do I put the config file do i need to move the config file inside the www folder like in phonegapbuild
I have tried various path combinations but none is working

Using Android, The application icon is located here: res/drawable/
So replace icon.png there.
Same thing for splash screen, replacing res/drawable/screen.png.

Related

Cordova Android Build of icon path not found

On typing cordova build android in a DOS box, nothing is built, but instead I see an error message:
Error: Source path does not exist: resources/android/icon/drawable-hdpi-icon.png
I have updated Cordova, android rm & add everything still no luck. I am a native android developer feeling very hard to learn Cordova hybrid app development please guide me to descriptive link too.
If you project is created using Ionic then do the following :-
Create the folder name "resources" in your projects root directory.
Place your icon file name as "icon.png" in the resouces folder.
Icons should be 192x192 px without rounded corners.
Place your splash file name as "splash.png" in the resources folder.
Splashscreens should be 2208x2208 px, with the image centered in the
middle.
After doing the above open you cli , go to the root of your project and enter
ionic cordova resources
your icon and splash will be generated and config file also will be updated.
If you have created this project using cordova/phonegap :-
you can either remove the icon tag you specified in your config.xml completely
or
create the icon and place it in "www/res/icon.png".
Update the path in config.xml
remove all the icon path and just add this line to your config.xml
<icon src="www/res/icon.png"/>

Font file not loading on Libgdx Android

I am using the following code to load font in my libgdx project.
BitmapFont(Gdx.files.local("fonts/test.fnt"))
This is working fine when i launch using Desktop Launcher.
however when I launch using Android Launcher i get the following error.
com.badlogic.gdx.utils.GdxRuntimeException: File not found: fonts/test.fnt (Local)
I am not sure What am i doing wrong here. My Android project's assets for folder contains fonts folder and has the files test.fnt and test.png.
On Android, assets can only be accessed using the internal file system:
Gdx.files.internal("filename");
Are you using different assets folders for both desktop and android so that you have separate copies of your files? Or are you using the same assets folder for both desktop and android?
If your are using the same assets folder, then both desktop and android have to use the android assets folder. Android is finicky in this way. So you will have to set your desktop assets folder to point to the android assets folder, then anytime you add new assets you have to add them to the android folder.
This is how I initialize my fonts.
fontTexture = new Texture(Gdx.files.internal("assets/texture/font.tga"));
buttonFont = new BitmapFont(Gdx.files.internal("assets/texture/font.fnt"), new TextureRegion(fontTexture), true);
By using internal it searches your project for the folder containing the assets for me that folder is "assets" my project looks something like this:
Eventhough I clearly have my assets packed into my project, I will get the same error when I export my application just like this.
Now here's how to solve that issue. You need to open up your exported project with something like 7z or Winrar, and manually drop in the 'assets' folder. In your case "fonts". This should should fix it, atleast I always have to do that, it never packs the assets for me.

Default Cordova index.html is compiling

I have cordova latest version installed on my system and I created the basic app with command
cordova create
and I added the platform using
cordova add platform android
and I replaced the default index.html in the www directory with my own index.html
but whenever i tried to generate apk, and tried to run it on my mobile. It was the apk generate with default index.html
the screen of my app will be
How to resolve this issue ?
This is a normal behaviour.
Cordova is going to take the index.html from your projects root folder, everytime you run cordova build, prepare or serve without attribues, which is located directly inside your projects www folder.
Root www folder inside your cordova project contains the index.html which is taken and "thrown" into all platform folders when you run those commands.
projectName -> www -> index.html
Solution
You work in your projects root folder, and run cordova prepare everytime after you did a change to your index.html file.
You work directly inside your android project folder and the index.html which is located inside the assets -> www folder
You can change default index.html file to your own .html file
Simply open config.xml file in your project folder and edit its src attribute in <content> tag:
like:
default:
content src="index.html"
edited:
content src="helloCounterApp.html"
(Then it will load helloCounterApp.html not index.html(default))

Assets folder in android app (eclipse)

I had searched to create the assets folder in an android app, the solution which i had tried is <App Name>/src/assets/fonts/
but when i try to use a ttf file in my Application, i have an error :
the code :
mFace = Typeface.createFromAsset(mContext.getAssets(),"fonts/fontType.ttf");
and the error :
native typeface cannot be made
I don't know if the assets folder is in the good place.
The problem is at the path of asset
<App Name>/src/assets/fonts/
should be
<App Name>/assets/fonts/
Read more at Directory Structure of an Android Project
Android project directory structure is as below
In Android Studio, I tried the root "app" folder, and that didn't work. I looked for the AndroidManifest.xml file and put the assets folder there. That worked for me.
For me it ended up being app\src\main\assets
ProjectName/assets/fonts
Not in under the src.
The assets folder is an independent folder.
While creating an Android project itself the Assets folder is independent to the src folder. Not inside the src folder.
Confirm that assets folder was created in the following way /assets.
Later create a fonts folder inside the assets folder and place fonts file inside the fonts : /assets/fonts

Phonegap + Eclipse + Cordova -- No config.xml

I just created an Android Project in Eclipse with all the phonegap and cordova files as expected. However, I have no such directory, and thus, no config.xml. According to the Apache Cordova documentation, it is supposed to be located at: app/res/xml/config.xml.
My folder structure is as follows, for the /res directory:
/res/drawable-hdpi
/res/drawable-ldpi
/res/drawable-mdpi
/res/drawable-mdpi
/res/layout
- /res/layout/main.xml
/res/values
- /res/layout/strings.xml
What have I done wrong or what step am I missing? I hope I have provided enough information.
Just create the /res/xml/ folder manually. Then create config.xml using a text editor and use this as a template: https://github.com/phonegap/phonegap/blob/master/lib/android/xml/config.xml
Whenever we create a cordova project, config.xml gets created automatically. We need to check if there is any folder in excluded list.
Go to Build path -> Resources -> Check for excluded resources.
Remove them from the project and build the project. You will be able to view the config.xml and www folder in the Project/Package Explorer.

Categories

Resources