I know that questions like this have been asked before, and I have been sifting through them. So here is my situation: I have a decent amount of experience using Java, specifically Eclipse, and I have a game ready that from my current standards, could be uploaded to the Google marketplace.
However, I have the project saved as a Java project. How do I make this project into an android app? I have attempted using the ADT plugin for Ecclipse, and changing the nature of the project file but I am beyond confused regarding how to proceed.
Right now I can click: Run < Run as < Java application.
The goal is to be able to click: Run < Run as < Android application.
I don't know of a streamlined way of doing it. Is your game using Swing as a UI? JavaFX? Is it text?
Regardless, I imagine your game would need to be wrapped in an android activity in some way. e.g. The activity can invoke the browser to run your applet (if your game is an applet).
I'd first create an android project, then copy your source from the java project into the android project. The manifest (R) will be updated with the new resources, etc.
Then you have to finish wiring everything up.
It's going to take more than that. Android has it's own UI system and lifecycle that differs from raw Java. Depending on how you've written the game you may be able to reuse a lot of the drawing and logic code but you going to need to make a lot of changes to the input and allowing multiple screen sizes.
Without seeing your code I can say exactly what you'll need to do but I can tell you it's not going to be as simple as Run As... Android Application.
Although android apps are written in Java code, this doesn't means that it is possible to "translate" a java program or a game in an android app simply clicking a button.
If the game are complex I suggest that you rewrite the game using a framework for develop android game!! You can reuse some logic but sure you have to create all the graphics and readapt the game to run in android devices.
GOOD WORK!!
Be patient and star from here:
Androi Developers
It is not possible. You can implement the application logic in Android in the same way that you used in Java, but you cannot simply convert the java project into Android project. Some packages used in your java project (like swing) can't be used in Android.
Related
I am working on an Cordova Android app. As part of the app, I wrote some Java classes to create a service using WorkManager to poll our server and send a notification to the client on certain events.
Right now the code is invoked through MainActivity.java, where I create the worker, and all of the classes sit in the Java folder under the Android Platform directory. My understanding is that this isn't ideal since my code will get dropped every time we want to reset the platform.
What is the right way to add this code to a project and is there a tutorial that I can follow? Should it all be a plugin?
Thank you in advance.
You should definitely refactor your code into a plugin. Check out the doc here
You can make your plugin for Android only as well.
I would recommend too, to clone a very simple plugin and check out the code.
I'm trying to create a TBS game with an isometric view for android. I began with Android Studio and I've already designed core parts of the UI including login, registration, authentication, and menus. I'm now trying to create the actual game and I've discovered that in order to make a 3d game, the only reasonably efficient path is to create the game from an engine like Unity3d. Is this true? How can I keep the progress I've already made while doing this? For example, is there a way I can launch and instance of the Unity game and pass the variables needed, while the rest of the app is made using Android Studio? Unity uses C# and I'd prefer Java, is there a way around this? The authentication and user information currently uses Firebase, if I need to rebuild this app in Unity, how can I use Firebase? Thanks for the help.
Check out this: https://www.assetstore.unity3d.com/en/#!/content/58337
That is the firebase API that you can use within Unity,
I do also believe that Unity has some features available for UI so you should be able to build it completely within Unity. Also, you can write the scripts in C#, JavaScript but I don't believe Unity supports Java for scripting out of the box.
Edit
I also just realized, C# is pretty similar to Java, you should really like it.
I want to be able to run my Android code/app on Windows/Mac/Linux/etc. but not use an emulator, as they are slow/cumbersome.
I want a real Java SE app, but to reuse my Android code.
My idea is to make an Android emulator using Swing, read the layout files and create the widgets in Swing and map between the 2 UI event models, life cycle, and library classes.
Question is, does such a thing exist already, I googled it, but could not find anything.
Otherwise I will start an open source project for it myself. Anyone interested in helping is more than welcome.
So I created an open source project "Swingdroid" that lets you run Android apps and Java swing desktop applications.
You don't need to use an emulator or change any code. It loads Android layout files and activities and renders them using Swing.
On GitHub here,
https://github.com/BotLibre/BotLibre/tree/master/swingdroid
I totally agree with #muratgu. But, if you just want to parse Android layouts (views) xml files and render them using Java Swing, this is possible and this has already been implemented, before deciding to make your own implementation, you'd better check the wysiwyg feature of UI editor in Android Studio.
I'm trying to begin programming with libgdx (in Windows XP with Eclipse for JAVA - Android) but, as every begining, nothing is clear and every doubt is a big problem.
I have found some tutorials about how to begin to programming with libgdx, but every tutorial found says the same: you must create a PC project for compile the native JAVA code and then create another project for Android who needs the PC project.
It's possible to do it in a easier way (all in only one Android project)? If it's possible, how? It would be really slower? I run my Android projects in my device (a Motorola G) and it seems pretty fast.
All (kind) responses will be appreciated. Thank you.
Are you using the project generator? http://code.google.com/p/libgdx/wiki/ProjectSetupNew
You could use that and simply ignore the non-android projects it creates ,even delete the other ones you don't plan to use (not the main java one though) and run it via an android emulator/device.
You will probably still have to keep the main java project, libgdx is geared towards people that want to compile to multiple devices.
It's been over year since i've used libgdx and i don't recall this being one of the issues i had with it.
The easiest way I find is to actually just put a main method class in your libgdx project. I have a wrapper project for android that invokes my libgdx project but if you look at the example in superjumper source in github you can see they just put a main method class within their libgdx project.
The android project then just delegates to this project.
Consider though, if you do run it directly from a project, you'll need to code in keyboard cursor keys which is pretty easy, you can follow the superjumper example here line 138.
I'm planning to start up a game project for Android 3.0 using Eclipse as IDE. During development, what I ideally want is the ability to build and run the game in JRE on my own OS. That is, I'm developing for Android but I'd rather not test on the included emulator, or on a physical device, until later on.
To achieve this, I'm going to isolate the game logic classes from the platform dependent classes and create an interface for the platform dependent classes to communicate with the game logic classes. For example, to run the game on Android, I'll let the Android specific classes (MyActivity, MyRenderer, etc..) send user input, update the game and then extract the data needed to draw the game to the screen.
But as I mentioned at the start, ideally I want to be able to develop the game logic as a Java project. I'm looking for some advice on how to set this up workspace wise. Should I develop the game logic classes in a separate project, and export as a library? Is there a better way to set things up so that an Android project and a Java project use the same classes? My ultimate goal is fast development in Java, and easy "conversion" to Android.
Should I develop the game logic classes in a separate project, and export as a library?
That would be my approach. Your game logic would create a JAR that your Android project would use.