Thursday, 10 April 2014

Android Studio (Preview) 0.5.4 : Simple Tutorials + solution for "Gradle project sync Failed : Failed to set up project : You can find all errors in the 'Messages' window, under the 'Gradle Sync' tab."

My notes on using Android Studio:

I will try to write three simple apps to investigate the use of Android Studio. And try to see whether Android Studio is better or Eclipse is better. Although now from the User Interface seems Android Studio can immediately display the preview beautifully, most of us are familiar on using Eclipse to develop Android application.

A. Very Simple Hello Word Application.

Below are the Steps to create a new Project:

1. Click "File" on the top menu, the click "New Project..."

The following screen will pop up and shown:
And you can fill in the Application name you want and choose the SDK correspondingly. 
The option "Create activity" is default selected.
Then fill in the form and clicked "Next":

3. After that you can choose which kind of activity to be created, here I just simply just the empty activity as it is just a simple testing hello world application:


4. Next you can enter the Activity Name and click "Finish"

Oops... Suddenly this error occurred:

Failed to set up project 'HelloWorld':
         
You can find all errors in the 'Messages' window, under the 'Gradle Sync' tab.

When I clicked the link "Open Messages Window", one occurrence is found:



dependencies {

    compile 'com.android.support:appcompat-v7:19.+'

    compile fileTree(dir: 'libs', include: ['*.jar'])
}

My solution for the above problem is as follows:
As I found that when I used the cursor to touch the 'com.android.support:appcompat-v7:19.+' , a message is shown: " ... but the SDK installation does not have the "Extra > Android Support Repository" installed. ..."

Thus after I open the SDK Manager and installed the component it mentioned. My project can run smoothly the Gradle Sync works fine.

5. You should now see the "Hello World" text shown in the mobile emulator screen. Seems Android Studio will automatically help you to insert the HelloWorld string for relevant project name.

If the text is not shown, you can drag the "Textview" from the left hand side and amend the content in Properties -> text. After that you can click extract and create the resource if you like to create one.

6. Click the "Save" button and then click "Run". After the gradle sync process run successfully, a form will pop up. Then you can choose which device or emulator to be used for running the application. Wait until the whole process done. Then you can check your phone or device. The application should be well installed on it.


You should see the following screenshot on your phone or on your emulator:
I have amended the text ... haha


Remarks:
At this stage, although the steps are little bit simpler compare to Eclipse as it does not need to touch any codings, I spend more time to finish this simple HelloWorld just because some error occurred. I hope these errors will just appear at the beginning. Nevertheless, it is just a preview version so facing errors is the thing that I expect. Next, I will try to make an Alarm Clock application as I saw the clock elements are ready on the left hand side at the Design Panel which seems very convenient to me.

Using this Android Studio to build apps seems don't need to involve codings or technical stuffs "yet".

Tuesday, 4 March 2014

Android Studio - Solution for : Exception raised during rendering: Unable to create temporary file

The interface of Android Studio looks good.
That’s why I would like to have a try on it. But when I first started the Android Studio, I faced the following error related to the rendering stuff, after I search for a while and tried several solution, I finally solved the problem~~~ T3T~
The error I saw in the Android Studio is as follows:

java.lang.SecurityException: Unable to create temporary file
 at java.io.File.createTempFile(File.java:1875)
 at javax.imageio.stream.FileCacheImageInputStream.<init>(FileCacheImageInputStream.java:100)
 at com.sun.imageio.spi.InputStreamImageInputStreamSpi.createInputStreamInstance(InputStreamImageInputStreamSpi.java:69)
 at javax.imageio.ImageIO.createImageInputStream(ImageIO.java:357)
 at javax.imageio.ImageIO.read(ImageIO.java:1351)
 at android.graphics.Bitmap_Delegate.createBitmap(Bitmap_Delegate.java:152)
 at android.graphics.Bitmap_Delegate.createBitmap(Bitmap_Delegate.java:135)
 at com.android.layoutlib.bridge.bars.CustomBar.loadIcon(CustomBar.java:145)
 at com.android.layoutlib.bridge.bars.CustomBar.loadIcon(CustomBar.java:125)
 at com.android.layoutlib.bridge.bars.StatusBar.<init>(StatusBar.java:47)



The way I solved the above problem is to upgrade the java version.
After I upgrade my java version (please be aware that I upgrade the jdk version) from Java(TM) SE Runtime Environment (build 1.7.0-b147) to Java(TM) SE Runtime Environment (build 1.7.0_51-b13).

Then the problem is solved. Let see this solution works for other people or not :)

Below is after the problem is fixed. When I first launch the Android Studio, the below screen will be shown.

Remarks:
Even if you cannot fix the error, you can simply click the blue hyperlink “Turn off custom view rendering sandbox” shown on the image above then the screen will show the same image as below as well J



Wednesday, 5 February 2014

Solution for : eclipse error: Plug-in com.android.ide.eclipse.adt was unable to load class com.android.ide.eclipse.adt.internal.launch.LaunchConfigTabGroup. An error occurred while automatically activating bundle com.android.ide.eclipse.adt (269)

I haven’t started my Eclipse for a while but when today once I start my Eclipse, the following error is shown:

error: Plug-in com.android.ide.eclipse.adt was unable to load class com.android.ide.eclipse.adt.internal.launch.LaunchConfigTabGroup. An error occurred while automatically activating bundle com.android.ide.eclipse.adt (269)

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOsr_HTqeN03ak5U6w1mGmEnyJ97ha30CJVYuGU_8nFYJ8zkbdv_eAbkS00zcZMHMGQGK2JprD2o8iqsr223_ksHm0mUtWuGvmLIezy7Yt9U5CydWEw6M2nGYDqbu7EwN0udxcQI1pl64/s1600/eclipse_err1.PNG


As I have installed the Android plugin to my Eclipse previously, so from the log, I can understand that it should be related to the plugin stuff and my Android project.

After doing some research on the web for a while again, I tried the following steps in order to eliminate this error.

Here comes the solution.

***Please be reminded that kindly back up this folder first before your delete it. This is just to in case that even when you delete the folder but this error still retain. It is always good to backup first as you can roll back later. ***
The solution will be locating your eclipse workspace folder and then delete the folder under this path:                          .metadata\.plugins\org.eclipse.e4.workbench

After that restart your eclipse. It should be all fine now :)

Remarks:
The Eclipse version in this case is Kepler Release.

Moreover, Please be aware that .metadata\.plugin folder is the folder used to store the configuration of your workspace. Thus if you delete the folder, it may cause unstable of your workspace or even you cannot use it again. As a result, please reconfirm when you delete the folder I mention in the solution.

Saturday, 7 September 2013

Mobile App Notes: Phonegap (Cordova 2.9.0) + Jquery Mobile + Eclipse

I have used phonegap before but at that time it is not yet related with Apache cordova. Now let's try to develop an app with this new version :)

Jquery mobile is famous for the User Interface design and it is easy to use with phonegap. Moreover jquery mobile can provide some default settings on buttons and other stuff which is quite convenient thus in order to ease my works, this time I will try to develop an Android App with phonegap and jquery mobile.

I used Eclipse for this app development. Install one if you don't have it. It is a tool that people normally used for java and Android application development.

Moreover, you have to install the Android plugin for eclipse before you start building the Android app.
Go to ADT Plugin Installation Page to take a look and install the plugin.

After installed the ADT Plugin, restart the eclipse.

Steps to create the simple Android Application:

1) Go to PhoneGap Official Site to download phonegap and go to JqueryMobile Official Site to download the jquery mobile's latest version. 

2) First create a new mobile project at eclipse:

File->New->Android Application Project-> Next

Fill in the application name and keep clicking "Next" , you can change some settings if you want. Then click finish.

A Android Project has been created.

Will continue to write this tomorrow, have sacrificed my time to play with Unity 3D (*ノ_<*)

---------------------------------------------------------------------------------
This the second part of creating a simple Android application using cordova/phonegap with the use of jquery mobile.

For part 1, we have create a new Android Project. Now
after created the Android Project in Eclipse and downloaded the latest version of Phonegap (Cordova).

Follow the steps below to start including the cordova into the Android Project:
1.     Copy the cordova-2.9.0.jar into the 
Android 
project folder called "libs". This jar located at phonegap2.9.0/lib/android  <- this can be replaced with the jar of other application platforms you would like to use
2.     Next create a folder called "www" under the "assets" folder in the Android project.
3.     Then copy the cordova.js file into the "www" folder you created in step 2. This javascript file (js) is located at the same folder of the cordova-2.9.0.jar (i.e. phonegap2.9.0/lib/android)
4.     Go to the "src" folder, amend the coding of the  MainActivity.java like this:

package com.test1; //This is my package name

import org.apache.cordova.DroidGap;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends DroidGap {

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  super.loadUrl("file:///android_asset/www/index.html");
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.main, menu);
  return true;
 }

}

5. Create a index.html file under the "www" folder, feel free to create the html file~ e.g. 

<html>
<body>
<h1>>333333333333333<  Here we arE~~~~</h1>
</body>
</html>


After you right clicked the Android project and choose “Run”, you need to choose the device or emulator to deploy the application. Then after the application have been deployed to the devices or emulator, you should see the android emulator or your phone is showing the screen like this:

o(><)o
Cheers~



Wednesday, 4 September 2013

Unity3D START!!!!!!!!!!!!!!!!! - My solution for this exception: BCE0021: Namespace 'System.Collections' not found, maybe you forgot to add an assembly reference?

Yesterday night I have built a simple Unity3D project. It can be compiled thoroughly and it works.
However no wonder why when I tried to open the project and run the project today. I got this weird error:


BCE0021: Namespace 'System.Collections' not found, maybe you forgot to add an assembly reference?


This error happened when I wanted to open a JavaScript file in Unity3d and then the MonoDevelop crashed......


I have deal with this error for few minutes and discovered that it is just because you have a file named "System"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ...... That's all...

My solution is that I just changed that file into another name instead of using the word “System”. After that my MonoDevelop works fine and I can continue to build my simple Unity3D game ( )

So it is probably that the word "System" is definitely not good to be used as a file name. Need to be quite aware of that.

Cheers~~~(≧∇≦

Remarks:

The version of Unity3D I used is Unity4. However the MonoDevelop always freezes thus I am going to switch to other editor soon.

In together with Unity3D probably I will use Blender to build some 3D images and products so that I can use them in Unity3D and build apps. The reason for using Blender is because it is free J Maya and other products are quite expensive. Will try to stick to Blender and see.
Moreover, just one more point, the Unity3D has an app on Android which allows us to test the project immediately which is very convenient.