May 2013

0

Creating an Android Project

Posted on Monday, May 20, 2013

An Android project is a collection of files and folders that contains the source code, configuration and resource files needed to build an Android app. When we start a new project, we need to create the application structure. Let’s see how the Android studio IDE does this for us.

New Project

Once started, Android studio welcomes us showing this screen:

We want a new project, so, to create a new project follow these steps:
  • Select “New Project...” 
  • Fill in the fields as shown below: 

Application name: It is the name that users will see. This name is shown in the Play Store and in Manage Applications.
Module name: This name is only used inside the IDE. You can enter here the same name as above.
Package name: This name is an identifier for your application, which has to be unique and a valid Java package name. It will be the same during all the application lifecycle.
Project location: A folder on your hard disk where the project will be stored.
Minimum required SDK: Is the lowest version of Android that your application will support.
Target SDK: The highest Android version that the app has been tested.
Compile with: The SDK version against which the app will be compiled. It should be the highest latest version of Android.
Theme: The UI style of your app.
Create custom launcher icon: This allows us to change the default launcher icon and use our own.
Create activity: If this box is checked, the IDE will create a default Activity for the app. An Activity represents the presentation layer in Android, it creates a window to place your UI elements that interact with the user. We can have more than one activity, and switch between them in runtime.
Mark this project as a library: A library is a project whose source code and resources will be used in other Android projects. They can’t be used as an application.
  • We have chosen to create a custom launcher icon, so now we can change the default icon by our own image. Play with the options available until you’re satisfied with the result and click Next

  • Now leave the default option “Blank Activity” selected and press Next

  • Leave these option as they are, and press Finish

Android studio will now build the project structure. After this work is completed you will see this screen:

Now we have our first Android project created. In next posts we’ll learn about the structure of a project and the meaning and use of the files and folders created.

0

Creating an Unity launcher for Android Studio


We have installed Android studio, and now we want to be able to run it from the Unity launcher.
First we will create a .desktop file:

gedit ~/.local/share/applications/android_studio.desktop
Then, paste this inside, changing the Icon and Exec values:

[Desktop Entry]
Type=Application
Name=Android-studio
Comment=Android Integrated Development Environment
Icon=/home/<< your username here >>/android-studio/bin/idea.png
Exec="/home/<< your username here >>/android-studio/bin/studio.sh" %f
Terminal=false
StartupNotify=true
StartupWMClass=jetbrains-android-studio
Categories=Development;IDE;Android;
Now open the folder with Nautilus:
nautilus ~/.local/share/applications


and drop android-studio.desktop to the desired position in launcher.

0

Installing Android Studio in Ubuntu 13.04

Go to http://developer.android.com/sdk/installing/studio.html and download Android studio for linux. It will download a tar file in your Downloads folder. Once downloaded, open Nautilus, navigate to Downloads folder, right click in android-studio-bundle-130.677228-linux and select "extract here".
Now you have a new folder named "android studio". Move this folder to your Home folder.
To run the IDE, open the terminal and type:

cd android-studio/bin
./studio.sh
If you are on Ubuntu default installation, using OpenJava, you will see this warning:

If you press Enter Android studio will start with this window:

Troubleshooting.

Installing Oracle Java SDK:
There are two ways for installing Oracle Java SDK.

First method.

First the easy one. Open the console and type:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
Ok, now let's check the java version installed. Type:
java -version
and you should see something like:
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

Second method:

Go to http://www.oracle.com/technetwork/es/java/javase/downloads/index.html and download Java JDK. Be sure to download the tar.gz corresponding to your architecture (Linuxx86 or Linuxx64).
Uncompress the file:
tar -xvf jdk-7u21-linux-i586.tar.gz (32bit)
tar -xvf jdk-7u21-linux-x64.tar.gz (64bit)
Now let's move the uncompressed folder to /usr/lib
sudo mkdir -p /usr/lib/jvm
sudo mv ./jdk1.7.0_21 /usr/lib/jvm/jdk1.7.0
Now run in terminal:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
Change ownership and permissions:
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.7.0
run:
sudo update-alternatives --config java
and choose the option corresponding to /usr/lib/jvm/jdk1.7.0/bin/java
do the same for
sudo update-alternatives --config javac
sudo update-alternatives --config javaws
Now check the version with
java -version

0

Let's get started. Installing Android studio.

Posted on Saturday, May 18, 2013


The first thing you'll need to start developing Android apps is an IDE. An IDE (integrated development environment) is a tool that provides, in an unique application, such things as a compiler, a code editor, a debugger, a GUI designer, and many other facilities for development.
If you are an experienced Android developer, you may be familiar with Eclipse. Eclipse is an multilanguaje IDE that has been the default tool for Android development so far. During the Google I/O 2013 event, Google has launched a specific IDE for development, based on the community edition of the Java IDE IntellijIDEA.
This software is called Android Studio. The version available to download right now is v0.1, which is a Early Access Preview. This means that there are features not implemented yet, and that the application may have bugs and should not be used in a production environment. Nevertheless, it seems like Google will be pushing this tool as the default development environment for Android applications.
So, as good developers trying to learn as much as possible, and to be up to date, let's see how to install Android studio.


Installing Android studio. 

First of all, you need to download Android studio from developer.android.com. Get the version that match your operating system:
download android studio
Now you have to install it. Let's see how to do it for Windows, and in a future post we will see how to do it for ubuntu.
Double click the downloaded .exe file to let the installation process begin.
Android studio should detect your JDK installation folder:

Be sure you have Java JDK installed in your system previously. If you are running a 64bit version of Windows, Android Studio may not be able to find the correct path to your JDK folder. Be sure you have an environmental variable set up with the following parameters:
name: JAVA_HOME or JDK_HOME
value: your path to your JDK folder, usually "C:\Program files\Java\jdk1.7.0_21"
Now the installation process is finished. You can run the program and import a project or create a new one.