Log in or register to post comments

Building QCAR unity package within Eclipse

April 15, 2012 - 1:32pm #1

Hi,
I am facing problem when building QCAR unity package project into eclipse.
I made the following steps:
1- following the below thread
https://ar.qualcomm.com/arforums/showthread.php?t=326&highlight=unity+project
2- Adding QCAR.jar, QCARUnityPlayer.jar to android project
3- Extending the class PlayerActivity
the result after running on Nexus s:
The app has stopped unexpectedly.
After debugging:
Exception: java.lang.unsatisfiedlinkerror Could't load mono: findLibrary
.....

I am stuck for a day with this error Please help.

Re: Building QCAR unity package within Eclipse

March 30, 2012 - 5:34pm #33

I've heard about this before but I'm not sure what causes it. I suggest browsing the web, e.g.

http://stackoverflow.com/questions/2680827/conversion-to-dalvik-format-failed-with-error-1-on-external-jar

- Kim

Re: Building QCAR unity package within Eclipse

March 30, 2012 - 5:36am #32

Hi, I done all step of unity-eclipse build setting but i cant solved "Conversion to Dalvik format failed with error 1 " error. Please help me because about 3 days i try to solved that problem.
If someone upload a basic unity-eclipse-qcar application there i can start developing.
I read all forum messages and apply all changing but i cant success.Please help me.Thanks a lot.

Re: Building QCAR unity package within Eclipse

November 22, 2011 - 4:59am #31
ksiva wrote:

Those files should automatically be added to the StagingArea/libs/armeabi-v7a folder. Are you checking "Is Library" on this project? Follow the guide again carefully, make sure you didn't miss a step.

http://unity3d.com/support/documentation/Manual/Android-Integrating%20Unity%20With%20Eclipse.html

- Kim

Thanks for attention.
Solved.
Actually, I forgot to overwrite AndroidManifest.xml from stagingarea to my custom project.

Re: Building QCAR unity package within Eclipse

November 21, 2011 - 3:58pm #30

Those files should automatically be added to the StagingArea/libs/armeabi-v7a folder. Are you checking "Is Library" on this project? Follow the guide again carefully, make sure you didn't miss a step.

http://unity3d.com/support/documentation/Manual/Android-Integrating%20Unity%20With%20Eclipse.html

- Kim

Re: Building QCAR unity package within Eclipse

November 21, 2011 - 7:34am #29

Hello,
I end up with messages:
E/Unity(18608): Unable to find QCARWrapper

Adding
libQCAR.so
libQCARUnityPlayer.so
libQCARWrapper.so
to project also does not help..
However my unity GUI is visible, just video is not there.

Re: Building QCAR unity package within Eclipse

September 28, 2011 - 8:40pm #28

OK Kim :)... Now im able to start the application in my android after i created another class called MyActivity that extends com.qualcomm.QCARUnityPlayer.VirtualBallPlayerActivity
and replaced this activity com.qualcomm.QCARUnityPlayer.QCARPlayerProxyActivity in AndroidManifest.xml with MyActivity.

The virtualBall application should show a soccerball moving while spinning when a finger touch the ball on stones imagetarget.
But my application only displays helloworld instead of running my virtualBall, because my main.xml layout only having the helloworld string.
I've attached my androidmanifest.xml file here..

So, now how can i call my application running instead of showing the hello world??:confused:

One more question,
Why should i extend the main VirtualBallPlayerActivity with another activity??
Y not play my app with that main activity itself??

Re: Building QCAR unity package within Eclipse

September 28, 2011 - 6:58pm #27
ksiva wrote:

I'm not sure what you're trying to do here. It looks like you have the QCAR Dominoes sample and your own MyVirtualBallPlayer1Activity class. How does Unity fit into this?

I wouldn't try using the native QCAR samples and the QCAR Unity extension in the same project.

Let us know exactly what you're trying to accomplish.

- Kim

Hi Kim, tat shouldnt be Dominoes...:confused:

This is what i did:
1) In Unity Pro, created new project, imported qcar-unity-virtualbuttons-android-1-0-6.unitypackage, opened the scene, build & run the project using Android option.
2) after that worked on my android, i followed the Unity steps on converting my working project to eclipse.
3) Now stuck at deploying that eclipse project to my android.:(

Re: Building QCAR unity package within Eclipse

September 28, 2011 - 6:29pm #26

I'm not sure what you're trying to do here. It looks like you have the QCAR Dominoes sample and your own MyVirtualBallPlayer1Activity class. How does Unity fit into this?

I wouldn't try using the native QCAR samples and the QCAR Unity extension in the same project.

Let us know exactly what you're trying to accomplish.

- Kim

Re: Building QCAR unity package within Eclipse

September 28, 2011 - 6:13pm #25

Hi Kim,

All i want is to make the sample virtualball project to run on my android.
And im keep getting the Application stopped unexpectedly on my android whenever run it.
My eclipse console throwing :
[2011-09-28 18:16:53 - MyVirtualBallPlayer1] Conversion to Dalvik format failed with error 1

Below is my Activity class:

package com.qualcomm.QCARUnityPlayer;

import android.app.Activity;
import android.os.Bundle;

public class MyVirtualBallPlayer1Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

Re: Building QCAR unity package within Eclipse

September 28, 2011 - 4:44pm #24

Our class structure has actually changed a bit, take a look at this thread:

http://ar.qualcomm.at/node/2000770

Do you want to extend (subclass) our activities to add your own functionality, or do you want to add your own Android activity? If you want to subclass ours use the info in that thread above, if you have your own activity you'll need to add it to the manifest file and switch activities like normal.

You may want to go through the Unity/Eclipse integration once without QCAR to work out the kinks. Here's another guide from the Unity folks: http://unity3d.com/support/documentation/Manual/Android-Integrating%20Unity%20With%20Eclipse.html

- Kim

Re: Building QCAR unity package within Eclipse

September 28, 2011 - 3:18am #23

Hi Kim,

Now im able to generate the Staging Area contents after build my example app in android (not the standalone build).
Im having a new problem. I've followed your steps on creating the application in eclipse from unity.

1 thing i didnt understand...

Your 5th step:
5) If you are extending the main Activity, be sure to extend com.qualcomm.QCARUnityPlayer.PlayerActivity.

What does this means? I've created the library project and execution project..I've followed all the steps except the 5th step.

When i run the application to my android, it throws unexpected error.

And im getting error:
Conversion to Dalvik format failed with error 1
attached the full log file below.

My Activity class looks like this:

package com.qualcomm.QCARUnityPlayer;

import android.app.Activity;
import android.os.Bundle;

public class MyVirtualBallPlayer1Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

Re: Building QCAR unity package within Eclipse

September 27, 2011 - 8:02pm #22
ksiva wrote:

The procedure for compiling a Unity project in Eclipse and extending the main Activity is rather complex, so let me summarize the steps here.

Start with these instructions:
http://forum.unity3d.com/threads/71607-Integrating-Unity-and-Eclipse

A few things:

1) Make sure you set up the StagingArea project as an Android library. Add your java code to a separate project that includes this library, as the guide suggests.
2) Add classes.jar, QCAR.jar, and QCARUnityPlayer.jar to your custom Android project.
3) Copy config.xml and qcar-resources.dat from the StagingArea/raw/QCAR folder to the new project's assets folder.
4) Copy the AndroidManifest.xml file from the StagingArea to your new project as well.
5) If you are extending the main Activity, be sure to extend com.qualcomm.QCARUnityPlayer.PlayerActivity, and update the AndroidManifest file to use your class as the new entry point.
6) Each time you rebuild your Unity project, you need to copy the contents of the StagingArea/assets folder to your custom Android project. Be sure to copy the config.xml and qcar-resources.dat files if they have changed as well.

Make sure you haven't missed any steps, and if it still isn't working please attach the full log.

- Kim

Hi Kim, Im having problem at the first place itself.

I have no idea why my StagingArea folder in my Unity project is always empty??? Any idea? I missed out something? When I build and run my project, nothing comes up on the player except black color screen.

Please help..:confused:

Re: Building QCAR unity package within Eclipse

August 3, 2011 - 2:31pm #21

The PlayerActivity is designed to be the main activity, you can start another activity from the PlayerActivity but we have not tested a scenario where the PlayerActivity is created and destroyed multiple times during app execution. Would it be possible to change you application execution order such that the PlayerActivity is only destroyed on exit?

- Kim

Re: Building QCAR unity package within Eclipse

August 2, 2011 - 11:38am #20

Could you please give some hints or instructions how to finish the PlayerActivity correctly?!
It's a source for errors and a bad user experience if the app closes or the whole app history is disturbed. Also the OnResume functionality is influenced and if you get a call or something else you have to start the app right from the beginning afterwards.

Thanks

Re: Building QCAR unity package within Eclipse

July 6, 2011 - 6:00am #19

Hi, I use an activity that extends the PlayerActivity and that one is used in an ActivityGroup as a kind of subactivity with the LocalActivityManager.
With the activity itself it works all well, but if I try to go to next Activity something weird happens.. It changes for some seconds to the right next activity but then it jumps back in the app somewhere else. As I tried to finish() the extended PlayerActivity the whole app closes instead the activity only.
Unfortunately I have no source code of the PlayerActivity and really don't know whats going wrong there?! Any suggestions?

Re: Building QCAR unity package within Eclipse

June 23, 2011 - 7:28pm #18

That's right, this isn't something we support. For one thing, each QCAR application can only have a single config.xml and qcar-resources.dat file.

- Kim

Re: Building QCAR unity package within Eclipse

June 23, 2011 - 6:13am #17

.. when I look at my eclipse project there will be also an issue if I use several libraries, because the assets that have to be pasted have also the same names and structures..

Re: Building QCAR unity package within Eclipse

June 23, 2011 - 1:17am #16

Hi,

I want to use several Unity-QCAR projects as several library projects in my main eclipse android project, but in every library there is the same package structure and class name "com.qualcomm.QCARUnityPlayer.PlayerActivity".
Is there a way to change this in unity?

Re: Building QCAR unity package within Eclipse

June 20, 2011 - 4:35am #15

It worked. Thank you very much Kim :)

Re: Building QCAR unity package within Eclipse

June 17, 2011 - 7:59am #14

I think you need to get the class, then the object, then call the method. Something like this:

var jc = new AndroidJavaClass("com.mycom.ar.mobile.MyPlayerActivity");
var jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
var selectedItem = jo.Call.<String>("getSelectedItem");

Where "currentActivity" is a global static variable in your java activity:

public static MyPlayerActivity currentActivity;

public void onCreate(Bundle savedInstanceState)
{
    ...
    currentActivity = this;
}

- Kim

Re: Building QCAR unity package within Eclipse

June 17, 2011 - 2:50am #13

Thanks Kim. I solved the problem according to your suggestion. :) Thanks a lot.

I just changed the package name in AndroidManifest.xml (in StagingArea project) file to some other package (other than com.qualcomm.QCARUnityPlayer). Then removed the 'gen' folder. So it created a new 'gen' folder according to new package.

Hope I have followed the correct steps. Please let me know if that is not correct.

Then I have another problem. I want to pass a value from Java side to Unity side.
That is, when user click on a button on Java side, I start the PlayerActivity (actually start my own activity which is an extension of com.qualcomm.QCARUnityPlayer.PlayerActivity), which start the unity scene.
Then depending on which button is clicked I need to change the scene in Unity project. So I want to pass a String which indicate the clicked button.

I tried to do this using AndroidJavaObject, but when I put the java method call inside a Javascript in Unity, the application returned to the previous java activity after the method call. That is when I click on the button the Unity application starts (displayed the Unity startup screen) and after the method call it returns back to the Java screen with the buttons.
Here's the javascript
function Start () {
var jo = new AndroidJavaObject("com.mycom.ar.mobile.MyPlayerActivity");
var selectedItem = jo.Call.("getSelectedItem");
}

I have following method in MyPlayerActivity class (which extends com.qualcomm.QCARUnityPlayer.PlayerActivity). The 'selectedItem' variable holds the value indicating which button is clicked.
public String getSelectedItem() {
return selectedItem;
}

Can you please help me on this as well.

Thanks.

Re: Building QCAR unity package within Eclipse

June 15, 2011 - 11:01am #12

Still couldn't solve the problem. :(

I didn't give any names when creating the StagingArea project in Eclipse. I just copied the files from StagingArea folder and gave a project name. All other names including the package name got automatically.

Have I done a wrong thing when creating the Unity project in Unity development environment? There I created a new project and imported assets from QCAR-ImageTargets-1.0.0.unitypackage (which installed with QCAR Unity extension). Imported assets include, Scripts, xml and dat file for targets.

Where do I have to change the names in order to get this work?
How can I change the bundle name?

Thanks for your help Kim. It is highly appreciated.

Re: Building QCAR unity package within Eclipse

June 15, 2011 - 6:55am #11

Sorry for the late reply, were you ever able to get this to work?

The only thought I have looking at these files is perhaps this is a naming issue. For your Unity project, did you use com.qualcomm.QCARUnityPlayer for the bundle identifier? If so, that could be causing a collision with the R files. Use any name but that for the bundle id.

- Kim

Re: Building QCAR unity package within Eclipse

June 11, 2011 - 10:39am #10

Thanks Kim.

I did setup the project as per the given steps. Is there any place where I can go wrong?
The file structure of my StagingArea project is in fileStructure.txt.

In my custom android project, there are two packages inside 'gen'; my custom package and com.qualcomm.QCARUnityPlayer. There are two R.java file inside the two packages.

I have attached the two AndroidManifest.xml files; for StagingArea project and custom android project.

See whether you can give any thought.
Thanks for your help.

Re: Building QCAR unity package within Eclipse

June 10, 2011 - 1:36pm #9

For your first problem, did you set up the StagingArea project as an Android library? There shouldn't be any collisions of the R files if you set that up correctly.

For your runtime exceptions, please look at the Android log file for any errors. You can see the log with the DDMS tool that comes with Android, or the DDMS perspective in Eclipse.

- Kim

Re: Building QCAR unity package within Eclipse

June 9, 2011 - 10:38pm #8

Hi,

I followed the steps given by Kim in post #2 (and the URL mentioned in the post).
There are several problems.

1. When I linked the library project to custom Android project and then tried to add the QCARUnityPlayer.jar to the custom Android project, it gives compile errors. I have attached 'compileError.txt'.

2. Then I compiled without adding QCARUnityPlayer.jar. It got compiled. When I run it on Android phone it gives exception saying Application stopped unexpectedly.

In my application I want user to do something and then when user click on a button I want to load the project from Unity (i.e the ImageTargets sample for Unity). So, on the button click I do as follows.
Intent i= new Intent();
i.setComponent(new ComponentName("com.qualcomm.QCARUnityPlayer.PlayerActivity","com.qualcomm.QCARUnityPlayer.PlayerActivity"));
startActivity(i);

I get the exception at this point (when user clicks button)

3. I feels whether this is problem related to libmono.so, libunity.so (which are in assets/libs/armeabi-v7a of the Unity project). I did copy libs folder to assets folder in custom Android project. However, it seems these two files are not getting build because they have modified date some time back. Even though I build the project in Unity Editor those files don't get changed (same modified date)

Please help me.
Thanks.

Re: Building QCAR unity package within Eclipse

May 26, 2011 - 7:08am #7

I think you have to create the currentActivity static variable in Java yourself, and set it to your Activity object in onCreate(). See my sample code in this thread: http://ar.qualcomm.at/node/2000434

- Kim

Re: Building QCAR unity package within Eclipse

May 25, 2011 - 7:55am #6

Hi,

I followed your instructions too and ended up with own working android project in eclipse with my own qualcomm-unity-activity. There I created own activities and extended the special quar-activity [B" />PlayerActivity[/B" />. I can start it from other activities and all works like a charm. Thanks so far! :)

Now I want to call a function inside this extended activity from within unity.
Therefor I found the example: (http://unity3d.com/support/documentation/Manual/Android-Launch%20an%20Android%20Application%20from%20a%20Unity%20Application.html)

[CODE" />
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic("currentActivity");
jo.Call("Launch");[/CODE" />

I adopted that to my special case:

[CODE" />AndroidJavaClass jc = new AndroidJavaClass("[B" />de.my.app.ExtendedPlayerActivity[/B" />");
AndroidJavaObject jo = jc.GetStatic("currentActivity");
jo.Call("[B" />DoMyStuff[/B" />");[/CODE" />

Unfortunatly the function "DoMyStuff" on the Java side is never called. Did i miss something?

Re: Building QCAR unity package within Eclipse

May 18, 2011 - 6:10am #5

Thanks Kim,
It worked successfully after I copied the libs folder from library project into assets folder of my project & copying it again to the root project folder.
It is not QCAR problem.

Thanks again.

Re: Building QCAR unity package within Eclipse

May 18, 2011 - 5:07am #4

When I went through these steps I ended up with libmono.so and libunity.so in the assets/libs/armeabi-v7a folder of my custom project. Are you getting that as well? Also, what version of Unity are you using?

Just to double check, can you run the QCAR sample inside Unity successfully?

- Kim

Re: Building QCAR unity package within Eclipse

May 18, 2011 - 1:37am #3

Thanks Kim for your fast reply.
I made the steps as you mentioned and as written on Unity site:

http://unity3d.com/support/documentation/Manual/Android-Integrating Unity with Eclipse.html
But, the exception still appears. I will attach the log file.

Note:
I have implemented new pure unity project and followed the steps mentioned in the above link and I successfully ran the unity project as library with android project. This problem appears when I try to build QCAR unity project within Eclipse.

Re: Building QCAR unity package within Eclipse

May 17, 2011 - 12:07pm #2

The procedure for compiling a Unity project in Eclipse and extending the main Activity is rather complex, so let me summarize the steps here.

Start with these instructions:
http://forum.unity3d.com/threads/71607-Integrating-Unity-and-Eclipse

A few things:

1) Make sure you set up the StagingArea project as an Android library. Add your java code to a separate project that includes this library, as the guide suggests.
2) Add classes.jar, QCAR.jar, and QCARUnityPlayer.jar to your custom Android project.
3) Copy config.xml and qcar-resources.dat from the StagingArea/raw/QCAR folder to the new project's assets folder.
4) Copy the AndroidManifest.xml file from the StagingArea to your new project as well.
5) If you are extending the main Activity, be sure to extend com.qualcomm.QCARUnityPlayer.PlayerActivity, and update the AndroidManifest file to use your class as the new entry point.
6) Each time you rebuild your Unity project, you need to copy the contents of the StagingArea/assets folder to your custom Android project. Be sure to copy the config.xml and qcar-resources.dat files if they have changed as well.

Make sure you haven't missed any steps, and if it still isn't working please attach the full log.

- Kim

Log in or register to post comments