Question

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.

Was it helpful?

Solution

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

enter image description here

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top