5

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.

schnatterer
  • 7,525
  • 7
  • 61
  • 80
  • 1
    possible duplicate of [Where to place Assets folder in Android Studio](http://stackoverflow.com/questions/18302603/where-to-place-assets-folder-in-android-studio) – Prince May 08 '15 at 05:05

4 Answers4

16

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

Pankaj Kumar
  • 81,967
  • 29
  • 167
  • 186
  • The [official android developer resources](https://developer.android.com/studio/projects/index.html#ProjectView) tell something different, though. See also [this](http://stackoverflow.com/a/18302624/1845976) great answer. – schnatterer Oct 10 '16 at 19:38
  • @schnatterer That is different because that answer is targeted to gradle and this answer is targeted to eclipse based project. – Pankaj Kumar Oct 12 '16 at 05:41
  • I couldn't figure that from the question, so I added it to the title. – schnatterer Oct 12 '16 at 15:59
2

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

Karl Henselin
  • 1,015
  • 12
  • 17
1
ProjectName/assets/fonts

Not in under the src.

silvia_aut
  • 1,481
  • 6
  • 19
  • 33
0

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

Seenu69
  • 1,041
  • 2
  • 15
  • 33