can I develop android applications using gwt?

前端 未结 7 2743
無奈伤痛
無奈伤痛 2021-02-19 23:35

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

相关标签:
7条回答
  • 2021-02-19 23:39

    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.

    0 讨论(0)
  • 2021-02-19 23:43

    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/

    0 讨论(0)
  • 2021-02-19 23:49

    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.

    0 讨论(0)
  • 2021-02-19 23:55

    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

    0 讨论(0)
  • 2021-02-20 00:01

    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

    0 讨论(0)
  • 2021-02-20 00:03

    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

    0 讨论(0)
提交回复
热议问题