LITTLEBIGPLAY.COM - FREE ONLINE GAMES   DONAGAMES.COM - GAMES FOR GIRLS     CONTACT ME    
FLASH GAMES | FOR KIDS | ANDROID ONLINE GAMES | TABLET GAMES | ANDROID GAMES | WEBSITES


TUTORIALS

1. How to load SWF with JAVA and package it as APK file!
2. LET'S MAKE SOME MONEY - ADDING LEADBOLT ADS!
3. FINDING PAIRS #1 - FLASH GAME TUTORIAL
4. FINDING PAIRS #2 - PUBLISHING AN ANDROID VERSION WITH ADOBE AIR
5. FINDING PAIRS #3 - ADDING MORE FUNCTIONALITY TO OUR ANDROID GAME
6. EARNING EVEN MORE MONEY WITH REVMOB - ADDING REVMOB TO OUR ANDROID GAME!!

Do you want to see more tutorials? Please buy me some beer! :)





1) How to load SWF with JAVA and package it as APK file

Welcome to my first tutorial in which I show you how to load the SWF file into JAVA and export it as APK file, that you can install on your Android phone or publish it on Android market! Please note this is just a basic tutorial that doesnt show any advanced functionality and it does not explain the code, it will just show you how to run the SWF file of the game on your Android phone via JAVA! If you dont have enough experience with JAVA, please use the same project names and file names as shown in this tutorial to avoid any potential errors.

What are the advantages of loading flash files via Java?
- You dont need to have AIR installed to be able to run the flash game on Android phone! User must have just Flash player installed!
- You will potentially get more downloads on Android market (because many people dont have AIR installed on their phones)
- You can integrate mobile ads with some serious revenue

You will need:
- install the SDK http://developer.android.com/sdk/installing.html
- swf of the game (for the purpose of this tutorial name it game.swf)
- 3 icons - 72x72.png, 48x48.png, 36x36.png

If you have these 3 things ready, lets start! ;-)

1) Open Eclipse and go to File->New->Android Project


2) In the Project Name type the name of your project (I used MyGame), (use default location or change), click NEXT


3) Select the Target Name. Choose Android 4.0 since we want to be able to run this game also on the newest android versions! Click Next!


4) Fill in Application Name, Package Name and click FINISH


5) You should see your project now in Navigator as shown on the screen below


6) Also in the project location you specified you should see these folders and files as shown below
There are 2 important folders - assets and res.

Assets - put here your swf file game.swf!


res -> drawable-hdpi, drawable-ldpi, drawable-mdpi - these folders will store the game icons - 72x72.png (drawable-hdpi), 36x36.png (drawable-ldpi), 48x48.png (drawable-mdpi)! Overwrite the files inside these folders with your icons.


7) Now go back to Eclipse and open main.xml in res->layout folder. There is graphical layout displayed by default, click on the second tab main.xml below the window and rewrite the code to match the code below


<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

8) Open MyGameActivity (or how you named it) in src->com->somedomain->MyGame-> and change the code so it matches the code below



package com.somedomain.MyGame;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.webkit.WebView;

public class MyGameActivity extends Activity {
WebView mWebView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
mWebView.setBackgroundColor(Color.parseColor("#000000"));
mWebView.loadUrl("file:///android_asset/game.swf");

}
}

9) Open AndroidManifest.xml and change the code to what you see below


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.somedomain.MyGame"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:screenOrientation="landscape"
android:label="@string/app_name"
android:name=".MyGameActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

Thats all! :-) Lets test it and export the APK file!

10) Test - Click the green circle with white rectangle (shown on the picture - left top corner) and choose Android Application, click OK! If you didnt make any mistake you should see the Android emulator start. You will not see the actual game, because the emulator cant display SWF files (you should see just the black screen), but you should see if there are any errors during compilation!


11) To export the APK file you need to click File->Export.. as show below


12) Choose Android -> Export Android Application


13) Click on Browse -> choose your project and click OK


14) Now you need to use your existing keystore or create new keystore if you dont have it already. Once done, press Next
.

15) Find your keystore in Alias and type password


16) Choose a destination APK file and press Finish!


That's it! You can run the APK file on your phone now or publish it on Android Market! :-)

- Download the final project files here. It includes also APK of the project, if you install it on your phone and run it you should see a swf file with MY GAME text!

- Check out the games I created and published in this way on the Android market https://market.android.com/search?q=littlebigplay or visit my game portal http://www.littlebigplay.com


TUTORIALS

1. How to load SWF with JAVA and package it as APK file!
2. LET'S MAKE SOME MONEY - ADDING LEADBOLT ADS!
3. FINDING PAIRS #1 - FLASH GAME TUTORIAL
4. FINDING PAIRS #2 - PUBLISHING AN ANDROID VERSION WITH ADOBE AIR
5. FINDING PAIRS #3 - ADDING MORE FUNCTIONALITY TO OUR ANDROID GAME
6. EARNING EVEN MORE MONEY WITH REVMOB - ADDING REVMOB TO OUR ANDROID GAME!!

Do you want to see more tutorials? Please buy me some beer! :)





 
 
Copyright © shajby 2010-2011