12

(or is there a way to convert gwt apps to android apps?)

pstorli
  • 121
  • 1
  • 1
  • 3

7 Answers7

8

It is not entirely correct to say that GWT is meant to create code that runs in a browser. GWT translates Java to Javascript and includes ui support and other goodies for web apps. There are a few native application wrappers that take Javascript applications and make them native for Android (or other mobile operating systems) with additional support for device access through Javascript apis. With a glue layer in between GWT and a native wrapper for a Javascript app you have a complete solution from GWT programming to native app.

So, you cannot do this with GWT alone but if you combine GWT with some other libraries it is absolutely possible.

Checkout PhoneGap/Cordova and either m-gwt or GWTMobile. NextInterfaces is built on top of PhoneGap and GWT-Mobile. I'm sure that there are more, but those seem to be the common solutions.

Adam
  • 410
  • 5
  • 13
5

If you want to develop native Android Apps (i.e. written in Java) then you cannot use GWT. GWT is a framework for developing applications that run in a browser: you write your application in Java and GWT will compile it to JavaScript, which will then run in the browser.

If you want to develop web-applications that work in Android's browser, than you can most definitely use GWT. Native support for touch events was recently added to GWT and there are others who are developing widgets, e.g. http://code.google.com/p/gwt-touch/

Stefan
  • 736
  • 4
  • 18
  • Why not if the app is hybrid?! Every Android app can have a WebView, that is a Chrome browser in itself! But the complications with hybrid approach are too much IMO. – WindRider Mar 26 '15 at 14:22
3

GWT apps are executed through a browser, but if you want to develop native Android Apps with the same code, take a look at PlayN. It's quite limited but the resulting app will work on a browser, Android, iOS and desktop

Sange
  • 31
  • 1
1

Here these are the steps to create android app from gwt app

  1. Compile the GWT project. Right click on the project, select Google-> GWT compile and select the project. It will take some time till it gets compiled. The new stuff is created in war directory in that GWT project
  2. Than create new Android Project let’s say GwtTest.
  3. Create libs folder if not generate automatic and paste the phonegap.jar (0.9.4 or above), I used phonegap-1.2.0.jar
  4. Add the jar file on project’s Build path
  5. Copy all generated stuff from GWTProject/war directory to GwtTest/assets directory (gtwproject, WEB-INF, css and html file)
  6. Now in android project’s MainActivity, extends DroidGap instead of Activity. Remove setContentView line and add this line: super.loadUrl(“file:///android_asset/index.html”);
  7. In Manifest.xml file add line of internet permission: uses-permission android:name=”android.permission.INTERNET”
  8. Create xml folder in res directory, put cordova.xml and config.xml file into the xml folder. Now you can run GwtTest as Android Application.

Remember the apk that will be generated while run as android, the size of apk is around 35mb. So make sure that your android device has this enough size.

sagar.android
  • 1,860
  • 17
  • 17
1

Since GWT is Java a lot of your code can be reused on Android. However, some code such as the UI can't. Google inbox reuses 70% of it's gwt code on android. Look at this question too

Community
  • 1
  • 1
jgleoj23
  • 262
  • 2
  • 9
1

GWT is cross-platform and works on WebKit based browsers, like those in iPhone and Android. GWT Mobile WebKit, might be of great help to you.

However there seem to be some issues with Scrolling using GWT in Android while it is seem to be fine in iPhone

Pravin
  • 1,059
  • 8
  • 17
0

if you want to develop the app that would run in the browser and android (and few other platforms on the way) you could use playN

Jacek Kwiecień
  • 12,397
  • 20
  • 85
  • 157