Unity Editor Plugin for creating Eclipse-Android projects

UPDATE: it is now also possible to create Android Live Wallpapers with Unity3d — check out the latest version of AJUnity2Eclipse!

Developing with Unity3d makes a lot of fun, not least because Unity dramatically simplifies the workflow when developing for multiple platforms. This is a huge benefit, especially when developing for different mobile platforms with many different screen sizes and device features. Unity already comes with a great framework to support most of these features. However from time to time, it can be useful to have the ability to write additional native code for a specific platform, namely Android and iOS. For example, we lately developed an app for one of our customers that had the requirement to display a login-screen on startup and user/role management on an additional screen. Of course this could be (somehow) done in Unity, but a native solution was clearly preferred. For iOS this was not a big problem, since Unity builds an Xcode project that can be extended easily. But for Android it was not that simple to get the whole thing to work in Eclipse. If you are familiar with the steps it takes (described here) to make Eclipse and Unity play together, you know how time consuming and error-prone it is. The most annoying part is that you have to copy the contents of the assets folder to your eclipse project, every time you make a change to your Unity project. And it is even worse if you have to integrate everything into your version control system.

Then – last week – we got a similar requirement for a new app and we agreed that this was not an optimal solution. So we decided to develop an Unity Editor Plugin that automizes the entire process and comes up with a one-click solution!
The Plugin adds a menu item to Unity to directly create an Eclipse Android project for your unity project. And the best thing: you no longer need to copy the assets folder! Once you continued working in Unity you can update your Eclipse project with one click! Of course this operation preserves any changes you made to the Eclipse project in the meantime.

We packaged the Plugin and made it available in the Unity Asset Store. After downloading, simply follow the instructions in the next section to set it up.

Using the AJUnity2Eclipse Plugin

First of all, download AJUnity2Eclipse Plugin from the Unity Asset Store and directly import it to your project. Alternatively, if you already downloaded a copy, you can simply pick the AJUnity2Eclipse.unitypackage file from your filesystem and drag it to the Project-Window in Unity.

Before your project can be exported to Eclipse, you initially need to make an Android-Build. Go to “File” -> “Build Settings ..”, select Android from the available platforms menu and click “Build”. Unity asks you to save the APK-file somewhere – you can save it anywhere, you won’t need it anymore. Once you have done this, click the new menu item named “Eclipse export ..” in the “File”-Menu. A small configuration dialog appears: you can leave all settings unchanged. You might want to change the output directory (the directory, where the Eclipse Projects are created – yes there are two projects), but we recommend to use the default, since this keeps your project well structured. Now finally click “Create Eclipse project”.

Note that AJUnity2Eclipse respects your Android Player Settinngs, like Bundle Identifier, Bundle Version and Minimum API Level, so your project is already well set up! By default, a directory called “eclipse-android” has been created in the root folder of your Unity project.

Now fire up Eclipse and go to “File” -> “Import…” -> “Android” -> “Existing Android Code into Workspace” and pick the newly created “eclipse-android” folder, or whatever you specified as output directory. By selecting this folder, you already see the two projects in the list box. Check them both and hit “Finish”. Important: it’s strongly recommended to not check the “Copy projects into workspace” option! Otherwise your assets will not be updated automatically when you make changes to the Unity project.

In some situations, you might see a small red exclamation mark in your package explorer or you might get build errors in Eclipse. To solve this issue, right click on the projects and select “Android Tools” -> “Fix Project Properties”. That’s it!

You can now build the Android project (the one that does not include the word “library” in its name) like you would do normally and test it on your device. The library-project includes the Unity Player binary files and is automatically referenced from your main project – you never have to touch or care about it.

Now you can add Java classes and change the main Activity to whatever you want. If you at any time go back to your Unity project and make some changes, you simply need to make an Android Build an run the export Plugin again. It automatically recognizes that you already created an Eclipse Project and offers you to update it with your latest Unity changes (like assets and scripts).

If you have any problems with the plugin, feel free to contact us or to leave a comment!

 

76 thoughts on “Unity Editor Plugin for creating Eclipse-Android projects

  1. Pingback: Android Live Wallpapers with Unity3d | appjigger studios

  2. Hi,

    we are experienced with projects involving unity and eclipse. Now we are working with QCAR Vuforia plugins. I would like to know if your plugin would work with it.

    Thank you very much
    Best regards
    Diego

      • Hi,
        I’ve bought your plugin intentionally to work with vuforia. I am developing an Android App mixing augmented reality on Android. Now i realize it doesn’t work with vuforia and I’m very disapointed. How long it would take to fix this error?

        I’ve tried also to make a simple Unity App, without Vuforia and it doesn’t work for me. Suddenly, after the splash image of Unity the app is closed.

        Thank you
        Judith.

  3. Pingback: Unity2Eclipse and Vuforia | appjigger studios

  4. Pingback: add adMob banner to your unity3d game using unity2eclipse | appjigger studios

  5. You said that plugin work with free version, but free version does not include build settings for Android. Do i need to purchase extension for Android first to use Unity2Eclipse?

    Thanks
    Boban

  6. First of all this plugin is awesome!

    And I’m just reporting a small issue in your java code generation.

    Within my project MyGrapeFruit13:

    In MyGrapeFruit 13.java, an error was generated in:

    public class MyGrapeFruit 13 extends UnityPlayerActivity

    The problem is your code generation needs to remove the spaces. It’s probably just a small fix.

    Much appreciated and thanks,

    ~Tim

      • No, not line spaces.

        Spaces in the Product Name.

        I.e.

        “GrapeFruit 13”

        as you can’t have a space in the activity name:

        public class MyGrapeFruit 13 extends UnityPlayerActivity

        Should be:

        public class MyGrapeFruit13 extends UnityPlayerActivity

        And the reference in the app.manifest to the activity needs the space removed.

  7. If you could resolve the QCAR Vuforia issues identified a few weeks back, that would be spectacular. It’s quite a mess to get a Unity/Vuforia/Eclipse project working properly now. Be a hero. :)

      • Is it just Android Tools > Export signed application package?

        Is there further things that need to be done?

        Strangely my signed exported project crashes but the one I install on my device by pressing the build button in Eclipse does not.

  8. Strange Flow..

    I am using S Pen and Sphero Unity plugins. The plugins are integrated as .jar and .so in Eclipse, and messages are sent to Unity via UnitySendMessage.

    First time I build from Unity, then use Unity2Eclipse and build in Eclipse, app runs. Even right after, if I build again from Eclipse, app crashes (no changes made). I have to re-build from Unity, then use Unity2Eclipse and build in Eclipse for app to run smoothly.

    Any idea what’s going on?

  9. Hello, good job with the extension :)

    I just bought it, but when I try to run the game in eclipse, the logcat says:
    sharedassets0.assets is corrupted! Remove it and launch unty again.

    I tryed several times, I don´t know what is wrong, using unity 3.5.6f4

    Regards

  10. I purchased AJUnity2Eclipse to add a 3D object inspector into an eclipse project. I had no problems importing it. It is basically a cam orbiting around a number of objects and the function in unity receives the variable for a target among objects. Could you go a bit further on your tutorial, showing how I implement a viewer for a unity project exported into eclipse? That would be of great value to anyone interested in using AJUnity2Eclipse for general purpose subviewer (fragment).

  11. Hi
    I have just bought the plugin and I am always getting a ClassNotFoundException whenever I try to run the project from Eclipse. This is the same whether I try to make a LiveWallpaper or if I try to make an AndroidApplication. I am using Unity 3.4.2f3, Eclipse IDE For Java Developers 1.4.1 with ADT 15. I even tried with a simple scene with a cube and one rotation script and a completely empty scene but they all fail with that same error.
    Any assistance will be much appreciated.
    Many Thanks

    • please check your log what class exactly is not being found.. are you sure your unity android add on is installed correctly? are you able to compile the same project directly from unity to your device?

  12. Hi,
    Thanks for the reply. Yes I can successfully compile the same project from unity to my device. The issue comes in eclipse. Surprisingly, if I close and reopen eclipse, it runs on my device just fine but if I try to run it again without restarting I get the ClassNotFoundException. When checking the Log, it is saying that it cannot find the main class. (I hope this helps)

    • hm.. it looks like your eclipse has some issues.. did you try to create a “regular” hello world pure android project in eclipse and compile it than?

  13. Hi,

    I’ve purchased the plugin and I can’t make it work. I’m using Unity 3.5.6. I followed all the steps and just get a crash after app splash image. I don’t see anything on Logcat. :(

    How can I make it work?

  14. I think I’ve finded the problem. I’m using the gyro on my project. If I include the scene that uses the gyro app crashes. Without that scene project works. Should I include something on the manifest?

    Thanks!

  15. I’ve bought the plugin and it works fine, but i have one problem: in Unity i’ve set the default orientation to “automatic rotation” but the live wallpaper always remains in “portait orientation”. Why? What can i do?

  16. 01-09 00:40:45.292: I/Unity(18468): JNI: Unable to find method id for ‘getVersion’
    etc when used with gyrodroid + Unity2Eclipse

  17. Hi

    I have been using this plugin to make wallpaper.  the problem I have is that when user change wallpaper settings and reset the wallpaper, it sometimes(50%) go black screen.  And if you try to set the wallpaper again after the black screen. it won’t work unless you load some other wallpaper then switch back.  This is a huge issue because almost everyone of my user is going to run into this problem.

    I have tried the city bokeh and unity2eclipse wallpaper you have in playstore. they all have the same problem.  in their case, they don’t have setting page… so i went to reset the wallpapers and they went black after 1-2 tries.

  18. Hi , first sorry for my bad english :)

    I bought your plugin two days ago and did everything correctly like your video tutorials to make an android app just contains a rotating cubes. I exported my eclipse files and imported them to eclipse but when I clicked to run, app didn’t open and gave “force to close” error. I tried to run it on emulator and my HTC Desire . In logcat the problem is ” Caused by: java.lang.ClassNotFoundException: com.bos.bos in loader dalvik.system.PathClassLoader[/data/app/com.bos-2.apk ” Thanks for your help :)

  19. Hi tom

    can you at least give a reply to my post here…   I don’t meant to complain but this is a bit too much.  I sent you an email about the issue a month ago, and you guys ignored it.  and then i post here a week ago, got ignored again.

    If you don’t have time to fix the issue yourself,  if you don’t mind can i look over your code to try to figure out a solution?

     

    thank you.

    • hi,
      we did not ignore you. if so your post would not be published..
      your question has been already answered for a different user. the LWP creation part of the plugin is as mentioned in the asset store experimental yet. currently there is no solution for your problem.
      the implementation of the unity player as android wallpaper service is almost impossible and we are very happy to see it working at all.. we are already working on a new (improved) experimental version that should support newer versions of unity too – its very time consuming and we can only do it in our spare time..

  20. Thank you for your reply.

    Since you guys are working on a new build. do you mind posting an approximation on the release date of the new build? And whether or not the problem will be solved by then? just a rough approximation will be fine. As you might have imagine, I also have a deadline to follow, depend on the your answer, I may have to find other solutions other than waiting…

    Thank you

  21. If you take a look at the initialization code of Sensor.cs, you will notice

    var clsActivity = AndroidJNI.FindClass(“com/unity3d/player/UnityPlayer”);
    var fidActivity = AndroidJNI.GetStaticFieldID(clsActivity, “currentActivity”, “Landroid/app/Activity;”);
    var objActivity = AndroidJNI.GetStaticObjectField(clsActivity, fidActivity);

    var clsJavaClass = AndroidJNI.FindClass(“com/pfc/sensors/SensorClass”);
    var midJavaClass = AndroidJNI.GetMethodID(clsJavaClass, “”, “(Landroid/app/Activity;)V”);

    You might have to change that part of the code to have it use your actual Activity (AndroidJNI.FindClass(“com/unity3d/player/UnityPlayer”)). That would be “com.app.gyro”. And since GyroDroid needs to hook into the main activity for access to the window manager and stuff like that, you need to provide a public static variable named “currentActivity” of type “android.app.Activity” which gets set in the constructor of your “com.app.gyro” to containt your main activity.

  22. Hi, I know this isn’t perfect and still a work in progress, but I know a lot of people have had issues with the app not being able to change ringer volume, it only changes media volume and a lot of people find that annoying. Do you know any fixes? Thanks.

  23. hi !!!

    my LWP crash when on/off screen or switch lock and home screen.Exception below:

    04-07 14:25:50.960: E/AndroidRuntime(1473): at com.google.android.gles_jni.EGLImpl.eglSwapBuffers(Native Method)

    04-07 14:25:50.960: E/AndroidRuntime(1473): at com.unity3d.player.e$a$d.b(Unknown Source)

    04-07 14:25:50.960: E/AndroidRuntime(1473): at com.unity3d.player.e$a$e.f(Unknown Source)

    04-07 14:25:50.960: E/AndroidRuntime(1473): at com.unity3d.player.e$a$e.run(Unknown Source)

    PLEASE HELP ME !

     

    • I think I can help you
      I think the problem is with the codes generated by the plugin. This can be corrected manually. For that I need to analise the codes created on your project. You should sent me a new project for analising. Follow the steps below and send me the files via e mail.
      Steps
      1. Create a simple unity project with a rotating cube and a camera.
      2. Using the plugin export it for creating wallpaper.
      3. Import the project on eclipse and make sure the eclipse project and library project are on the package explorer.
      4. Attach both the projects to e mail and send to me at tinitom26@gmail.com . If your current project is not your secret or personal project. Send it too. Please hurry.

  24. I just want to know that is this plugin doing the the manual steps Given by unity ,automatically ,which means that it is reducing the Long steps to a few

  25. No such file directory .. Trying to load libmono.so….
    When I start live wallpaper logcat log above mentioned error and never display live wallpaperon screen

    • I think I can help you
      I think the problem is with the codes generated by the plugin. This can be corrected manually. For that I need to analise the codes created on your project. You should sent me a new project for analising. Follow the steps below and send me the files via e mail.
      Steps
      1. Create a simple unity project with a rotating cube and a camera.
      2. Using the plugin export it for creating wallpaper.
      3. Import the project on eclipse and make sure the eclipse project and library project are on the package explorer.
      4. Attach both the projects to e mail and send to me at tinitom26@gmail.com . If your current project is not your secret or personal project. Send it too. Please hurry.


  26. @tinitom : Can you Help me Please?

    I am Also getting

    my LWP crash when on/off screen or switch lock and home screen.Exception below:

    04-07 14:25:50.960: E/AndroidRuntime(1473): at com.google.android.gles_jni.EGLImpl.eglSwapBuffers(Native Method)

    04-07 14:25:50.960: E/AndroidRuntime(1473): at com.unity3d.player.e$a$d.b(Unknown Source)

    04-07 14:25:50.960: E/AndroidRuntime(1473): at com.unity3d.player.e$a$e.f(Unknown Source)

    04-07 14:25:50.960: E/AndroidRuntime(1473): at com.unity3d.player.e$a$e.run(Unknown Source)

    We want After Uploading on Playstore. it should be worked for all the Devices.

    Let Us know or Guide us if anything wrong we could have done here. we are testing the App on Nexus 4. and it crashes by giving above exception.

    Thank you,

     

  27. please same one help me…

    I followed the tutorial step by step, export live wallpaper in eclipse, eclipse does not give me any error, install the application on my phone and I get to post a message error:
    the application is locked in abnormal hear … what can I do? how can I fix? thank you very much!

  28. Hey,

    So I successfully for your tutorial working. The only issue I am trying to solve is, that how can you access your cube (game object) from eclipse ? Say I want to do some modifications in eclipse to your cube, how can I do that ?

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *