Log in or register to post comments

Unable to find QCARWrapper

March 25, 2014 - 8:11am #1

Hi,

I use Vuforia Unity in my Android Project. In Vuforia Unity project I use ARCamera.

Now, when my app is starting, Unity is run. I don't want that, so I decided to add to the AndroidManifest.xml another entry

<activity android:name="***.UnityPlayerNativeActivity" android:label="@string/app_name" android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
</activity>

Activity's code:

public class UnityPlayerNativeActivity extends NativeActivity
{
    protected UnityPlayer mUnityPlayer;

    protected void onCreate (Bundle savedInstanceState)
    {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        
        getWindow().takeSurface(null);
        setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
        getWindow().setFormat(PixelFormat.RGB_565);

        mUnityPlayer = new UnityPlayer(this);
        if (mUnityPlayer.getSettings ().getBoolean ("hide_status_bar", true))
            getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                   WindowManager.LayoutParams.FLAG_FULLSCREEN);

        int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
        boolean trueColor8888 = false;
        mUnityPlayer.init(glesMode, trueColor8888);

        View playerView = mUnityPlayer.getView();
        setContentView(playerView);
        playerView.requestFocus();
    }

}

When I add that changes and I run my app camera doesn't show anything and screen is black.

Furthermore, in LogCat appears message

"Unable to find QCARWrapper"

Could someone help me?

Unable to find QCARWrapper

March 27, 2014 - 6:56am #11

Unfortunately, it does not work.

I added all activites to AndroidManifest in Unity project. Now when I run Android Project and press the button I get errors in LogCat:

Could not find class 'com.unity3d.player.UnityPlayer', referenced from method com.qualcomm.QCARUnityPlayer.QCARPlayerNativeActivity.onCreate

Unable to find QCARWrapper

March 26, 2014 - 1:11pm #10

Yes, all your Activities mus be declared in the same AndroidManifest.xml.

The AndroidManifest.xml that is located inside the Assetd/Plugins/Android folder of your Unity project, basically represents the AndroidManifest used by Unity to build your App when you deploy for the Android target. You can think of it as the AndroidManifest that you would have in a regular Android project developed wih Eclipse or other IDE.

 

 

Unable to find QCARWrapper

March 26, 2014 - 10:36am #9

If I undesrand you well, now, I should add to the AndroidManifest file in the “Assets/Plugins/Android/” directory of Unity project declaration of MainActivity. Am I right?

I do not know why it is needed. I do not know whta is the meaning AndroidManifest file in subdirectory of Unity project. Could you tell me?

Unable to find QCARWrapper

March 26, 2014 - 10:24am #8

Yes, but in the end, when you adjust the AndroidManifest in the plugins directory of the Unity project, you need to make sure that both activities are declared in that AndroidManifest (i.e. in the same manifest), otherwise how the app would know at runtime?

Unable to find QCARWrapper

March 26, 2014 - 9:04am #7

Both activites are declared in appropriate projects.

In the AndroidManifest of project checked as library is only MyPluginActivity.

In the AndroidManifest of project created as second  is only MainActivity.

I did step 10 of article and I did changes in AndroidManifest file in “Assets/Plugins/Android/” directory of Unity project. I changed the name of main activity with package_name.MyPluginActivity

Unable to find QCARWrapper

March 26, 2014 - 8:53am #6

Have you declared both Activities (MainActivity and MyPluginActivity) in the AndroidManifest ?

Unable to find QCARWrapper

March 26, 2014 - 8:49am #5

I suppose I did something wrong. Could you point at my mistake?

I decided to go through article https://developer.vuforia.com/resources/dev-guide/unity-android-plugins

I created Android Project named MyPlugin. The main activity is named MyPluginActivity. I added two libraries into that project as written is step 5 of tutorial. Next, I made the code changes as mentioned in step 6. Eclispe does not show any mistakes, so I suppose it's ok.

Then I marked my Android Project as libray - step 7. In /bin subdirectory I could notice JAR and I did step 8 and then step 9 and 10.

I ignored further steps. My Vuforia Unity project has ARCamera with button at the top. When the button is pressed, I change the scene, so Vuforia Project includes two scenes.

Now, I created another Android project and in Properties -> Android I added the library MyPlugin. The main activity of that project is MainActivity. I created my own layout for the main activity of that project. That layout contains button. I added onClick method to that button.

public void onClick(View v) {
                Intent i = new Intent(MainActivity.this, MyPluginActivity.class);
                startActivity(i);

}

I did needed imports. When I run my Android project the layout with button appears. It's expected. But, when I press the button, app crashes.

I suppose, I did an easy mistake. If not, please, let me know, I try to paste LogCat messages.

Unable to find QCARWrapper

March 26, 2014 - 4:19am #4

I'd like to create custom activity with own layout containing button. Now, when the button will be pressed, I'd like to start Vuforia Unity project, e.g. by starting new activity.

Yes, and you can achieve this by following the tutorial indicated below (https://developer.vuforia.com/resources/dev-guide/unity-android-plugins) + some additional steps, which consist of:

- creating your own activity in Eclipse, as part of the Eclipse Java project that you would create anyway in order to implement the Android plugin

- starting the Unity activity from your own activity when pressing a button (via an Intent), as you say

- adding your own Activity to the AndroidManifest.xml

 

However, if you don't like following the Android plugin approach, you can also follow the approach explained here:

https://developer.vuforia.com/resources/dev-guide/extending-unity-android-activity-and-adding-custom-views-eclipse

By following this tutorial, you can export your Unity project to Eclipse and then customize the project directly within Eclipse, e.g. adding your activity, adjusting your manifest, etc....

 

Unable to find QCARWrapper

March 26, 2014 - 4:03am #3

Thanks for your reply. However, I think I have another problem. I do not want change aything in Vuforia Unity project.

Assume, I get the Vuforia Unity project exported from Unity as Android project. Now, when I take that Android project and when I import and run it in Eclipse it works. Firstly, Unity logo appears and later I can notice camera. It's ok.

But I do not want it. I'd like to create custom activity with own layout containing button. Now, when the button will be pressed, I'd like to start Vuforia Unity project, e.g. by starting new activity.

Everything I am describing is a simplification, yet I hope that is understandable for you.

I'll be very grateful for reply.

Unable to find QCARWrapper

March 25, 2014 - 9:07am #2

Hi,

check this article which explains how to customize Vuforia Unity for Android:

https://developer.vuforia.com/resources/dev-guide/unity-android-plugins

By following that, you should be able to:

- build a custom Android plugin for a Vuforia - Unity project

- customize the AndroidManifest.xml

- defining a new custom Android Activity (in addition to the Unity one), from which you can start the Unity one

I hope this helps.

Log in or register to post comments