Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. Step 3 – Right click app >> New >> Folder >> Assets folder.
To view asset files in Files home, select Libraries and then select Asset Library . To view and edit asset files in Setup, enter Asset Files in the Quick Find box, then select Asset Files.
Step 1: To create an asset folder in Android studio open your project in Android mode first as shown in the below image. Step 2: Go to the app > right-click > New > Folder > Asset Folder and create the asset folder. Step 3: Android Studio will open a dialog box. Keep all the settings default.
From Android Docs : http://developer.android.com/tools/projects/index.html
Library modules cannot include raw assets
The tools do not support the use of raw asset files (saved in the assets/ directory) in a library module. Any asset resources used by an application must be stored in the assets/ directory of the application module itself. However, resource files saved in the res/ directory are supported.
And this is how you can read a JSON from res/raw folder : JSON Parsing in android - from resource folder
Other workarounds :
how to reference an asset in a library project
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With