Since long I have been struggling to convert .swf file to .apk file and the best part is I have the solution !!
Even I was searching around the internet for the solution ,and the outcome was obvious none of the methods worked !!! And I believe there are no tools yet that convert .swf to .apk directly.
Most Important !! The phone should be flash player enabled for the apk to work or else just a white screen would appear if the phone isnt flash enabled.
So after so many trials and errors I came out with a solution and it worked perfectly !!
Without any wasting any time lets get started !!
Create an android project eclipse and just include the code !
Here is code.
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String url ="file:///android_asset/Flash.swf"; //Include your swf file here.
WebView wv=(WebView) findViewById(R.id.web_engine);
wv.getSettings().setPluginsEnabled(true);
wv.loadUrl(url);
}
}
XML code
Just replace the main.xml with the following code.
You can use any layouts of your choice, I have used absolute layout.
Its pretty straight forward.
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<WebView android:id="@+id/web_engine"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</WebView>
</AbsoluteLayout>
Thats it !!
Run the project !
Your APK is Ready ! Do comment !
Happy Coding !
Hi, Could u send the eclipse project file to sankar2389@gmail.com
ReplyDeletecan you send me a copy too please
Deletejbanks1994@yahoo.com.au
I have even included the xml code.
DeleteI think you wont be having any kind of errors if you follow the steps.
just create a new project
ReplyDeletePlace your .swf file in "assets" folder
and include these lines
String url ="file:///android_assest/your_file";
WebView wv=(WebView) findViewById(R.id.web_engine);
wv.getSettings().setPluginsEnabled(true);
wv.loadUrl(url);
please mail it to me also at (sunildeepu6@gmail.com).
ReplyDeleteHi pavan,
ReplyDeleteWhere we have to include these lines ? Is it into the .java file locate in com.exemple.projectname ?
Thanks
Exactly !!
DeleteIn d main method.
The complete code is provided above.Have a look.
setContentView (R.layout.main), this code gives an error
ReplyDeleteHi...where can i get that 3 items in bin/res/... folder? classes.dex and so on ...?
ReplyDeleteNext. .. WebView wv=(WebView) findViewById(R.id.web_engine); gives me an error ...
could you help me?
you need to include webview layout !
DeleteI have updated the blog with xml code.
You wont b having any kinds of trouble.
Just follow the steps.
Just paste ur swf file in assets folder.
ReplyDeleteAnd u need import WebView.
Den d error goes off for sure.
Can you be more specific?
ReplyDeleteI would like to include gyroscope control . How can i do that?
ReplyDeleteI think its not possible through this method as this is just packaging up d swf file into an apk......
ReplyDeletexml error
ReplyDeleteCan you please make a video tutorial about this method when ever i try it i get erorrs
ReplyDeletewhat kind of errors ?
DeleteThe xml is code is updated
Just follow the steps u wont be having any kind of errors.
Actually you can simple use a Andaired
ReplyDeletefor converting SWF to APK
For this to work:
ReplyDeletewv.getSettings().setPluginsEnabled(true);
do i have to externally install any plugins on my android device?
No
Deleteyou dont need any.
cool. thanks
DeleteDue to errors in the code U've pasted above I referred the android developer website and made the following changes.
DeleteBut when I run it directly in my android device the app crashes. What could be the problem.
Device: Nexus7(Android version 4.3)
I've installed the adobe flash player plugin as well.
MainActivity.java
package com.example.myfirstapp;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
String url ="file:///android_asset/cards2.swf"; //Include your swf file here.
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl(url);
}
}
Activity_main.xml:
activity_main.xml
Deletexml 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"
i removed the opening closing brackets bcoz i wasn't able to post the xml code
DeleteWhat exactly do u mean by crash ??
DeleteDo u have a blank white screen ?
I get a deprecated error :)
ReplyDeleteFlash is no longer supported(officially) from Jellybean versions.
Deletejust a quick question, should i put the first code at this folder?
ReplyDeletesrc/com/mydomain/gamefolder/filename.java
anywhere in the src folder will do !
Deletei got an error in:
ReplyDeletewv.getSettings().setPluginsEnabled(true);
what should i do??
it says: the method setPluginsEnabled(boolean) is undefined for the type Web settings
I have the same problem, and in .xml it says that AbsoluteLayout is deprecated
DeleteWhere can I download eclipse?
ReplyDeletehttps://eclipse.org/downloads/
DeleteHow to put the .swf file to eclipse android project and do I have to paste your code on the main activity under the src file?
ReplyDeleteCan you please tell us if this codes were still reliable by this time> thank you :)
ReplyDeleteHallo. Another way is using adobe air.
ReplyDeleteLoad swf into air and create apt pack with publish option.
C.
this coding not work bro...
ReplyDeletewv.getSettings().setPluginsEnabled(true);
please help me give solution.. anggihalfiantara@gmail.com
Bro where to convert?
ReplyDeleteشكرا لك ولكن لو سمحت أعطنا كود واضح بدون تفاصيل
ReplyDeleteyoutube-free.com – YouTube HD (2 MB) Videos, Videos, Reviews - Vimeo
ReplyDeletehttps://www.youtube.com/channel/m4cvr6uYcE6yFqVZjm/videos/mygadget+video-free-c/videos-f5c4d9e0/4f5d9e0_v4jmpk?wet=8 youtube mp4
Hard Rock Hotel & Casino New Orleans - Mapyro
ReplyDeleteFind hotels, motels, 양산 출장마사지 and other lodging 과천 출장샵 near Hard Rock 서산 출장마사지 Hotel & Casino New Orleans in New 김천 출장마사지 Orleans. Hotel Information, reviews, photos and more. 성남 출장마사지