Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

472
Vistas
Uncaught ReferenceError: for JS library on Android Project

Trying to create a demo app using the VAST Client JS library in my Android Project.

For this, I have downloaded the library's pre-bundled version

JS library document

and put it in the assets folder.

Assets folder

Besides that, I've also created an HTML file that basically calls the JS functions of the library.

< !DOCTYPE html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<script src='file:///android_asset/vast-client-browser-min.js'></script>
<script>
 // Get the VAST Url from the Java class
 const tagURL = window.MyHandler.getVASTUrl();
 
 const vastClient = new VAST.VASTClient();

 vastClient.get(tagURL)
 .then(res => {
    // notify my Java class
    window.MyHandler.onResponse('hey');
 }).catch(err => {
    // notify my Java class
     window.MyHandler.onError('heyy');
 });
</script>
</head>
<html>
<body>
</body>
</html>

On the Java side, I call my HTML file

    // initialize webview
    WebView.setWebContentsDebuggingEnabled(true);
    webView.setWebChromeClient(new WebChromeClient());
    webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    
    // add javascript interface to notify my java class from the JS side.
    webView.addJavascriptInterface(new JavaScriptInterface(this, webView), "MyHandler");
    
    // Load the HTML file
    webView.loadUrl("file:///android_asset/vast_client_handler.html");

However, when I run the app, I get this;

I/chromium: [INFO:CONSOLE(17)] "Uncaught ReferenceError: VASTClient is not defined", source: file:///android_asset/vast_client_handler.html (17)

what could I be missing? Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your whole HTML document is wrong.

  • First, you should start with the <html> tag and not the <head> tag.
  • The < !DOCTYPE html> has a space after the first < character so it doesn't get parsed properly
  • You have a closing tag after the script, but the script should be inside
  • This is just a suggestion - but if you're loading a resource in the head, you should properly put the script that uses it inside the body so that you won't have race conditions (<head> content loads before the <body>)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda