Gradle in command line or Android Studio? - android

Android studio provides lots of plugins and features to run the task more quickly. There are two ways to run Android applications that I know,
Download Gradle and run in cmd. (Without Android Studio)
In Android Studio generally, all developers do in this way.
I know the major differences. Can we run below tasks without Android Studio and with installed Gradle and in CMD.
E.g.
I want to clean build in cmd without Android Studio.
Generate signed APK in CMD.
Run test cases in CMD.
Make sure to run above tasks there will not be any dependency on Android Studio.

The two ways are totally the same.
Also, with Gradle, you do not run Android applications. Gradle is your build tool which has a plugin for build steps necessary for Android applications. Android Studio offers you an integration of the mentioned build tool, but you are free to use this integration or a standalone Gradle installation.
However, take care about different versions of Gradle, this may cause your build files to only work with either the standalone or the Android Studio Gradle installation. Also, it may be possible, that the two installations do not share temporal folders or global properties, as they expect them in different directories.
For my part, I use the Android Studio Gradle installation with the tool integration, but switch to a standalone installation for continouus runs (e.g. a Gretty container).

Related

Build (not develop) your android app .apk (gradle build) on server?

I'm trying to build(not develop) an android application on server. I've the whole native android code on the server, which I need to build according to some modification done on the server.
I've been looking all over the internet but couldn't find any detailed solution. All I got to know was I might need Jenkins or some CI tool (which I think is time consuming as I'll need to get them installed on server and then all the android dependencies).
Initial idea was to build the .apk file via some python script which contains all the gradle commands in it.
How can i do this?
Android apps can be built easily on a system that doesn't have any Android tools installed by applying the Android SDK Manager plugin for Gradle to your project.
When running ./gradlew assembleDebug (or whatever task), then Gradle will be installed and then all Android dependencies, including the SDK tools, build tools, platform versions and other dependencies will be installed automatically.
You can run this simply on the command line yourself, or automate to run after every commits to source control easily with Jenkins (it's easy to install on a wide range of operating systems).
You need to install Stand-alone SDK tools and suitable SDK packages to your server to build Android software.
When you have all installed and good, you can build APK with gradle , e.g.
(Linux and Mac)
./gradlew assemble

Writing a Gradle for a previous Project

I just started an android project for school, and I have to edit an android application that was built by previous students. I was given source files and apk but no gradle.
I imported into Android Studio and tried to run the build when I saw that I couldn't. I have looked up documentation online for the past 4 days and have so far come up with nothing other than downloading the gradle-2.7 files and running:
build gradle
in my computers shell.
Is there an easy way to build a gradle? Perhaps some tools or such? Or will I have to go through the files and write all the gradles myself?
Android Studio uses a Gradle wrapper to fully integrate the Android plugin for Gradle. You can build your Android apps from within Android Studio and from the command line on your machine or on machines where Android Studio is not installed.
Android studio comes bundled with gradle and in the screenshot I can see gradel folder, gradlew and gradlew.bat and build.gradle files. So (hopefully) all you need to take care is build.gradle files.
I would strongly suggest you to go through link
If you have time go through this course

Building Android app with Jenkins & Gradle

I'm a devops engineer, and my company is building their first Android app. For all of our other projects, we've used Jenkins to handle builds.
I've read quite a few tutorials on getting android building on Jenkins and they all seem to rely on Gradle. I'd like to get out in front of the devs a bit and start the job. Is it possible that the app that they build doesn't support Gradle? What scenarios are those, so I can influence decisions?
Maybe Gradle isn't the latest thing, if not, what is?
Is it possible that the app that they build doesn't support Gradle?
It is possible that they are not currently building the app with Gradle, but highly unlikely that the app could not be built with Gradle.
What scenarios are those, so I can influence decisions?
The most likely scenario where they are not building with Gradle, is that they use the Eclipse IDE to develop the app. Eclipse projects have historically been built more often with Ant or Maven. But an Eclipse project can be built with Gradle. That said, configuring an Android project to be built with Gradle is not a requirement to build that project with Jenkins. Ant, Maven, and other build tools play nice with Jenkins also. So, if your dev team is using a build tool other than Gradle, that shouldn't be a blocker for you. You should be able to accommodate them, if that's going to cause less friction.
Maybe Gradle isn't the latest thing, if not, what is?
I'm not sure about latest, but Gradle does currently have a lot of momentum as the build tool of choice for Android projects because it is the default build tool for Android Studio (which is positioned to replace Eclipse as the default Android IDE).
So, my advice would be to ask your dev team what IDE and build tool they are currently using, and go from there... (if they use Eclipse and you want to build with Gradle: Is it possible to use the Gradle build system for Android with Eclipse?)
Source: At the company I work for, I develop two Android apps and make daily builds with Jenkins. A few months ago I switched from Eclipse (Ant) to Android Studio (Gradle).
I hope this was helpful. I have not answered many questions on here so I'm not entirely sure I'm doing it right. :)

How can I use Android Studio 1.0 without Gradle or Maven?

I just want to start a simple Android project and quickly make changes and install it on my phone using simple right-click --> Run as an Android application.
I could do this in Eclipse but I really like Android Studio's (i.e. IntelliJ IDEA's editor features). But because Android Studio has all the Android dependency bundled with it I decided not to install IntelliJ IDEA and rather went with Android Studio 1.0.
I am getting plethora of errors with Gradle which I am not even adding in my project while trying to start one, neither can I find a way to remove Gradle from my project. My Android Studi 1.0 installation is standard installation on Windows 7 and I can see gradle 2.2.1 in plugins folder but it just doesn't work. I expected everything to work out of the box as its just a dummy app with default UI components selected from SDK while creating the project.
Is there a way to simple app building experience in Android Studio without dealing with Gradle and its dependency and set-up?
Android Studio uses Gradle as its build engine. There is no way to use one without the other. That said, the "New Project" wizard should get you up and running quickly.

Android autobuild + tests

what is the easiest way to run an autobuild of android app, that includes compiling, running tests and creating an apk file (using ANT)?
thanks!
Use the android tool from the SDK. If you already have something that's a running project in Eclipse you just need to run the android project in the base directory of your project:
android update project --path .
And it should generate the ant build scripts needed to be able to build debug and release apks from the command line.
As for testing, there's also options to create a new test project using the android tool: http://developer.android.com/guide/developing/testing/testing_otheride.html The docs in there go through details for automating and setting up test projects.
If you're looking for a way to automate all the stuff check out one of the continuous integration servers, like Jenkins (http://jenkins-ci.org/) They're tailored to watch a software repository, automate some actions, and monitor the output.

Categories

Resources