1. Are you ready for the Galaxy S20? Here is everything we know so far!

Gradle in Android for a simple helloworld js app

Discussion in 'Android Development' started by neonwarge04, Jan 30, 2016.

  1. neonwarge04

    neonwarge04 Lurker
    Thread Starter

    Hi,

    as I move deeper into software development, I always encountered some hurdles. Some kind of complexities in development which at first I haven't had the chance to try out. For example I tried git for svn, now I learned it and it has integrated in my soft dev most of the times for the past 2 years. I realized I should have used it before and save a ton headache managing my project history. Now here comes build systems. I just heard of it on my early days as Android dev a year ago and never even bothered by it since eclipse and similar IDEs has this play button which is going nice for me. I clicked it and my app runs on my phone. As I learn more about this build system from here, I realized I traveled into a very bad path. I am eager to believe, building systems like gradle is very very important and I got no knowledge of it whatsoever. I barely grasp gradle and build systems in general. I am developing an app which has a component written in js just for fun.

    There is gradle link for js here. The guy who posted the article seems to me working on an enterprise app. This is complicated and confusing for me. Its too much to handle. What I basically need something like this.

    I develop a js app which I place in myjsproject folder. Obviously it has an index.html file, I have js src files in src/ folder and lib files in lib/ folder (I have libraries like Polymer, and Require.js; I am not planning to pull them off in a central repo). As I developed my app and feel quite good about it I wanna run a build script which will copy all the contents of myjsproject folder (I am not into minification yet, just copy and run the index.html file) into my Android projects app/assets/www folder. Because what I usually does is to copy paste file back and forth and maintain two project files. It is very stupid, noobish, primitive. I don't like this, gradle does make sense at this point. I also need to run a command like
    Code (Text):
    1. gradle appbrowser
    , which basically do the same thing but instead copy the file into a bin folder (minification can be done here along with combining amd modules via require.js) and then paste it to my xampp/htdocs/js/myjsproject/. There I open it from my browser. Simple. I wanna have a groundwork in Gradle so I am starting small :p.

    Also I wanted to augment gradle build script of my Android project app such that each time the Android Studio run the build script for my Android project it also run the build script for myjsproject which basically copies all the files inside excluding the *.gradle files and git files and pasting them to app/assets/folder

    Unfortunately even this simple build script of copy pasting a code inside the root directory doesn't work. I
    Code (Text):
    1.  
    2. task copyTask(type : Copy) {
    3.     doLast
    4.     {
    5.         println 'Copying files'
    6.         from 'copyContents'
    7.         into 'sample/'
    8.  
    9.         println 'Finished copying'
    10.     }
    11. }
    12.  
    13. task build (dependsOn : 'copyTask') <<
    14. {
    15.     println "building..."
    16. }
    17.  
    I don't know why this doesn't work. copyContents folder is empty. There is not even a sample/ folder in the root directory.

    Even the company I am working on I believe doesn't deal with build system. So I don't know how I could learn gradle by doing just as I learn Git by doing it. User Guide isn't helping. They keep saying its like "Maven /Ant". The hell I don't even know those two! Some part of gradle doesn't make sense to me maybe until I met the day I need to use it? I am confuse as to how to utilize gradle in my project. I am in dire need of automation as of the moment.
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...
Similar Threads - Gradle Android simple
  1. Dan Coleman
    Replies:
    0
    Views:
    638
  2. Pravinkumar Putta
    Replies:
    2
    Views:
    1,338
  3. RebelCommander
    Replies:
    0
    Views:
    993
  4. Pei Liu
    Replies:
    1
    Views:
    1,322
  5. Sathish Mohan
    Replies:
    0
    Views:
    352
  6. kannanthayumanavan
    Replies:
    5
    Views:
    1,845
  7. Mekhi Greene
    Replies:
    3
    Views:
    644
  8. ClintonBrits
    Replies:
    1
    Views:
    477
  9. mcpixel
    Replies:
    0
    Views:
    547
  10. luwana50
    Replies:
    1
    Views:
    10,633

Share This Page

Loading...