YouTube: How to Develop in Cordova & Deploy to Android

I've been experimenting a bit with Cordova development in NetBeans IDE. In this YouTube clip, I show you how to get started setting up Cordova, while here you see the creation of a new Cordova application, with deployment to an Android emulator:

However, as you see in the screencast above, the Android emulator is extremely slow. The web abounds with complaints about this, as well as information about Genymotion, the solution to the problem, since Genymotion is a really fast Android emulator.

Once you have a virtual machine set up, together with Genymotion, you're good to go. However, once you've created an APK file, i.e., an archive of an Android application, you need to use the ADB tool to deploy to Genymotion. To Simplify that, I created a small plugin, which adds an action to APK files for deploying to Genymotion. Here you see a small YouTube clip that aims to illustrate that Genymotion is really fast, I must say I was very impressed. Now the only slow part is the building of the APK file.

And here's the Action that uses the ADB tool to deploy to Genymotion.

@ActionID(
        category = "Run",
        id = "org.nb.geny.model.Deploy2GenymotionAction"
)
@ActionRegistration(
        displayName = "Deploy to Genymotion"
)
@ActionReference(
        path = "Loaders/application/x-java-archive/Actions", 
        position = 1600)
public final class Deploy2GenymotionAction extends AbstractAction implements LookupListener {

    private Lookup.Result<DataObject> result;
    private DataObject context;

    public Deploy2GenymotionAction() {
        putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
        result = Utilities.actionsGlobalContext().lookupResult(DataObject.class);
        result.addLookupListener(
                WeakListeners.create(LookupListener.class, this, result));
        resultChanged(new LookupEvent(result));
    }

    @Override
    public void actionPerformed(ActionEvent ev) {
        try {
            execute();
            StatusDisplayer.getDefault().setStatusText(context.getPrimaryFile().getNameExt());
        } catch (InterruptedException ex) {
            Exceptions.printStackTrace(ex);
        } catch (ExecutionException ex) {
            Exceptions.printStackTrace(ex);
        }
    }

    public Integer execute() throws InterruptedException, ExecutionException {
        ExternalProcessBuilder processBuilder = new ExternalProcessBuilder("/usr/bin/adb").
                addArgument("install").
                addArgument("-r").
                addArgument(context.getPrimaryFile().getPath());
        ExecutionDescriptor descriptor = new ExecutionDescriptor()
                .frontWindow(true)
                .controllable(true);
        ExecutionService service = ExecutionService.newService(
                processBuilder,
                descriptor,
                "adb installation");
        Future<Integer> task = service.run();
        return task.get();
    }

    @Override
    public boolean isEnabled() {
        return context.getPrimaryFile().getExt().equals("apk");
    }

    @Override
    public void resultChanged(LookupEvent le) {
        Collection<? extends DataObject> p = result.allInstances();
        if (p.size() == 1) {
            context = p.iterator().next();
        }
    }

}
Comments:

And how can you add this action to Netbeans 7.4?

Posted by guest on February 02, 2014 at 02:40 AM PST #

Yes - as the previous comment, please tell us a bit more! New to NetBeans and Genymotion, but not Cordova/Android...

A few more 'for dummies' steps would be greatly appreciated, since this is the top current resource for getting the "dream team" suite of programs working...

Also - the audio is extremely faint on these videos, though other videos on YouTube are playing fine for me.

Thanks in advance.

Posted by potomac on March 09, 2014 at 02:56 PM PDT #

A bit more about what? Everything in this blog entry is about NetBeans IDE 7.4. What is it exactly that you want to know? How am I supposed to guess if you don't say what it is you want?

Posted by Geertjan on March 09, 2014 at 10:33 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today