Changes

Jump to: navigation, search

Mobile/GeckoView

184 bytes removed, 16:07, 10 October 2018
Completely overhaul the page
== What '''GeckoView is GeckoView ==[https://www.mozilla.org/firefox/ Firefox Quantum's] engine, packaged as a reusable Android library.'''
Mozilla uses GeckoView is an Android library project that allows thirdto power [https://blog.mozilla.org/blog/2018/09/18/firefox-reality-now-party developers to use Gecko as an Android View in their own applicationsavailable/ Firefox Reality], [https://www.mozilla. GeckoView is similar to Android's built in WebVieworg/firefox/mobile/#focus Firefox Focus], but '''it is not a drop in replacement for WebView'''and more.
Note that GeckoView serves a similar purpose to Android's built-in WebView, but it has its own APIs and is ''not quite ready to be used '' a drop in a production environmentreplacement.
Current API documentation can be viewed here: https://mozilla.github.io/geckoview/javadoc/mozilla-central/== Why GeckoView? ==
== Testing GeckoView ==While Android offers a built-in WebView, it's not intended for building browsers, and many advanced Web APIs are disabled. Android's WebView is also a moving target: it's impossible know exactly which engine (and what version of that engine) will power a WebView on client devices.
GeckoView is a library, not a standalone appIn contrast, but you can test GeckoView by installing Focus Nightly "track" (channel). Focus 6.0 and earlier use Android's WebView, but Focus 7.0 is switching to Mozilla's homegrown Gecko. Unfortunately, Google Play only allows you to install one track (per Google Play account) at a time. Installing Focus Nightly will uninstall the regular Focus and replace it (and your settings) with Focus Nightly. If you have multiple Google Play accounts, then you can install a different Focus track in each account.:
* [https'''Full-Featured'''://githubGeckoView is designed to expose the entire power of the Web to applications, including being suitable for building web browsers.com/mozilla-mobile/focus-android/wiki/Release-tracks#nightly How to install Focus Nightly]* If '''Self-Contained''': Because GeckoView is a standalone library that you have questionsbundle with your application, you're welcome to drop by can be confident that the #focus IRC channel on [https://wiki.mozilla.org/IRC Mozilla's IRC server] or ask in code you test is the [https://groups.google.com/forum/#!forum/focus-klar-nightly focus-klar-nightly Google Group]code that will actually run.* If you've found a bug in Focus Nightly compared to Focus using WebView''Standards Compliant''': Like Firefox, then check the [https://githubGeckoView offers excellent support for modern Web standards.com/mozilla-mobile/focus-android/issues Focus bug tracker] to see if there is a bug filed. If notWebAssembly, CSS Grid, please file oneor Variable Fonts? No problem! :)
If you joined the Focus beta program ''before'' subscribing to the focus-klar-nightly Google Group, Google Play might not upgrade you to the new Focus Nightly right away. Google Play treats the Focus beta and nightly tracks as different flavors of beta and can forget to switch you from the regular beta to the nightly "beta" track. In this case, try:== Get Started ==
# Leave the Focus beta program (by clicking the "LEAVE" button in the "You're 'Building a beta tester" section browser? Check out [https://mozilla-mobile.github.io/android-components/ Android Components], our collection of Focus's Google Play page)# Uninstall Focus# Reready-join the beta program# Reto-install Focus# Open the Play Store app, open the "My apps & games" screen, select the "BETA" tab, and check for "Firefox Focus: The privacy browser" UPDATE button.use support libraries!''
== Using GeckoView = Configure Gradle ===
=== GeckoView Releases ===You need to add or edit four stanzas inside your module's <code>build.gradle</code> file.
Like Firefox, GeckoView has three three release channels: '''Nightly1. Set the GeckoView version''', '''Beta''', and '''Stable''' (production). GeckoView supports three different architectures:
* '''armeabi-v7a''' (32-bit ARM)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"* '''arm64-v8a''' ( geckoviewVersion = "64-bit ARM aka AArch64).0.20180927100037"* '''x86''' (32-bit)}* Coming soon in {{bug|1480834}}: '''x86-64'''</syntaxhighlight>
GeckoView build numbers use the format'''2. Add Mozilla's Maven repository'''<syntaxhighlight lang="Groovy">repositories { maven { url "https: MAJOR.MINOR.BUILD_ID, e.g. 63.0//maven.20180904170936mozilla.org/maven2/" }}</syntaxhighlight>
==== Release Schedule ===='''3. Configure build flavors'''
New major versions of GeckoView Stable are published every 6-8 weeks, following the ''Note: Until we resolve [https://wikibugzilla.mozilla.org/Release_Management/Calendar#Calendars Firefox release schedule]show_bug. Minor dot releases with security fixes may be released more frequently. The Stable channel is built from a release branch ("relbranch") in the [mozilla-release repositorycgi?id=1485045 Bug 1485045] with , you must configure a branch name like [https://hg.mozilla.org/releases/mozilla-release/shortlog/GECKOVIEW_62_RELBRANCH GECKOVIEW_62_RELBRANCH]separate build variant for each CPU architecture.''
New Nightly builds are released every day from Firefox's [https:<syntaxhighlight lang="Groovy">android { //hg.mozilla.org/mozilla-central/ mozilla-central repository]. New Beta builds are released once or twice a week from Firefox/Gecko's [https://hg.mozilla.org/releases/mozilla-beta mozilla-beta repository].
==== Add GeckoView to your build // Note: compileOptions is only required for minSdkVersion < 24 compileOptions { sourceCompatibility JavaVersion.gradle ====VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
GeckoView builds are published in a Maven repository: [https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/ maven.mozilla.org] for each release channel and architecture. The build naming convention is flavorDimensions "geckoview-$CHANNEL-$ARCHabi", e.g. geckoview-nightly-armeabi-v7a, geckoview-beta-arm64-v8a, and geckoview-x86.
<pre> productFlavors { x86 { dimension "abi" }repositories x86_64 {dimension "abi" } arm maven {dimension "abi" } url 'https://maven.mozilla.org/?prefix=maven2/' aarch64 { dimension "abi" }
}
}
</presyntaxhighlight'''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=== Add "@+id/geckoview to dependencies ==" android:layout_width="fill_parent" android:layout_height="fill_parent" /></syntaxhighlight>
Again, === Initialize GeckoView in build.gradlean Activity ===
'''1. Import the GeckoView classes inside an Activity:'''<presyntaxhighlight lang="Java">dependencies {import org.mozilla.geckoview.GeckoRuntime; implementation 'import org.mozilla:.geckoview:.GeckoSession;import org.mozilla.geckoview-nightly-armeabi-v7a:+'}.GeckoView;</presyntaxhighlight>
This will always use the latest Nightly in the repository'''2. As GeckoView development continuesIn that activity's <code>onCreate</code> function, we will have Beta and Release repositories that have add the expected version names following:'''<syntaxhighlight lang="Java">GeckoView view = findViewById(62R.0id.0, etcgeckoview);GeckoSession session = new GeckoSession();GeckoRuntime runtime = GeckoRuntime.create(this);
==== Loading a page in GeckoView ====session.open(runtime);view.setSession(session);session.loadUri("about:buildconfig"); // Or any other URL...</syntaxhighlight>
=== You can now use GeckoView your app by including the following in a layout XML file:'re done! ===
<pre><org.mozilla.geckoYour application should now load and display a webpage inside of GeckoView.GeckoView android:id="@+id/geckoview" android:layout_width="fill_parent" android:layout_height="wrap_content" /></pre>
You can then load a page in your Activity withTo 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].
<pre>onCreate(...) { // Find the GeckoView in our layout GeckoView geckoView = (GeckoView) findViewById(R.id.geckoview);= Getting Help ==
// Attach the Interested in GeckoView ? We're here to a new GeckoSession GeckoSession session = new GeckoSession(); sessionhelp.open(); geckoView.setSession(session);
// Load If you find a URL session.loadUri("httpbug or need assistance, please reach out by either://mozilla.com");}</pre>
* [https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox%20for%20Android&component= Example App ==GeckoView Filing a bug]* Talking to us in [ircs://irc.mozilla.org:6697/#mobile #mobile] on [[Irc|irc.mozilla.org]].
GeckoViewExample is an example app that [https://searchfox.org/mozilla-central/source/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java lives in mozilla-central] == Documentation and lets you easily exercise GeckoView. You can build/install it with the following gradle command:Examples ==
<pre>mach gradle geckoview_example'''APIs'''* [https:installLocalWithGeckoBinariesNoMinApiDebug</pre>/mozilla.github.io/geckoview/javadoc/mozilla-central/ JavaDoc API Documentation]* [https://mozilla-mobile.github.io/android-components/reference/ Android Components APIs]
You may find it easier to do this from Android Studio, where geckoview_example appears as a module.'''Building / Contributing'''
Firefox Focus also has a build variant that uses Gecko. To build, check out the Focus code from <code>* [[Mobile/Get_Involved]]* [https://githubdeveloper.com/mozilla-mobile/focus-android</code> and follow the [https://github.comorg/mozillaen-mobileUS/focus-androiddocs/blobMozilla/masterDeveloper_guide/README.md instructionsIntroduction Mozilla Developer Guide]. The only difference is you need to select one of the Gecko build variants from the Android Studio 'Build' menu.
The Gecko-related code for Focus lives in [https://github.com/mozilla-mobile/focus-android/blob/90bf62d89919d5ae2d8bd95954491264dcbe1bba/app/src/gecko/java/org/mozilla/focus/web/WebViewProvider.java WebViewProvider.java]'''Bugs'''
* [https://bugzilla.mozilla.org/buglist.cgi?product=Firefox%20for%20Android&component= Bugs GeckoView&resolution=---&list_id=14376671 All GeckoView Bugs]* [[Mobile/GeckoView/Bugs|GeckoView Bug Dashboard]] 🐛
'''Products / Examples'''* [https://blog.mozilla.org/blog/2018/09/18/firefox-reality-now-available/ Firefox Reality] ([Mobilehttps:/GeckoView/Bugs|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 bugs 🐛]Reference Application]
Confirm
170
edits

Navigation menu