Android and Ant - java

I have tried my hands on compiling a Java project with Ant from scratch. Is it possible in Android too? If I have only the source code, can I compile the project? If so, how?

Yes, it is.
Read the android developer website for more details.

There are a few things to keep in mind:
Android supports ant build scripts, the developer website, and the tools provided, show you how to do this easily.
But if you want to support different versions of android with a single set of scripts the best way is to write custom ant scripts (a single set, that will compile for all versions) for this as SDK Tools v5, v6, v7 and v8 all do ant builds differently. This requires some effort and planning.

Related

Can I edit xml/java codes of my android app on Brackets Editor?

I am new to Android app development. I have a source code and would like to modify some xml/java codes. Can I use the Brackets editor for this? I don't want to use Android studio as it's a bit complicated for me.
If you really want to, you can edit source files in an editor of your choosing and build the app manually via terminal. Actually, this is how it's done on Continuous Integration systems.
Typically Android projects are using Gradle build system, and come with Gradle wrappers. After you are done editing, you can just invoke it to assemble the release APK signed with proper keys as discussed in How to create a release signed apk file using Gradle? thread. Note that it would require you having downloaded Android SDK and configured your paths properly, which would be tricky for a beginner, yet completely automated in a proper IDE.
If you are unlucky, it could be an old Eclipse project, or using some less popular build system, like Ant.
As you are new to Android development, I think you should go the more simple route and just download Android Studio and import your project.

Android Studio - How does a library project used in an app follow with the app-release.apk

I'm using a library (https://github.com/PhilJay/MPAndroidChart) for plotting data in an android app. When app-release.apk is created by the program it is ready to be installed on the tablet I use for testing.
What is puzzling to me is how the parts of the library, which i use, follow with the release. In other scenarios, for example in Visual Studio and c# - program being installed on Window machine, libraries require dll files to be installed and registered on each targeted machine. In my scenario the library is written specifically for Android, but if I somehow managed to include a c++ or a c# library in my Android app using tools like libstdc++ or MONO, would it work the same way when it comes down to app-realease.apk?
Are all classes in a library included in the app-release.apk or just the parts that I use?
Thanks in advance and please let me know if the question is unclear before downvoting it!
Normally, when you build your APK, all the libs you have imported (jars) are included and transformed to dex files, as the rest of your code. So, yes all the classes are included, even if you don't use them.
You can use Proguard to remove them from the APK. Look at this post :
Use Proguard for stripping unused Support lib classes

How to integrate PhoneGap into an Ant build?

I've been reading up on PhoneGap and really like it. I'd like to see if I can use it with GWT to write Java apps that deploy to many different platforms (web, mobile web, android, iphone, winphone, etc.).
It looks like the PhoneGap SDK comes with different versions of cordova.js for each native platform you want to support. So it looks like the Ant build will have to somehow package the GWT-generated JavaScript to the correct version of cordova.js:
3098DJU39I4F9IF9.html + cordova-android.js
3098DJU39I4F9IF9.html + cordova-iphone.js
3098DJU39I4F9IF9.html + cordova-windows-phone.js
I'm generalizing here, and I know those aren't the correct file names (although, obviously, 3098DJU39I4F9IF9.html is the GWT-generated code).
But then something has to kick-off PhoneGap's ability to take each of those pairings and produce the correct packaged container: an APK, IPA or XAP for each platform respectively.
So I first ask: how does a PhoneGap developer normally go from 3098DJU39I4F9IF9.html + cordova-android.js to having a myapp-android.apk, or from 3098DJU39I4F9IF9.html + cordova-iphone.js to having a myapp-iphone.ipa? Does the PhoneGap SDK have a command-line tool that does this?
Once I understand that much, I'm trying to figure out how to automate this packaging/binding process from an Ant build. Are there any known Ant tasks that already do this? Or do I need to kick off a shell from inside Ant and just run the shell commands? Thanks in advance!
#rooftop is right, you have to build the native app using native SDK even if you are using Phonegap. The benefit lies in creating the UI and behavior of the app using HTML5, CSS and JS.
So, if you are not using any of the native functionality or custom Phonegap plugins, you can just have a bare minimum package structure of native apps for each of the platforms and then simply move the correct files into the concerned folders (in Android it is assets folder) of those package structures using copy task of ant. Thereafter, you can use command line compile and build tools specific to each platform to build and package the app.
Hope this helps.
EDIT: Added more details about other platforms
Basically, all SDKs contains command line tools. In fact I used to compile and build from command line, to automate the process, even for standard Windows apps (Console, Web Apps etc) which are usually performed via Visual Studio's easy to use environment. You can see this for extended tools over standard SDK for Windows phone development.
Similarly iOS is based on UNIX so there we get the power of majority of command line tools for compile, build and automation and XCode provides command line tools for building.
Further for Android, you may find this helpful.
You should really be using Cordova, the renamed version of PG that is an Apache project now. Command line tools were recently released for Cordova. I have not used them so I am not sure if they will help you with building or not. Typically the way you woul create the binary for the device, say an IPA file for iOS would be to actually use Xcode and the native SDK to compile and package your app. This means you need all of the native tools and SDK for each platform. There is also a hosted service from Adobe that will build the native bits for you for a fee. It used to be called phone gap build, not sure if that is still the name. You might want to look at IBM Worklight, as it does many if the things you asked about. The developer edition is free an Eclipse based for the IDE.

Is it possible to use Rake to automate the build process for Android applications?

I'm looking into automating my Android application build process. I've been reading up mostly on whether to use Maven or Ant, but both seem to have big drawbacks. For my .NET work I use Rake and was wondering if it is possible to use Rake or something similar to build for Android development as well. There doesn't seem to be much information available online about this.
Is anybody using Rake to build android ? How has your experience been ? Do you recommend this instead of using Maven or Ant ?
Do you need any plugins to make this work ? Are there any available ?
Rhomobile uses rake for Android builds and other as well. But it's a cross-platform framework in which you use ruby. I believe not many use rake for Android. Did you try gradle android plugin? Here's more on gradle itself.
Gradle is great because it's lighter than maven, still having it's power. It Handles your library dependencies and is easy to customize. Highly recommend.

How can I develop for Android in Emacs?

I have gone through the Android guide for other IDEs, and I've got the basic build and install working fine using ant and a simple Emacs compile command. I'm aware of some of the existing tools for developing Java and XML in Emacs. I've also seen the EmacsWiki page recommending two Emacs packages, EmDroid and android-mode
I'd like to hear what people recommend, in terms of Emacs packages, small functions, or just workflows.
As a side note, I have decent familiarity with Eclipse, and I did setup the ADT plugin. However, emacs is my primary editor, and I'd like to see how I can use it here.
I too use Emacs for my Android development.
Although I do not use any Emacs packages for it.
Simply write in Emacs and then from a terminal use the android-sdk (ant, android, keytool, jarsigner, adb).
You can always use M-x compile from within Emacs, but I usually prefer a plain old bash shell for Android.
Sorry my work flow isn't really exciting.
Currently android-mode.el is in better shape, plus you can easily fork it to add your own submissions to the developers over Github.
Both of the modes are pretty basic however, and just give you a set of functions to call the various Android development tools.
You are probably aware of jde and ant-mode.el - if you're not, I've just mentioned them.
They'll help you with the general Java / Ant support you'll need for Android SDK development.
You can try Android-emacs-toolkit. http://code.google.com/p/android-emacs-toolkit/
Android-emacs-toolkit helps to build android development environment on emacs. It contains a emacs major mode which help to develop android sdk and ndk program.
It provides support for create new avd, launch avd, create new android project, build and rebuild Android sdk project, build and rebuild Android ndk project, install and uninstall apk, run executable ndk project, output emulator log on emacs.
This toolkit tested on WindowsXP/7, Ubuntu11 with android-sdk and android-ndk-r7.
For building Android itself (ie. AOSP, CyanogenMod...), look in the $(TOP)/development/ide/emacs directory. ATM, you'll find android-common.el, android-compile.el and android-host.el.
These can be used to make modules/packages inside Emacs, replacing commands like mm and mmp.

Categories

Resources