Log in or register to post comments

How to combine an android project with unity project

February 16, 2011 - 6:39am #1

hello,

I've developed an android application who establish a connexion to a database on a distant server. (java code on eclipse)
In the same time the application starts the camera to track images and render 3D objects. That's why i want to use unity Qualcomm extension.

I did everything, i created my trackables , i got my qcar-resources and config files.But i cannot understand how to combine my java code with my unity project.

All i can see is a plug in for the android device!!

I didnt found any documentation on internet explaining my problem!!
Hope someone can help me..

How to combine an android project with unity project

July 19, 2017 - 5:03am #34

Hi MiraMakram, 

For me also near like your requirement only did you find any thing?. Can you tell how to get target name from unity generated android code?

How to combine an android project with unity project

April 20, 2017 - 12:19pm #33

hello :) 

In my unity application I need that when the user do an action ( move the play button ) , to send a Bluetooth signal to a micro controller. I already have my android app that send / receive bluetooth bytes to the MCU (with android studio ) . Is there a method to integrate both in one app so that while the user is moving the button Bluetooth signals are sent and received concurrently ? as 2 threads running together ? 

Thanks in advance :) 

How to combine an android project with unity project

July 13, 2012 - 6:16am #32

with Unity 4 :) 

Eclipse project generation for Android. 

When building to Android you can now generate an Eclipse project instead of directly publishing from Unity. Doing this allows for easier integration and iteration when using third party libraries and you can also add Android specific code at this step. Once deployed to a device debugging can also be done via Eclipse.

Re: How to combine an android project with unity project

May 9, 2011 - 6:03am #31

I think you have to be careful about calling finish() on the Unity activity. Unity has chosen to kill the process outright on finish() to ensure everything is unloaded, but of course this will have undesired results if you are trying to return to a previous activity. I would post a question about this in the Unity forums.

- Kim

Re: How to combine an android project with unity project

May 8, 2011 - 4:50am #30

Hello guys,
I have got a new problem with unity and qualcomm in an android project.
I want to finish the PlayerActivity, to return on another Main Activity.
When I call finish, the activity disappears correctly but after I have an error and the previous Main Activty recall the constructor and Oncreate.
Look at this error :" Activity manager : failed to set app changed!"

A screen shot of the log :https://docs.google.com/leaf?id=0B8eiX7rlv1bMYmIxMGVmM2QtMzYxOS00MTYxLWI5NWEtMDIxZDk1NzU3OGRi&hl=en

Thanks for your reply...
Simon.

Re: How to combine an android project with unity project

March 28, 2011 - 6:02am #29

It's work!! Thanks you very well!:)
I developp this application for a student project (Gobelins school). I hope It was finish in june and send the the link on this forum to download the apps.

Re: How to combine an android project with unity project

March 28, 2011 - 4:06am #28

you have to import unity classes.jar files into eclipse.For that go to In project properties, go to Java_Build_path->Libraries, select "Add External Jar...", navigate to UNITY_INSTALLATION\Editor\Data\PlaybackEngines\and aroidplayer\bin and add classes.jar.I thought error will go.

Re: How to combine an android project with unity project

March 28, 2011 - 2:04am #27

Hello,
I have tested with a new unity project, new android lib project and a new Android project... I am in front of this error : https://docs.google.com/leaf?id=0B8eiX7rlv1bMYjZkZWQ4NzQtNzRiOS00MjY5LTk5MjUtYThhYjk0ZDg4NzIz&sort=name&layout=list&num=50
[COLOR=Red" /> Could not find class 'com.qualcomm.QCARUnityPlayer.QCARUnityPlayer', referenced from method com.qualcomm.QCARUnityPlayer.PlayerActivity.initUnityPlayer[/COLOR" />

I have linked QCAR.jar and QCARUnityPlayer.jar ("Add External JARs" in the Properties of the Main project).

I havn't got error in my code.

Please help me! :)

Simon

Re: How to combine an android project with unity project

March 24, 2011 - 10:55am #26

yes kim is right.I thought when you check the libs folder in eclipse coming in assest or as separate folder which you make as library.So you can debug your program by copying .so files present in your library to your android project.

Re: How to combine an android project with unity project

March 23, 2011 - 5:28pm #25

I believe the .so files only need to be in the Unity project when you build. You should be able to find them in the Plugins/Android folder. You can also try copying them to the Eclipse project's "libs" folder, which you might have to create.

- Kim

Re: How to combine an android project with unity project

March 23, 2011 - 5:19pm #24

I using Unity version 3.1.0f4. I have copied all asset in my eclipse projet.
The libraries files (.so file) are in the eclipse project or in the project library?

I have linked the jar classes files in the eclipse project but I have the same error.

Simon.

Re: How to combine an android project with unity project

March 23, 2011 - 4:32pm #23

There are two possible causes that I can think of:

1) Make sure that you have applied the Unity 3.2 patch to your Unity project (if you are using Unity 3.2 or 3.3). Is is available under the Unity section here: http://ar.qualcomm.com

2) You need to copy the config.xml and qcar-resources.dat files from the Unity StreamingAssets folder into the "assets" folder of your Eclipse project.

Let me know if either of these help!

- Kim

Re: How to combine an android project with unity project

March 23, 2011 - 3:24pm #22

Hello everybody,
I have tested the Milan_cool method to intergrated unity in a java eclipse projet but I have got an error on the libQCAR.so and libQCARUnityPlayer.so loading.
Have you got any idea ?
https://docs.google.com/leaf?id=0B8eiX7rlv1bMMzk1YjJjNjYtZjllOC00OTNjLTk4NDUtZDdiNjkyYzMzMzM4&sort=name&layout=list&num=50
This error appear when in want to build my eclipse projet on the phone.
Can you help me or give me a zip file with all project (2 eclipse project and 1 unity project)?

Sorry for my bad english!

Re: How to combine an android project with unity project

March 11, 2011 - 9:38am #21

Okay, what you are trying to do here is not at all for beginners, nor is it required for using the QCAR Unity Extension. You'll want to write your entire application in Unity, and handle tracking events with Unity scripts. You won't need Eclipse at all to do this.

Please follow the guide under the AR Extension for Unity 3 section on the main SDK page: http://ar.qualcomm.com

Begin with the Quick Start guide, we tried to make Unity integration as simple as possible! Let me know if you have any questions, but please open a new thread for those.

- Kim

Re: How to combine an android project with unity project

March 11, 2011 - 9:29am #20

Hi Kim, thanks for your quick reply.
When I mark the Unity project as a library and I add it to my Java project, Eclipse creates in gen folder com.qualcomm.QCARUnityPlayer package, which contais the R.class file (automatically).

I´m a beginner in developing with Qualcomm SDK and Unity, and I don´t know if i´m in the right way. I want to develop an Android AR application. Basically, the application should recognize a few markers and tracking them. Each time a marker is recognized, I want to display a message (or a 3d object or something like this). Is possible to do it with Unity?

Thank you!

Re: How to combine an android project with unity project

March 11, 2011 - 8:15am #19

First of all, I want everyone to understand that this Eclipse project setup is only required if you want to extend the Java code. Even then, there are other ways to do this (e.g. building your custom JAR and placing it in the Plugins/Android folder in Eclipse). Unless you are extending the Java code, you can simply build and run your QCAR project inside Unity like normal. In either case, you need the Unity Android add-on to build your app.

For your particular problem, make sure you didn't skip this step:

Quote:

Mark this project as a library in the properties window for the project. (Right click on the project name, go to Properties->Android and mark "Is Library".)

The R file shouldn't be included if the project is marked as a library in this way.

- Kim

Re: How to combine an android project with unity project

March 11, 2011 - 8:00am #18

Hello everybody! I´m very interested in developing an Augmented Reality App in Android with Qualcomm SDK and Unity 3D. I´ve made a simple scene (only with an ARCamera) in Unity and I want to install it in my Samsung Galaxy S. First of all, I´ve followed these steps:

Milan_cool wrote:

hii kim,
As i had followed the steps in http://forum.unity3d.com/threads/71607-Integrating-Unity-and-Eclipse for integration of unity3d with qualcomm plugin and eclipse ide.
# Set up your Unity Android project as you would normally and hit Build.
# Enter your project folder, go to Temp/StagingArea.
# Copy all project files to a new folder.
# Import this folder as a new Android project in Eclipse.
# Mark this project as a library in the properties window for the project. (Right click on the project name, go to Properties->Android and mark "Is Library".)
# Create a new Android project in Eclipse. This will constitute the Java part of your project.
# Add the Unity Android project as a library to your new project. (Right click on the project name, go to Properties->Android, select "Add...", add the project.)
#then i add QCARUnityPlayer.jar to my new android project in eclipse.for that i go to java build path and add external jar file in eclipse.then i add this jar file
#Move the assets folder from the library project to the my new project in eclipse ide.
then i create activty say MyActivity.
As per you
i write the activity class as follows
public class MyActivity extends com.qualcomm.QCARUnityPlayer.PlayerActivity{
protected void onCreate(Bundle savedInstanceState) {

// call qualcoom UnityPlayerActivity.onCreate()
super.onCreate(savedInstanceState);

// print debug message to logcat
Log.d("OverrideActivity", "onCreate called!");
}
then i gave camera permission in androidmanifest file also give all permission as the permission given by androidmanifest file in qualcomm plugin in unity3d.
After this i create apk from eclipse ide as usually we follow.After installing camera is automatically opened.But when i placed in my own marker the ar things didnot come in camera.
I also see in ddms for this.Camera callback methods called.But the ontrackebleFound() and ontrackableLost() is not callled.So thats why the arthings didnot come when i focus camera on my own marker.Whats problems may be?

but I´ve a problem. I add the Unity Android project as a library and the QCARUnityPlayer.jar to my new android project in eclipse. At this point, my project has
-gen/com.qualcomm.QCARUnityPlayer package (with R.class inside)
-Referenced Libraries/QCARUnityPlayer.jar/com.qualcommQCARUnityPlayer (with R.class inside too)
When I build the project, I get the following error:
java.lang.IllegalArgumentException: already added: Lcom/qualcomm/QCARUnityPlayer/R$attr;
How can I resolve it?

Thanks a lot.

Re: How to combine an android project with unity project

March 11, 2011 - 6:30am #17

http://forum.unity3d.com

If your Java method is part of the extension you've been writing I think Unity will find it. So now it's just a matter of understanding the syntax of these AndroidJavaObject calls. If I had to guess, it works something like this:

package: com.my.package
class: MyClass
method: int getValue()

Use something like this to call the getValue method (assuming it returns an int)

AndroidJavaObject jo = new AndroidJavaObject("com.my.package.MyClass");
int value = jo.Call<int>("getValue");

Look to Unity scripting documentation for more details: http://unity3d.com/support/documentation/ScriptReference/AndroidJavaObject.html

- Kim

Re: How to combine an android project with unity project

March 11, 2011 - 12:06am #16

Hi kim,
thankx for that.I found something.I dont want to write jni.I want to access a method in java ,i am referring below as example.
AndroidJavaObject jo = new AndroidJavaObject("java.lang.String", "some_string"); // somewhat expensive
int hash = jo.Call("hashCode"); // first time - expensive
int hash = jo.Call("hashCode"); // second time
i have a method getValue() in java .How to modify the above code to access getValue() method.
Should i include jar file in the project for doing this?

Re: How to combine an android project with unity project

March 7, 2011 - 11:35am #15

I suggest carefully reading the Unity Plugin documentation (look at the Android sections). They provide a wealth of information for communicating between Unity scripts, native code, and Java.

http://unity3d.com/support/documentation/Manual/Plugins.html

- Kim

Re: How to combine an android project with unity project

March 7, 2011 - 8:46am #14

Hii kim,
i am back.I want to call a function in unity3d which is defined in the eclipse ide.i want to save the state of object which is defined in eclipse ide and i just access the object in unity3d .Is dere any ways to proceed this?

Re: How to combine an android project with unity project

March 3, 2011 - 12:05am #13

thankx kim.it works again thankx for that.I will ask furure for further help for my project.

Re: How to combine an android project with unity project

March 2, 2011 - 2:28pm #12

Try copying the raw/QCAR folder from the StagingArea to the assets folder of your new Eclipse project. You're probably missing the config files necessary to find the targets.

- Kim

Re: How to combine an android project with unity project

March 2, 2011 - 11:13am #11

hii kim,
As i had followed the steps in http://forum.unity3d.com/threads/71607-Integrating-Unity-and-Eclipse for integration of unity3d with qualcomm plugin and eclipse ide.
# Set up your Unity Android project as you would normally and hit Build.
# Enter your project folder, go to Temp/StagingArea.
# Copy all project files to a new folder.
# Import this folder as a new Android project in Eclipse.
# Mark this project as a library in the properties window for the project. (Right click on the project name, go to Properties->Android and mark "Is Library".)
# Create a new Android project in Eclipse. This will constitute the Java part of your project.
# Add the Unity Android project as a library to your new project. (Right click on the project name, go to Properties->Android, select "Add...", add the project.)
#then i add QCARUnityPlayer.jar to my new android project in eclipse.for that i go to java build path and add external jar file in eclipse.then i add this jar file
#Move the assets folder from the library project to the my new project in eclipse ide.
then i create activty say MyActivity.
As per you
i write the activity class as follows
public class MyActivity extends com.qualcomm.QCARUnityPlayer.PlayerActivity{
protected void onCreate(Bundle savedInstanceState) {

// call qualcoom UnityPlayerActivity.onCreate()
super.onCreate(savedInstanceState);

// print debug message to logcat
Log.d("OverrideActivity", "onCreate called!");
}
then i gave camera permission in androidmanifest file also give all permission as the permission given by androidmanifest file in qualcomm plugin in unity3d.
After this i create apk from eclipse ide as usually we follow.After installing camera is automatically opened.But when i placed in my own marker the ar things didnot come in camera.
I also see in ddms for this.Camera callback methods called.But the ontrackebleFound() and ontrackableLost() is not callled.So thats why the arthings didnot come when i focus camera on my own marker.Whats problems may be?

Re: How to combine an android project with unity project

March 2, 2011 - 6:38am #10

You say your are extending com.qualcomm.QCARUnityPlayer.PlayerActivity. Are you adding your own logic to onCreate/onResume? If so, you have to be careful not to interrupt the existing PlayerActivity initialization. Be sure to call super, and let the super class handle the creation of the UnityPlayer (this is not something you can safely overwrite).

I'll need more details of what you are trying to accomplish to help debug further.

- Kim

Re: How to combine an android project with unity project

March 2, 2011 - 12:54am #9

Hi kim,
i am working on unity qualcomm ar plugin using unity3d gaming engine.In my project i have one image target and plane as child of that image target.So when i look at that imageTarget the plane will appear on that image target.i am trying to integrate with eclipse ide following http://forum.unity3d.com/threads/71607-Integrating-Unity-and-Eclipse,and also some steps given by you i.e extending com.qualcomm.QCARUnityPlayer.PlayerActivity.
Now when i open my app the Qcarunityplayer activity is opening but it is not recognizing the ar marker,it is not giving plane over imageTarget so thats why i have concluded it is not recognizing the armarker..what may be the problem???

Re: How to combine an android project with unity project

February 22, 2011 - 8:50am #8

It works !!

Thanks Kim

Re: How to combine an android project with unity project

February 22, 2011 - 6:54am #7

It looks like these models use quads instead of triangles. OpenGL cannot render quads (rectangular primitives), so you need to triangulate the model before exporting it. Any 3D modeling program should be able to do this.

- Kim

Re: How to combine an android project with unity project

February 22, 2011 - 6:22am #6

hey Kim,
I have two 3D models : a monitor and a cpu. I'm trying to give them a one color texture but its not working!!

What do u think the problem could be?

Re: How to combine an android project with unity project

February 21, 2011 - 6:12pm #5

One common texture problem is flipped Y coordinates, you may want to try flipping your texture image vertically and resaving it. If that doesn't work I would need more info about the problem, and perhaps a screenshot, to help.

- Kim

Re: How to combine an android project with unity project

February 21, 2011 - 5:32pm #4

Thanks Kim for ur reply.
But i decided finally to work on the ImageTarget sample modifying it.

At the end i was able to get what i want for my application but i have a small problem.

I'm not at all expert in 3D models. I downloaded some of them on the net(.obj).
Converted to (.h) with a pearl script.

Anyway i have a problem with textures, i didnt manage to apply the texture on all my 3D model. i have always some parts of my model where the texture is not applied and its not beautifull to see :d

I think its easy to fix but for the moment i didnt find a solution.
Can u help??

Re: How to combine an android project with unity project

February 16, 2011 - 10:49am #3

Also, if you haven't already read this, here is Unity's explanation of how to extend their Java Activity:

http://unity3d.com/support/documentation/Manual/Plugins.html
Section titled: Extending the UnityPlayerActivity Java Code

Extending the QCAR Java Activity is similar, except that you extend com.qualcomm.QCARUnityPlayer.PlayerActivity instead of com.unity3d.player.UnityPlayerActivity.

- Kim

Re: How to combine an android project with unity project

February 16, 2011 - 10:44am #2

Yes, sorry, the Unity extension isn't currently built with the idea of extending the Java code in mind. That said, you should be able to accomplish what you want. Here are a few hints:

The QCAR Java activity is named com.qualcomm.QCARUnityPlayer.PlayerActivity. Currently this is the first Activity run by the application, but you should be able to create your own Activities that do some startup work before creating this one. In this case, be sure to change the AndroidManifest to start your Activity first.

Another option is to create an Activity that extends com.qualcomm.QCARUnityPlayer.PlayerActivity, and add your own logic to the onCreate/onResume/onPause methods (be sure to call super!)

In either case, you will need to put QCARUnityPlayer.jar (located in the Plugins/Android folder) on your build path for your Android project.

I know this is a quick introduction to the solution, so let me know if you have any questions!

- Kim

Log in or register to post comments