I am trying to get AssetManager
form a class in an Android library project, but I am getting the error:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
This is how I call it:
public class RevPluginLoader extends AppCompatActivity {
private List<String> copyPlugins() {
AssetManager assetManager = getAssets(); // This is where it all fails
}
}
How can I get the AssetManager
?
We can't add assets folder in lib module
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 app must be stored in the assets/ directory of the app module itself.
For More details, you can refer here