Friday, August 1, 2014

Releasing a Signed Cordova Apk from NetBeans 8

I'll show how to build a cordova android app in NetBeans 8, and release a signed apk file.

The first part is relatively easy. Start up NetBeans 8, and from the main menu select File -> New Project. This brings up the New Project dialog.

In the dialog 'Categories' open the Samples folder and select the HTML5 subfolder. In the dialog 'Projects', select the Cordova Maps Sample, and click Next, name the project and click Finish:


This generates the application. Open index.html in your root, connect your android phone to the usb and hit F6 to run the project.

You should see something like this on your phone:



That was the easy part. Net beans doesn't have any menu selections to build a signed apk that you can distribute. However, Cordova uses an ant build process, and NetBeans is ant friendly.

So, the first thing you need to do is create your key:

$ keytool -genkey -v -keystore myapp.keystore -alias myapp -keyalg RSA -keysize 2048 -validity 10000

The keystore utility will walk you through some questions. You'll need to enter your app name and password, app alias, alias password and developer name. The remaining can be defaulted.

Now, in NetBeans project explorer, select the files tab, and create a file named ./platforms/android/ant.properties. entering the following contents:

key.store=/home/bruce/Git/myapp/myapp.keystore
key.alias=myapp
key.store.password=password
key.alias.password=password


Now you can right-click on ./platforms/android/build.xml and select Run Target -> release:




It will take a minute or two, and the ant build process will generate  ./platforms/android/bin/MyApp-release.apk, a signed distribution file.







Maybe I was wrong - with a little tlc, NetBeans does have a menu selection to build your apk!



66 comments:

  1. Great tutorial so far, but I do not have a target "release" in my build.xml. Any hint on this?

    ReplyDelete
  2. The build.xml imports commands like release from "${sdk.dir}/tools/ant/build.xml". So you won't see that target in the file if you visually inspect it. But when you right click on it in the project explorer, the command should be selectable - netbeans stitches it all together behind the scenes.

    If you aren't seeing a release command when you right click, my guess is that netbeans isn't finding your android sdk - you can set the path to it at tools>options>Miscellaneous/Mobile Platforms.

    ReplyDelete
  3. Netbeans is already running with android sdk (I am already running my project with the android device). But really no target "release" for the build.xml, see screenshot: http://postimg.org/image/kdpmsylot/

    ReplyDelete
    Replies
    1. I see the problem. You need to use the build.xml in the ./platforms/android folder - you're selecting the build in the ./nbproject folder - that one wraps the cordova command line, which, it seems. does everything except create a signed .apk :)
      I've updated the image on this posting to clarify that better.

      Delete
    2. Thanks for your help, but the build.xml in the android folder has got -no- targets in its popup menu. I can only choose "advanced". I guess I will give it up.
      So far I use the signed package, delete the meta-inf folder in it (http://stackoverflow.com/questions/5089042/jarsigner-unable-to-sign-jar-java-util-zip-zipexception-invalid-entry-compres) and sign it manually over command line :(

      Delete
  4. The way bruce described works with the constallation Netbeans 8.0.0 and Cordova 3.4.0-0.1.2 (thank you Bruce!). Because of a security issue on cordova I needed to update cordova. Now with Netbeans 8.0.1 and Cordova 3.6.3-0.2.13 the commands aren't found by the build.xml file. After comparing both projects I found the following difference:

    The file platforms/android/local.properties in my new project was empty and should be generated/modified automatically.
    # This file is automatically generated by Android Tools.
    # Do not modify this file -- YOUR CHANGES WILL BE ERASED!

    I modified the file manually with the path to the sdk (thank you again bruce for the hint from 2014-10-01), e.g. for windows:

    sdk.dir=D:\\adt-bundle-windows-x86_64-20131030\\sdk

    Now the commands are found by the build.xml file. :)

    ReplyDelete
  5. i dont understand this line., where should I do this code?

    $ keytool -genkey -v -keystore myapp.keystore -alias myapp -keyalg RSA -keysize 2048 -validity 10000

    ReplyDelete
  6. Keytool is a command line utility that ships with the jdk. I just opened a command window in my project folder, and ran it there - in my example, that would be /home/bruce/Git/myapp/

    For a full explanation of keytool and its parameters, you can check out the oracle documentation:
    http://docs.oracle.com/javase/8/docs/technotes/tools/unix/keytool.html

    ReplyDelete
  7. I don't have a build.xml file, but there is a build.gradle file. Did the build process switch from Ant to Gradle, and is this something to do with Netbeans or with Cordova? (Using Netbeans 8.0.2).

    ReplyDelete
  8. I'm also using netbeans 8.0.2. My two existing cordova projects work just fine. But when I just tried to create a new one, the new project wizard fails, says I don't have cordova. What I do have is the newer version of cordova (5.0.0) - The projects that are working for me use Cordova 3.x,. It sounds like Netbeans hasn't kept up.

    I found this on cordova's doc: "Cordova for Android now supports building with Gradle. This is optional in Cordova 3.x, but will be enabled by default in the future, probably with Cordova 4.0."

    If you are married to Netbeans, I'd try downgrading the cordova version. I've actually been using AndroidStudio lately for creating APK's. Intel's XDK works pretty well, too, if you can get past the editor.

    ReplyDelete
  9. This is an excellent post I seen thanks to share it. It is really what I wanted to see hope in future you will continue for sharing such a excellent post. Latest APK File

    ReplyDelete
  10. Many Android users are not very much aware about these applications. It is quite simple and easy to learn more information about these files.
    showboxdownloadsapp.com

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.
    I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging.
    If anyone wants to become a Java developer learn from Java EE Online Training from India.
    or learn thru Java EE Online Training from India .
    Nowadays Java has tons of job opportunities on various vertical industry.

    ReplyDelete
  13. Usually, your Android device will automatically install the APK. However, if the application that you have is not from the Android Market, you need to make sure that you install it manually in your device. This step is needed so that your apps will run successfully without any hitch.ShowBox APK

    ReplyDelete
  14. Absolutely fantastic posting! Lots of useful information and inspiration, both of which we all need!Relay appreciate your work.
    Gb Instagram

    ReplyDelete
  15. It is possible for a person to install APK files directly in devices. This can be done without necessarily downloading them from any network. You can use a desktop computer and use different communication programs.
    appmirror

    ReplyDelete
  16. Excellent and very exciting site. Love to watch. Keep Rocking.
    Diving in Cabo
    Scuba Diving in Cabo

    ReplyDelete
  17. Excellent and very exciting site. Love to watch. Keep Rocking.
    sfs framing
    curtain wall insulation

    ReplyDelete
  18. I am definitely enjoying your website. You definitely have some great insight and great stories.
    metsec wall
    metsec cladding rails
    curtain wall detail
    timber cladding details

    ReplyDelete
  19. Thanks For sharing this Superb article. I use this Article to show my assignment in college. it is useful For me Great Work.
    certified Ethical Hacker nj
    comptia linux plus nj
    mcsa certification
    mcsa certifications

    ReplyDelete
  20. It’s laborious to find educated people on this subject, however you sound like you realize what you’re speaking about! Thanks download lucky patcher

    ReplyDelete
  21. I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. cyberflix tv ios

    ReplyDelete
  22. Please let me know if you’re looking for a article writer for your site. You have some really great posts and I feel I would be a good asset. If you ever want to take some of the load off, I’d absolutely love to write some material for your blog in exchange for a link back to mine. Please send me an email if interested. Thank you! Charlies Magazines

    ReplyDelete
  23. I’ve read some good stuff here. Definitely worth bookmarking for revisiting. I surprise how much effort you put to create such a great informative website.
    Balance CBD
    Best CBD Products
    Buy CBD Oil
    CBD Edibles

    ReplyDelete
  24. Excellent and very exciting site. Love to watch. Keep Rocking.
    data recovery dubai
    iphone data recovery dubai

    ReplyDelete
  25. I am definitely enjoying your website. You definitely have some great insight and great stories.
    Vishnu swasthi yoga
    Yoga Classes in doha qatar

    ReplyDelete
  26. I am definitely enjoying your website. You definitely have some great insight and great stories.
    we buy homes
    cash for your house
    lease to own
    rent to own

    ReplyDelete
  27. This comment has been removed by the author.

    ReplyDelete
  28. This is helpful for kowning about cordova apk signed version. Thanks admin.

    Learn more about:

    Snaptube

    Ccleaner Pro

    Ccleaner Pro

    Clas of clans update

    ReplyDelete
  29. Good artcile, but it would be better if in future you can share more about this Keep posting.
    Mejor Farmacia Online
    Comprar Farmacia Online
    Farmacia Online en Chile

    ReplyDelete
  30. Keep up the good work , I read few posts this web site and I conceive that your blog is very interesting and has sets of fantastic information.
    hard drive data recovery
    data recovery sharjah
    data recovery abu dhabi

    ReplyDelete
  31. I am definitely enjoying your website. You definitely have some great insight and great stories.
    porn pics
    erotic images
    sexy pics

    ReplyDelete
  32. This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information...
    Versace Eros

    ReplyDelete
  33. In light of humble device, picking information transmission and choice of online gaming, the broadness of the online games are beginning at now right hand in all regards rapidly. The gaming reputation is growing peevishly, so as the degree of players and the degree of people who see it. latest breaking news

    ReplyDelete
  34. To each blog out there, ricocheting on Google News isn't some purposeless wealth. It's a key that effects their very survival. The thing is, Google has gave structures concerning necessities for when to set a site on its system of updates. article

    ReplyDelete
  35. Abstain from losing handle of the blog by getting your own space name similarly as your own encouraging record. At whatever point you use free encouraging, you will encounter trouble getting fabulous web record rankings, and besides you ought to endure from the standards of the host. Premium Blog

    ReplyDelete
  36. To effectively run a blog, you'll need bits of knowledge. That will connect with you to get these examinations you should visit trades distinctive social gatherings and blogs. Also, an enormous measure of the time the exhaustive system who comment in your blog are uncommon at making new data that you just may perhaps never have perceived about going. To be huge in the present blogging globe, you have to consistently consider fresh material that people need. Blog

    ReplyDelete
  37. News blogs are the best wellspring of chosen giving bits of finding out about any space of intrigue. There are unequivocal blogs proposed to cover present principle speaking news, determining and breaking news from around the globe. These are commonly open on the web. With the PC being utilized for fantastically more than choosing, you can discover news sources saddling the intensity of this medium. You have various fantastic to go online blog which give centered substance. Magazine Blog

    ReplyDelete
  38. Thanks you so much for your efforts blog, If your are looking for a creative mobile app development in mumbai, Appslure provides one of the best and professional app development company in mumbai.
    Mobile app development company in mumbai

    ReplyDelete
  39. With these sites people are truly conveying their contemplations, their viewpoints, and notion on somebody specifically or point. Regardless, now and again these blogs can similarly be manhandled in light of the way that it is routinely used to defame an individual and de advances that particular person. Blogging type sites are basically sited where people share their very own decision and points of view and they have their very own profile on it with the objective that others can see them. information

    ReplyDelete
  40. For simple energy fans you can seek after music, films, accounts and logically on the web. Notwithstanding whether its news blogs concentrated on the dispatch of a film or covering the activities of your favored star, there's information available as it happens. Online magazine

    ReplyDelete
  41. Besides you have all out opportunity of articulation and conclusion and can concur or differ with everything without exception that is being said. Additionally, on the off chance that you discover something valuable and need to impart it to your partners you can without much of a stretch do as such with the snap of a catch. Online magazine

    ReplyDelete
  42. They additionally state that an appropriate equalization of everything (their insight, their composition style, their SEO) is sufficient to make them effective as business bloggers. Online magazine

    ReplyDelete
  43. The you have is very useful.The sites you have referred was good. Thanks for sharing...
    Kroger experience

    ReplyDelete
  44. Business blogs are useful in light of the fact that for the most part they talk about understanding. What's more, I imagine that involvement in business checks more contrasted with any book guidance. information

    ReplyDelete
  45. Excellent .. Amazing .. I’ll your blog and take the feeds also…I’m happy to find so many useful info here in the post, we need work out more techniques in this regard, thanks for sharing.

    farmacia

    ReplyDelete
  46. A great blog is informative in a real manner. Some of the time, bloggers are searching for actualities that are not regular to the readers so they will convince them to check everything inside the blog. These are a portion of the characteristics of a great blog. todaypost magazine

    ReplyDelete

  47. Thanks for sharing knowledgeable information about electronic cigarettes.Its an interesting one but in the case of vapourlites david it is to my knowledge that the authority for medical recommendations is spread across many different bodies and frameworks in the UK.
    https://tellthebelll.us

    ReplyDelete
  48. Keep in mind it is your own appearance. There are a few people who blog to help other people. These blogs are typically wellbeing related. Individuals blog about a specific ailment or illness they have that others may likewise experience the ill effects of. Blog

    ReplyDelete
  49. In all likelihood, you have thought about the articulation "blog." Even in case you are not an eager peruser of them on the web, you have certainly thought about the term eventually. You may even be intrigued about what the term insinuates and what exactly a blog includes. For those that may need their advantage answered, here is a brief survey of what a blog is: Online magazine

    ReplyDelete
  50. In case you run an IT association, purchasing in to blogs on technology can empower you to pick up capability with the latest examples in the market. You can guide your gathering to inquire about and devise new designs to be put into your organization or thing. Smart Home

    ReplyDelete
  51. Thanks for a wonderful share. Your article has proved your hard work and experience you have got in this field. Brilliant .i love it reading.
    iphone data recovery kenya
    data recovery services nairobi

    ReplyDelete
  52. Why this is suggested? Wouldn't i be able to simply manufacture a daily blog website and reveal a specialty for money-making arrangements, later on? Obviously, you can definitely include some money-making thoughts a while later. However, when you begin using that you should monetise your daily blog, regardless of whether simply with the end goal of a little pocket money, at that point you'll approach an online business using the right mindset. Business Nyo

    ReplyDelete
  53. As said before, Finance is a gigantic subject with numerous classes. Indeed, even before beginning your blog composing, settle on what classification you need to compose. Also, significantly increasingly significant is to adhere to it. This is significant on account of the nearby between connection of these classifications that can undoubtedly divert you to an alternate class all together, and without your insight. For eg. You may begin composing 'On the best way to deal with your Personal Finance'. There comes one pivotal point in it about reimbursing your high need obligations. Here you can without much of a stretch wind up expounding more on that and disregard different purposes of planning. https://helpwithfinance.org/

    ReplyDelete