Android “font asset not found” error

一世执手 提交于 2019-12-06 03:23:55

Assets folder should be under root directory of main folder which inner folder of src.

For Reference Please find attached images of folder structure.

I am guessing that my file structure is wrong because the "assets" folder does not show up in "Android" mode and only shows up in "Project Mode"

According to your screenshots, you do not have an "assets" folder. You have a res/assets.fonts/ folder. It has the wrong name (assets.fonts, not assets) and is in the wrong location (a child of res/).

Step #1: In your project tree, right-click over main.

Step #2: Choose New > Directory from the context menu that appears when you right-clicked.

Step #3: In the resulting dialog, type assets, then click OK. You will now have an assets/ directory under main.

Step #4: In your project tree, right-click over your newly-created assets directory.

Step #5: Choose New > Directory from the context menu that appears when you right-clicked.

Step #6: In the resulting dialog, type 'fonts', then click OK. You will now have an assets/fonts/ directory under main.

Step #7: Drag your font file from its current location to move it into assets/fonts/.

Step #8: Delete the res/assets.fonts/ directory, which is now empty.

I am guessing that my file structure is wrong because the "assets" folder does not show up in "Android" mode and only shows up in "Project Mode".

Your assets is empty you can't see it in "Android mode". Change mode to "Project" and add your font to assets folder.

Right location of assets folder:

root-module
|--.idea
|--app
|----build
|----src
|------main
|--------assets
|----------norwester.otf
|--------java
|----------source code here
|--------res
|------AndroidManifest.xml
|----build.gradle

To create assets folder Right click on app->New->Folder->Assets Folder like below image.

The assets folder must be in the main folder, not in resources folder. Also there is assets.fonts in your project which I guess is not the correct format. You can create the assets in the main directory, then right click -> New -> Directory and give its name as fonts

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!