|
|
Line 1: |
Line 1: |
| '''GeckoView is [https://www.mozilla.org/firefox/ Firefox Quantum's] engine, packaged as a reusable Android library.'''
| | #REDIRECT [[Mobile/GeckoView]] |
| | |
| Mozilla uses GeckoView to power [https://blog.mozilla.org/blog/2018/09/18/firefox-reality-now-available/ Firefox Reality], [https://www.mozilla.org/firefox/mobile/#focus Firefox Focus], and more.
| |
| | |
| GeckoView serves a similar purpose to Android's built-in WebView, but it has its own APIs and is ''not'' a drop in replacement.
| |
| | |
| == Why GeckoView? ==
| |
| | |
| GeckoView, like Firefox for Android, offers excellent support for web standards. Because GeckoView is a standalone library that you include in your application, you know exactly what capabilities it supports.
| |
| | |
| Android's built-in WebView is a moving target:
| |
| | |
| == Get Started ==
| |
| | |
| ''Building a browser? Check out [https://mozilla-mobile.github.io/android-components/ Android Components], our collection of ready-to-use supporting libraries!''
| |
| | |
| === Configure Gradle ===
| |
| | |
| You need to add or edit four stanzas inside your module's <code>build.gradle</code> file.
| |
| | |
| '''1. Set the GeckoView version'''
| |
| | |
| ''Like Firefox, GeckoView has three release channels: Stable, Beta, and Nightly. Browse the [https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/ Maven Repository] to see currently available builds.
| |
| <syntaxhighlight lang="Groovy">
| |
| ext {
| |
| geckoviewChannel = "nightly"
| |
| geckoviewVersion = "64.0.20180927100037"
| |
| }
| |
| </syntaxhighlight>
| |
| | |
| '''2. Add Mozilla's Maven repository'''
| |
| <syntaxhighlight lang="Groovy">
| |
| repositories {
| |
| maven {
| |
| url "https://maven.mozilla.org/maven2/"
| |
| }
| |
| }
| |
| </syntaxhighlight>
| |
| | |
| '''3. Configure build flavors'''
| |
| | |
| ''Note: Until we resolve [https://bugzilla.mozilla.org/show_bug.cgi?id=1485045 Bug 1485045], you must configure a separate build variant for each CPU architecture.''
| |
| | |
| <syntaxhighlight lang="Groovy">
| |
| android {
| |
| // ...
| |
| | |
| // Note: compileOptions is only required for minSdkVersion < 24
| |
| compileOptions {
| |
| sourceCompatibility JavaVersion.VERSION_1_8
| |
| targetCompatibility JavaVersion.VERSION_1_8
| |
| }
| |
| | |
| flavorDimensions "abi"
| |
| | |
| productFlavors {
| |
| x86 { dimension "abi" }
| |
| x86_64 { dimension "abi" }
| |
| arm { dimension "abi" }
| |
| aarch64 { dimension "abi" }
| |
| }
| |
| }
| |
| </syntaxhighlight>
| |
| | |
| '''4. Add GeckoView Implementations'''
| |
| <syntaxhighlight lang="Groovy">
| |
| dependencies {
| |
| // ...
| |
| | |
| x86Implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}-x86:${geckoviewVersion}"
| |
| x86_64Implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}-x86_64:${geckoviewVersion}"
| |
| armImplementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}-armeabi-v7a:${geckoviewVersion}"
| |
| aarch64Implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}-arm64-v8a:${geckoviewVersion}"
| |
| }
| |
| </syntaxhighlight>
| |
| | |
| === Add GeckoView to a Layout ===
| |
| | |
| Inside a layout <code>.xml</code> file, add the following:
| |
| <syntaxhighlight lang="XML">
| |
| <org.mozilla.geckoview.GeckoView
| |
| android:id="@+id/geckoview"
| |
| android:layout_width="fill_parent"
| |
| android:layout_height="fill_parent" />
| |
| </syntaxhighlight>
| |
| | |
| === Initialize GeckoView in an Activity ===
| |
| | |
| '''1. Import the GeckoView classes inside an Activity:'''
| |
| <syntaxhighlight lang="Java">
| |
| import org.mozilla.geckoview.GeckoRuntime;
| |
| import org.mozilla.geckoview.GeckoSession;
| |
| import org.mozilla.geckoview.GeckoView;
| |
| </syntaxhighlight>
| |
| | |
| '''2. In that activity's <code>onCreate</code> function, add the following:'''
| |
| <syntaxhighlight lang="Java">
| |
| GeckoView view = findViewById(R.id.geckoview);
| |
| GeckoSession session = new GeckoSession();
| |
| GeckoRuntime runtime = GeckoRuntime.create(this);
| |
| | |
| session.open(runtime);
| |
| view.setSession(session);
| |
| session.loadUri("about:buildconfig"); // Or any other URL...
| |
| </syntaxhighlight>
| |
| | |
| === You're done! ===
| |
| | |
| Your application should now load and display a webpage inside of GeckoView.
| |
| | |
| To learn more about GeckoView's capabilities, review GeckoView's [https://mozilla.github.io/geckoview/javadoc/mozilla-central/ JavaDoc] or the [https://searchfox.org/mozilla-central/source/mobile/android/geckoview_example reference application].
| |
| | |
| == Getting Help / Contacting Us ==
| |
| | |
| If you need help with GeckoView, please let us know by either:
| |
| | |
| * [https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox%20for%20Android&component=GeckoView filing a bug] on Firefox for Android's GeckoView component
| |
| * Asking us in [ircs://irc.mozilla.org:6697/#mobile #mobile] on [[Irc|irc.mozilla.org]].
| |
| | |
| == Documentation and Examples ==
| |
| | |
| '''APIs'''
| |
| * [https://mozilla.github.io/geckoview/javadoc/mozilla-central/ JavaDoc API Documentation]
| |
| * [https://mozilla-mobile.github.io/android-components/reference/ Android Components APIs]
| |
| | |
| '''Building / Contributing / Bugs'''
| |
| * See [[Mobile/Get_Involved]] and the [https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Introduction Mozilla Developer Guide] for information on how to contribute to GeckoView
| |
| * Bugs are tracked in [https://developer.mozilla.org/en-US/docs/Mozilla/Bugzilla Bugzilla]
| |
| * We have a bug dashboard at [[Mobile/GeckoView/Bugs]] 🐛
| |
| | |
| '''Products / Examples'''
| |
| * [https://blog.mozilla.org/blog/2018/09/18/firefox-reality-now-available/ Firefox Reality] ([https://github.com/mozillareality/firefoxreality GitHub])
| |
| * [https://www.mozilla.org/firefox/mobile/#focus Firefox Focus] ([https://github.com/mozilla-mobile/focus-android/ GitHub])
| |
| * [https://searchfox.org/mozilla-central/source/mobile/android/geckoview_example GeckoView Reference Application]
| |