Reputation: 27
I'm trying to make an Android app that shows the content of an HTML using GeckoView
//MainActivity.kt
class MainActivity : AppCompatActivity() {
private lateinit var geckoView: GeckoView
private val geckoSession = GeckoSession(GeckoSessionSettings.Builder().allowJavascript(true).build())
private fun setupGeckoView() {
// 1
geckoView = findViewById(R.id.geckoview)
// 2
val runtime = GeckoRuntime.create(this)
geckoSession.open(runtime)
// 3
geckoView.setSession(geckoSession)
// 4
val apkURI: URI = File(packageResourcePath).toURI()
val assetsURL = "jar:$apkURI!/assets/"
val myURL = assetsURL + "index.html"
geckoSession.loadUri(myURL)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setupGeckoView()
}
}
In the assets I have the index.html, a bunch of .css and a .js script. The app launches, correctly displays the html (meaning that also css was correctly loaded), but the js script doesnt start and this error is returned:
[JavaScript Error: "NS_ERROR_NOT_AVAILABLE: " {file: "jar:file:///data/app/com.icp.firefox_app-2/base.apk!/assets/full-offline.iife.js" line: 3}]
@jar:file:///data/app/com.icp.firefox_app-2/base.apk!/assets/full-offline.iife.js:3:4777
@jar:file:///data/app/com.icp.firefox_app-2/base.apk!/assets/full-offline.iife.js:101937:101768
Doesn anyone have any idea what could be the problem?
Upvotes: 0
Views: 34