Where to place the assets folder in AIDE?

2.1k views Asked by At

I'm using AIDE (A code editor / IDE & compiler which runs on Android) to write an Android app, and I want to add some assets to my project, specifically a HTML file plus associated CSS and JavaScript files, to be displayed in a WebView.

I've put my assets (a HTML file) in projectDirectory/app/src/main/assets/htmlfile.html, but, when I use the code below to load it in WebView, it shows "File not found". The exact same thing works fine in Android Studio.

Where do I put this assets folder for AIDE to pick up its contents ?


Here is my code where I'm loading the WebView, although I don't think there's anything wrong here, as it works in Android Studio.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    WebView webView = new WebView(this);
    setContentView(webView);
    webView.loadUrl("file:///android_asset/htmlfile.html");
}

What I've tried:

  • Placing it in /app/src/main/assets/htmlfile.html (The usual location, which works in Android Studio).

  • In /app/src/main/res/assets/htmlfile.html

  • In /app/src/assets/htmlfile.html

  • Pretty much everywhere else.

However, wherever I put it and recompile, the WebView always shows "File not found". So where do I put my assets folder for it to work with AIDE, or how do I make AIDE pick it up when compiling ? Does AIDE support assets at all ?

2

There are 2 answers

0
Jonas Czech On BEST ANSWER

Doh: All I needed to do was menu > more > project > refresh build, with the assets in /app/src/main/assets/htmlfile.html and it worked. Somewhat non-obvious, but hey, solved my problem.

Leaving this self answer in case anyone else has the same problem.

1
Zahan Safallwa On

As for an html keep it in app->src->main->assets

And later on you can acces it like "file:///android_asset/error.html"

Lets take example of a webview wv1. You can write

wv.loadUrl("file:///android_asset/error.html");

Dont forget to rebuild your project. This is a safety measure in such case. Many times files are not included automatically