Oracle JET v5 on Android with Windows
I’ve dabbled with Oracle JET since v3.2 and have done some bits and bobs with the hybrid version namely the iOS target.
For those that are new to Oracle JET, it provides a single source set (set of CSS, JS and HTML) which you can target multiple devices with (Android, iOS and Windows phones).
I was interested in getting up to speed with looking at Android and this was going to be my first exposure of trying the Android emulator. It therefore made sense I used the latest version (Oracle JET version 5) as the framework is getting richer with each release.
I was trying my best to follow the Oracle JET instructions (for reference, https://docs.oracle.com/en/middleware/jet/5/develop/getting-started-oracle-jet-hybrid-mobile-application-development.html#GUID-C75CD8DC-5084-4831-BE1A-FFEE4EA8600C) but I got confused or slipped up on a couple of areas. Therefore, this post serves as a reminder for myself but should help others who are getting stuck.
Cordova Version
One of things that really threw me off is one of the first items you actually install; Cordova. I didn't realise what was wrong and why my changes were not occurring but I will tell you up front that when the document tells you to:
[sudo] npm install -g cordova
what we actually need to do is install Cordova v7. Therefore, my command is more like this:
[sudo] npm install -g cordova@7
Some config files have changed and what I ended up getting was errors with either “platforms.json not found” when saving a file or “hybrid\platforms\android\res\xml\config.xml” not found errors on build.
What I notice with v7 is that when I run the
ojet serve android
command I can see that the console shows a list of files which have been transferred to the emulator:
Before, when using v8, the serve was finishing much earlier at the step:
Resource Hungry Development
Not really a JET issue I know but just a heads up that my machine had a measely 6 Gb of RAM. With Android development, it involves Gradle and Java. This, plus the memory utilisation of the emulator itself, can soon see your system chugging. I upgraded from 6 Gb > 12 Gb and the emulator was able to run correctly.
AVD Confusion
This brings me on to the headscratcher of creating an AVD (Android Virtual Device) when you’ve just installed Android Studio. The instructions say to:
In Android Studio, launch the Android Virtual Device Manager by selecting Tools > Android > AVD Manager.
Now, when I first ran Android Studio, I get this window:
This screen does not have a tools window. I guess that the Studio has been updated and Oracle’s instructions are a little behind.
What I did is created a blank project so I got into the main part of the Studio.
I was then able to click this little button to get to the AVD menu:
Where I could create my device:
Post Project Scaffolding Issue
I found this one after running my initial ojet scaffold command:
ojet create MediumExample --hybrid --appname=”MediumExample” --template=navbar --platform=android
This built the project fine. However, when following the instruction to cd into MediumExample and run
ojet build
I found myself getting an error that a json file was missing. The below GIF shows the issue just after scaffolding and running ojet build android
after changing directory. The GIF goes on to run npm update
and then ojet build android
again which then runs correctly:Setting Paths
The Oracle instructions do a good job saying what needs setting on the path. However, my notes for Windows are as follows:
JAVA_HOME points to a java install directory but NOT as far as /bin. So, for example:
C:\Program Files\Java\jdk1.8.0_171
ANDROID_HOME points to the sdk folder. This directory is available after downloading the Android Studio installer. For example:
C:\Users\Jason\AppData\Local\Android\Sdk
PATH should be extended to have the SDK tools on. Primarily because JET build tools checks to see if
adb.exe
is on your path. Therefore, add this directory (or similar):C:\Users\Jason\AppData\Local\Android\Sdk\platform-tools
Summary
The Oracle JET framework is fantastic in terms of getting you on an emulator. With just a couple of hurdles to jump over you can be developing in the emulator in no time:
Happy JET coding!
Originally published at medium.com on June 3, 2018.
Comments