My goal is to create a modified version of WebView (call it WebViewCustom) in Android for my personal use in my application. WebView is WebKit based so I need to compile it in C by means of NDK. I am not interested in participating in the open-source Android project now, so my need is just to be able to compile the original C source of WebView and use it as a customized control in my Android application (both SDK and NDK are possible environments for the application). I think it is possible without all that GIT WebKit stuff I am not interested in, but I am not an expert of the Android and WebKit projects. Is it possible to just edit and compile the WebView code and put it in my application as a new control? Can you show me the main steps of this task?
Share
This is certainly possible. The main difficulty in rebuilding
android.webkitfrom source lies in the lack of a correct build environment. It was never intended to be built outside of the target platform, but a couple of simple hacks around the sources make it quite easy to accomplish.First of all, the whole
android.webkitpackage business has to be renamed for obvious reasons, since anandroid.webkit.WebViewclass would already be available during runtime. Usesedon all theframeworks/base/core/java/android/webkittree for example.Basically you have to grab the full source tree, initialize a build environment (More information here http://source.android.com/source/initializing.html),
make frameworkto make the internal runtime environment available, create a new development platform, replace all the classes fromframework.jar(after building it’s inout/target/common/obj/JAVA_LIBRARIES/framework_intermediaries/classes.jar) intoandroid.jarof the platform, build your ownwebkitpackage against this new platform that contains the internals.Check out https://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/ for more information on getting an internal runtime available for development purposes.
You will also need
core_intermediaries,bouncycastle_intermediariesand others in order to compilewebkit, these are all available whenmake frameworkis invoked, look at the errors when building yourwebkitpackage and grep theout/target/common/obj/JAVA_LIBRARIES/to figure out which classes contain the symbols.That’s not all, however, the package uses
libwebcore.sowhich exposes native methods to theandroid.webkitpackage; this would have to have all native method bindings registered to your new package name (inexternal/webkit/WebKit/android/jni) and be recompiled without prelinking (make libwebcore) and packaged with your application as a native library.After everything is satisfied, you would then use your own
WebViewclass from your own package instead of theandroid.webkitone. If you intend to replaceandroid.webviewcompletely – you would have to recompile aframework.jarand replace it insidesystem/framework/(root privileges required).