Mobile/GeckoView: Difference between revisions
Line 7: | Line 7: | ||
== Using GeckoView == | == Using GeckoView == | ||
# Download | # Download a recent GeckoView AAR from treeherder (mozilla-central tree). The AAR is available from the 'Android API15+ Gradle opt' job under the 'Bg' symbol. After clicking that, there is a link to 'geckoview-0.0.1.aar' in the bottom pane. | ||
# Add the GeckoView AAR to your Gradle / Android Studio project. In Android Studio you can add the .aar as follows: | |||
# | ## Move the geckoview aar to your project's 'libs' folder. | ||
# | ## Use the 'New Module' option under the 'File' menu. | ||
# | ## Import the .aar file. | ||
You can now use GeckoView your app by including the following in a layout XML file: | You can now use GeckoView your app by including the following in a layout XML file: | ||
Line 30: | Line 26: | ||
<pre> | <pre> | ||
GeckoView geckoView = (GeckoView) findViewById(R.id.geckoview); | GeckoView geckoView = (GeckoView) findViewById(R.id.geckoview); | ||
geckoView. | geckoView.loadUri("http://mozilla.com"); | ||
</pre> | </pre> | ||
Revision as of 18:16, 30 June 2017
What is GeckoView
GeckoView is an Android library project that allows third-party developers to use Gecko as an Android View in their own applications. GeckoView is similar to Android's built in WebView, but it is not a drop in replacement for WebView.
Note that GeckoView is NOT ready to be used in a production environment. It is currently possible to load webpages, but that's about it. See bug 1322573.
Using GeckoView
- Download a recent GeckoView AAR from treeherder (mozilla-central tree). The AAR is available from the 'Android API15+ Gradle opt' job under the 'Bg' symbol. After clicking that, there is a link to 'geckoview-0.0.1.aar' in the bottom pane.
- Add the GeckoView AAR to your Gradle / Android Studio project. In Android Studio you can add the .aar as follows:
- Move the geckoview aar to your project's 'libs' folder.
- Use the 'New Module' option under the 'File' menu.
- Import the .aar file.
You can now use GeckoView your app by including the following in a layout XML file:
<org.mozilla.gecko.GeckoView android:id="@+id/geckoview" android:layout_width="fill_parent" android:layout_height="wrap_content" />
You can then load a page in your code with:
GeckoView geckoView = (GeckoView) findViewById(R.id.geckoview); geckoView.loadUri("http://mozilla.com");
Example App
The example app is a bare bones Android app that uses GeckoView. Clone the GeckoBrowser repository and follow the instructions above to add the GeckoView library to the app. Alternatively, you can use this fork, which allows to download the dependencies and build the GeckoBrowser app "à la make".
When running, it looks as such:
Known Issues
Asset Compression - bug 908929
GeckoView assets (.so's) should not be compressed in final APK's built by 3rd-party developers. This may cause problems in some cases. See bug 908929.