Log in or register to post comments

Unity-Android: Starting with Blue Screen

September 12, 2011 - 3:12am #1

I have created a project for Android and started out using QCAR without Unity but decided in a later stage of the project to start using Unity. So what I did was to follow the instructions for creating a QCAR Unity project and also followed the instructions on the Unity homepage for integrating Unity to Eclipse.

I seem to have problems loading the created scenes into the application that I have created. What I have understood is that the Unity "blank view" is a blue screen (not a error page) that has nothing on it, which I get when starting the application. I used the following code to start the Unity Player. The code is located in myproject\src and the scenes are located in myproject\assets\Scens (have also tried without the Scens folder).

import android.os.Bundle;
import com.unity3d.player.UnityPlayerActivity;

public class UnityPlay extends UnityPlayerActivity{
    /** Called when the activity is first created. */
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
}

The Unity project can be built to the phone and run from there and the scene works with no problem. So the problem seems to be loading the levels, so how do I decide what level to load when starting Unity from my Android application and how do I get it to start?

A question about the archtecture of the QCAR library:
When loading the QCAR library, a myproject/assets/Plugin/Android folder is created. In that folder a AndroidManifest is located with all libraries for QCAR. I do still have a AndroidManifest in my myproject folder and what is the purpose of the AndroidManifest in the plugin folder? Do I really need two AndroidManifest and could the problem be related to this?

The entire QCAR library is imported into the assets folder, is this correct location for it to be located?

EDIT: Where should my java code (android application code) be located for Unity projects?

Re: Unity-Android: Starting with Blue Screen

September 20, 2011 - 1:14am #8
ksiva wrote:

Every time you change the Unity project you'll have to copy the contents of the StagingArea/assets folder to the library project you created.

This was what I had missed, I thought that all I needed was to copy the asset folder from the library and not from the unity project StaginArea/assets to the library! Thanks för the help!

Re: Unity-Android: Starting with Blue Screen

September 16, 2011 - 1:34pm #7

If you want to bring Android code into a Unity project while you continue to build and run from Unity you'll need to create a JAR file with your Android code. Completely disregard that other guide, you no longer need to mess with the StagingArea. Instead, create an Eclipse project with the classes (and optionally activities) that you want to bring into Unity. Export it as a JAR file using Export > Java > Jar file. You may only want to export your classes, and not the resource files, manifest, etc. (play around with this step if you get runtime errors later).

Place this JAR file in the Plugins/Android folder. Now you can modify the AndroidManifest file in that folder to make use of any Activities you added.

Again, this might require some trial and error. Watch for any runtime errors in the logcat.

- Kim

Re: Unity-Android: Starting with Blue Screen

September 16, 2011 - 1:23pm #6

I think you're confused on how Unity fits into this build setup. Once you've followed that integration guide you end up with an Eclipse project that you build and run using Eclipse, not Unity.

There are actually two Eclipse projects, one built from the StagingArea as a library and your custom project (which is the one you build and run). Only the AndroidManifest in your custom project is used, but you should create it using the one in the StagingArea as a starting point.

Your Java classes live in your Eclipse project, and don't ever have to be copied to Unity.

Every time you change the Unity project you'll have to copy the contents of the StagingArea/assets folder to the library project you created. From that guide:

Quote:

Note that you will lose the one-step build process once you begin integrating the two projects in Eclipse, as the project has to be built in Unity, the asset folder copied to Eclipse and the whole project built again.

Note that this isn't the only possible workflow, this is useful if you're modifying your Android code more than your Unity scene, and when you want to build and run from Eclipse. My next post will describe a different approach.

Re: Unity-Android: Starting with Blue Screen

September 16, 2011 - 8:28am #5

I am still having problems, I know its not a QCAR problem (since I am having problems with out QCAR). I would not ask again if I would not be getting crazy on this (been trying to fix this for almost the entire week).

After reading through and following all instructions thorougly i still have a few questions. Hopefully these questions might make it clearer for me what I'm missing out... My main focus right now is just to get a scene to load.

* Should there be two Manifest files in the project? If so, should they be different?
* When I have created my new (Eclipse) project and linked the library, where do I create/work with the Unity project? Where should my Unity project be located?
* Where should my Java classes be located (in the src folder or assets/Plugins/Android)?
* Eclipse automatically renames the Asset folder to asset, is the search path case-sensitive? Is the path to the project sensitive if I have spaces in the path name?

Re: Unity-Android: Starting with Blue Screen

September 14, 2011 - 10:04pm #4

If all you want to do is start with your own Activity before the Unity Activity you probably don't need to create a custom ProxyActivity or extend any of our classes. In that case, make your IntroductionActivity the main activity in the manifest and launch the QCARPlayerProxyActivity when you're ready for it.

If you're still having trouble, I suggest running through the process without QCAR once first. Follow the instructions here carefully: http://forum.unity3d.com/threads/71607-Integrating-Unity-and-Eclipse

- Kim

Re: Unity-Android: Starting with Blue Screen

September 14, 2011 - 4:32am #3

I've followed all the mentioned threads as far as possible, but I am still experiencing the same problem. The application seems to be using the manifest in \myproject and not in \myproject\assets\Plugins\Android\ (which I have understood is the one that should be used).

I started out with using the Manifest from the created "library" and added all applications and permissions that were missing. In the second thread it said that the classes in the manifest should be youre own project and not qualcomm or unity. Do I need to create files for these then? I have created a ProxyActivity from the mentioned reference but do not know what to do with it...

When i use the same manifest in \myproject\assets\Plugins\Android and run and build the Unity project the following error comes: Resource re-package Failed! This appears when something is wrong in the manifest as far as I can see.

My Manifest file (with the important parts). The main thing is that I want the application to start a normal Android Java Application and not Unity.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
  android:versionName="1.0" android:versionCode="1" 
  package="com.company.project">
  
  <uses-sdk android:minSdkVersion="7" 
  android:targetSdkVersion="13" />
    
  <uses-feature android:name="android.hardware.camera" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.VIBRATE"/>
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  
  <application 
    android:name="com.company.project.Application"
  	android:icon="@drawable/app_icon" 
	android:label="@string/app_name" 
	android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
    android:description="@string/app_description"
    android:launchMode="singleTask"
	android:debuggable="false">
	
        <activity android:name="com.company.project.IntroductionActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        
	
	    <activity 
		    android:name="com.company.project.ProxyActivity" 
		    android:label="@string/app_name" 
		    android:configChanges="keyboard|keyboardHidden|orientation" 
		    android:screenOrientation="portrait">
	    </activity>
	    
	    <activity 
		    android:name="com.company.project.QCARPlayerActivity" 
		    android:label="@string/app_name" 
		    android:configChanges="keyboard|keyboardHidden|orientation" 
		    android:screenOrientation="portrait">
	    </activity>
	    
	    <activity 
	    android:name="com.company.project.QCARPlayerNativeActivity" 
		    android:label="@string/app_name" 
	    android:configChanges="keyboard|keyboardHidden|orientation" 
		    android:screenOrientation="portrait">
	      	<meta-data
				android:name="android.app.lib_name" 
				android:value="unity" />
	    </activity>
	    
	    <activity 
		    android:name="com.company.project.VideoPlayer" 
		    android:label="@string/app_name" 
	    android:configChanges="keyboard|keyboardHidden|orientation" 
		    android:screenOrientation="portrait">
	    </activity>
       
        <activity android:name="com.company.project.UnityPlay"
                  android:label="@string/label_unity_activity"
                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
        </activity>
  </application>
  
  <uses-library android:name="com.google.android.maps" />  
  
  <uses-feature android:glEsVersion="0x00010001" />
</manifest>

A few changes was made to the Java code to use the structure of 1.06. Do I need ProxyApplication to run the application?

In a thread I read that I need Unity Android Pro to do these steps, is this true? At the moment Im using a Unity Trial with Pro so that is no problem, but for future references.

import android.os.Bundle;

import com.qualcomm.QCARUnityPlayer.QCARPlayerActivity;

public class UnityPlay extends QCARPlayerActivity{
    /** Called when the activity is first created. */
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
}

I saw in the first thread how to choose level.

Thanks for the help!

Re: Unity-Android: Starting with Blue Screen

September 12, 2011 - 3:27pm #2

Be sure to use the class structure outlined in that second thread for QCAR 1.0.6.

One important thing to understand is that Unity uses a single Android Activity, even for multiple scenes. You can set the scene order using the Build Settings menu in Unity.

You'll want to use the AndroidManifest file from the StagingArea as your starting point. See the instructions in this post: http://ar.qualcomm.at/node/2000478

- Kim

Log in or register to post comments