Git Product home page Git Product logo

unityionicintegration's Introduction

Unity Ionic Integration (with Vuforia support)

This plugin is NO LONGER MAINTAINED by the author. It has been ~3 years since I've last used Ionic or tested this integration. The repository isn't archived for the sole purpose of keeping the Issues active (it is a community effort, I don't necessarily provide support myself). Please note that Unity's official Unity as a Library method might be more stable than this integration, though I haven't tested it myself.

This tutorial will show you how to integrate your Unity app into an Ionic app and send messages between them (optional). It is tested on a medium-scale commercial Unity project with Vuforia plugin (optional).

Before we start, I'd like to give credits to these other guides that helped me overcome some challenges I've faced along the way:

Also, a special thanks to all who contributed to the development of this plugin :)

Discord: https://discord.gg/UJJt549AaV

GitHub Sponsors ☕

System Requirements

  • Android: Android Studio
  • iOS: Xcode
  • Ionic: tested on ionic info:
Cordova CLI: 6.5.0 
Ionic Framework Version: 3.3.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.3.7
ios-deploy version: 1.9.1 
ios-sim version: 5.0.13 
OS: macOS Sierra
Node Version: v6.9.5
Xcode version: Xcode 8.3.3 Build version 8E3004b

For future versions of Ionic, you may have to use ionic cordova platform add instead of ionic platform add, ionic cordova plugin add instead of ionic plugin add and so on.

If you are using Unity 2017.3.0+ and Vuforia, check out this topic for possible issues that you may encounter during the integration process: #16

If you are using VideoPlayer component and it stops working after integration, check out this topic: #18

Ionic-side Setup

  • First things first, you should import the plugin into your Ionic app using the following command: ionic plugin add https://github.com/yasirkula/UnityIonicIntegration.git
  • Now, you can launch Unity from your Ionic app using the following code snippet (TypeScript):
import ...

// Should put declare before any @Component's
declare let unityARCaller: any;

@Component({
  ...
})

export class ...
{
	constructor() {
		...
	}
	
	openUnity() {
		// It is possible to send a string message to Unity-side (optional)
		unityARCaller.launchAR( "my message for Unity-side", this.uReturnedFromUnity, this.uMessageReceivedFromUnity );
	}
	
	sendMessageToUnity() {
		// Send a message to Unity while Unity is still running
		unityARCaller.sendMessage( "Function name", "Optional parameter" );
	}
	
	uReturnedFromUnity = (param) => {
		// param:String is the (optional) message returned from Unity-side
		alert( param );
	};
	
	uMessageReceivedFromUnity = (message) => {
		// message:String is the message received from Unity-side
		// If you call a UI-blocking function here like 'alert', subsequent messages from Unity
		// will be queued by the OS and will only be received after returning to Ionic and
		// unblocking the UI
		console.log( "=========" + message + "=========" );
	};
}

NOTE: to access the plugin from Javascript, use window.unityARCaller.

  • All you have to do is call launchAR( parameter, onReturnedToIonicCallback, onMessageReceivedCallback ) function whenever you want to show Unity content. Here, parameter is the optional String parameter that is passed to Unity right after it is launched (see Unity-side Setup). Upon returning to Ionic from Unity, onReturnedToIonicCallback is triggered with an (optional) String parameter param that is returned from the Unity-side

  • Unity and Ionic can keep communicating even while Unity view/activity is active. You can call a function on Unity-side from Ionic using the unityARCaller.sendMessage( "Function name", "Optional parameter" ); function and, if you want, send a message back to Ionic (see Unity-side Setup) that triggers onMessageReceivedCallback

NOTE: on Android platform, if device runs out of memory while running the Unity activity, the Ionic activity is stopped and then automatically restarted by Android OS upon returning to Ionic from Unity. In that case, unfortunately, onReturnedToIonicCallback can not be called.

Unity-side Setup

  • Import IonicComms.cs script (available in files directory of this git repo) into your project. You don't have to attach this script to any GameObject but feel free to do it if you want to assign some references to it through Inspector. Just be aware that there can only be a single living instance of IonicComms component at a time and if you want to attach it manually to a GameObject, you must do it in the first scene of your project
  • If you had passed a String message from Ionic to Unity in launchAR function, it will be available in the OnMessageReceivedFromIonic function in IonicComms.cs
  • You can call functions that you define inside IonicComms.cs from Ionic with unityARCaller.sendMessage function. Although the parameter passed to sendMessage is optional, your C# function must have the following signature: public void FunctionName( string message );
  • You can send messages from Unity to Ionic runtime using IonicComms.SendMessageToIonic( "my message" )
  • When you want to return to Ionic from Unity-side, just call IonicComms.FinishActivity() function (or, optionally, IonicComms.FinishActivity( "return value" ) to send back a return value)
  • SO, DO NOT USE Application.Quit() ANYMORE!
  • for Vuforia users: disable Auto Graphics API in Player Settings and remove everything but OpenGLES2
  • for Android: open Build Settings and set Build System to Gradle (New). Then, select the Export Project option and click Export button to export your Unity project as a Gradle project to an empty folder
  • for iOS: put uIonicComms.mm file found in files directory of this repo into Assets/Plugins/iOS folder of your Unity project (create the Plugins and iOS folders, if they do not exist)
  • for iOS: in Player Settings, set Scripting Backend to IL2CPP and then simply build your project to an empty folder

Android Steps

NOTE: see the following topic if your Unity Android project has any gradle dependencies and the Android Studio steps below yield a Failed to resolve: error: #21

  • Build your Ionic project using ionic build android (use ionic platform add android, if Android platform is not added yet)
  • Open platforms/android folder inside your Ionic project's path with Android Studio
  • Open settings.gradle and insert the following lines (don't forget to change the path in the second line!):
include ':UnityProject'
project(':UnityProject').projectDir = new File('C:\\absolute path\\to your\\unity export folder')
  • Open build.gradle of android module and insert the following line into dependencies, where all the other compile command(s) are located at:
compile project(':UnityProject')

  • Click Sync now (top-right) and wait until Android Studio yields an error
  • In build.gradle of UnityProject module, change apply plugin: 'com.android.application' to apply plugin: 'com.android.library'
  • Inside jniLibs folder of android module, delete unity-classes.jar, if exists
  • Click Sync now again and wait for another error
  • If you receive the message "Error: Library projects cannot set applicationId..." inside build.gradle of UnityProject module, delete the line applicationId 'com.your_unity_bundle_identifier' and click Sync now again
  • Inside manifests folder of android module, open AndroidManifest.xml and switch to Merged Manifest tab
  • Click on the "Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml to override" text
  • Open AndroidManifest.xml of UnityProject module and switch to Text tab
  • Remove the <activity>...</activity> with the following intent:
<intent-filter>
	<action android:name="android.intent.action.MAIN" />
	<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
  • Now you can Run the android module

  • If you receive a "Could not find method compile()" error, see: #52

NOTE: if you are able to build your Ionic project successfully the first time but not the second time, remove the Android platform using ionic platform remove android and add it again using ionic platform add android.

About 64-bit ARM, x86 and x64 Android Devices

As of now, Unity has a native library for 32-bit ARM and x86 architectures only. However, Unity applications do run on 64-bit ARM and x64 architectures as 64-bit ARM architecture natively supports 32-bit ARM applications and x64 architecture natively support x86 applications. This is valid as long as there are no 64-bit ARM or x64 plugins in your project and all your plugins have both 32-bit ARM and x86 libraries. Otherwise, you will receive a "Failure to initialize! Your hardware does not support this application, sorry!" error while launching Unity content. To avoid this issue, you must ensure the following criteria:

  • If there are any arm64-v8a, armeabi or x86_64 folders in the jniLibs directory of your Android Studio project, simply delete these folders. Your application will not be affected by this change as long as plugins in these folders have libraries in armeabi-v7a and x86 folders, as well
  • If there is any plugin in your project that has a library in armeabi-v7a folder but not in x86 folder (like Vuforia, unfortunately), you have to make the following decision:
    • either don't touch anything and your Ionic application will run on all architectures but the Unity content will not launch on Intel architecture devices (x86 and x64)
    • or delete the x86 folder and both your Ionic application and the Unity content will run on all ARM architectures as well as on Intel architectures that support emulating ARM applications (also note that Unity 2019.3+ no longer supports x86)

If you want consistency for your app, go with the second option.

Troubleshooting

  • Activity has leaked IntentReceiver org.apache.cordova.plugin.CordovaUnityLauncher$UnityToIonicBroadcastReceiver that was originally registered here. Are you missing a call to unregisterReceiver()?

See: #61

  • Unity : Failed to load 'libmain.so', the application will terminate.

Disable Strip Engine Code in Player Settings (source).

iOS Steps

IMPORTANT NOTICE: make sure that the paths to your Ionic project and Unity build directory do not contain any space characters.

  • Build your Ionic project using sudo ionic build ios (use sudo ionic platform add ios, if iOS platform is not added yet). If you receive the following error at the end, it means the build was successful, no worries: Signing for "MyIonicProject" requires a development team. Select a development team in the project editor.
  • (optional) use command sudo chmod -R 777 . to give full read/write access to the project folder in order to avoid any permission issues in Xcode
  • Open platforms/ios folder inside your Ionic project's path with Xcode (open wcworkspace, not xcodeproj)
  • In Plugins/unityARCaller.m, uncomment the (void)launchAR and (void)sendMessage functions
  • Rename Classes/AppDelegate.m to Classes/AppDelegate.mm (changed .m to .mm) and Other Sources/main.m to Other Sources/main.mm
  • Change the contents of Classes/AppDelegate.h with the AppDelegate.h found in files directory of this repo
  • Change the contents of Classes/AppDelegate.mm with the AppDelegate.mm found in files directory of this repo
  • for Vuforia users: in AppDelegate.mm, uncomment the lines marked with //for vuforia:
  • Create a group called Unity in your project

  • Drag&drop the Classes and Libraries folders from the Unity build directory to the Unity group in Xcode; select Create groups and deselect Copy items if needed (importing Classes might take quite some time)
  • Drag&drop the unityconfig.xcconfig config file found in files directory of this repo to the Unity group in Xcode; select Create groups and deselect Copy items if needed
  • Drag&drop the Data folder from the Unity build directory to the Unity group in Xcode; select Create folder references and deselect Copy items if needed
  • for Vuforia users: drag&drop the Data/Raw/QCAR folder from the Unity build directory to the Unity group in Xcode; select Create folder references and deselect Copy items if needed

  • Remove the Libraries/libil2cpp folder in Unity group from your Xcode project using Remove References
  • Remove the Libraries/Plugins/Android folder (if exists) in Unity group from your Xcode project using Remove References
  • In Configurations of your project, set all the configurations as unityconfig

  • In Build Settings, set the value of UNITY_IOS_EXPORTED_PATH to the path of your Unity iOS build directory (do this for PROJECT and the TARGETS)

  • In Build Settings, select Prefix Header and press Delete to revert its value back to the default value (in case it is overridden)(do this for PROJECT and the TARGETS)(if Prefix Header becomes blank after this step, apply this fix: #12 (comment))
  • Open Classes/UnityAppController.h in Unity group and find the following function:
inline UnityAppController* GetAppController()
{
	return (UnityAppController*)[UIApplication sharedApplication].delegate;
}
  • Then, replace it with this one:
NS_INLINE UnityAppController* GetAppController()
{
	NSObject<UIApplicationDelegate>* delegate = [UIApplication sharedApplication].delegate;
	UnityAppController* currentUnityController = (UnityAppController *)[delegate valueForKey:@"unityController"];
	return currentUnityController;
}
  • Open Classes/UnityAppController.mm in Unity group, and replace - (void)shouldAttachRenderDelegate {} with the following function:
- (void)shouldAttachRenderDelegate {
    AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    [delegate shouldAttachRenderDelegate];
}
  • Add #import "AppDelegate.h" to the top of Classes/UnityAppController.mm
  • Change the contents of Other Sources/main.mm with Classes/main.mm (located in Unity group) and replace const char* AppControllerClassName = "UnityAppController"; with const char* AppControllerClassName = "AppDelegate"; (in Other Sources/main.mm)

  • Remove Classes/main.mm in Unity group from your Xcode project using Remove References
  • for Vuforia users: in Libraries/Plugins/iOS/VuforiaNativeRendererController.mm in Unity group, comment the line IMPL_APP_CONTROLLER_SUBCLASS(VuforiaNativeRendererController)
  • Sign and build your project (it is advised to build to an actual iOS device rather than to emulator to possibly avoid some errors during the build phase)

NOTE: if you encounter an error like "cordova/cdvviewcontroller.h' file not found" while building, try adding "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" to Header Search Paths in Build Settings (do this for PROJECT and the TARGETS)

unityionicintegration's People

Contributors

yasirkula avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unityionicintegration's Issues

Lessons learnt with Vuforia 7 and Unity 2017.3.0f3

Hi everyone,

I'm posting this here just to let other users know of some lessons learnt / changes we've experienced using Vuforia 7 and the new Unity.

Unity Side Setup

  • In Player settings->Other Settings: Camera Usage Description must be specified and Target minimum iOS version must be >= 9.0
  • In Player settings->XR Settings: Vuforia Augmented Reality must be enabled

iOS Side Setup

  • For Vuforia users: Drag & drop Data/Raw/Vuforia instead of Data/Raw/QCAR(which does not exist) from the Unity build directory to the Unity group in Xcode
  • For Vuforia users: Move VuforiaNativeRendererController.mm from Libraries(in Unity group in Xcode) to Libraries/Plugins/iOS(in Unity group in Xcode)
  • Have a look at #15
  • You might need to specify the Camera Usage Description in Xcode.

Android setup

  • Have a look at issue #14

Kind regards,

Ian

iOS - Thread 1: EXC_BAD_ACCESS (code=1, address=0x30)

After integration, when running on iOS, the app opens and the Ionic side is working. When I tap on the button that starts Unity (using the openUnity() method) I'm getting the following error:
Thread 1: EXC_BAD_ACCESS (code=1, address=0x30)

Here are screenshots of exactly what's happening:

https://pasteboard.co/H39PlhX.png
https://pasteboard.co/H39YwmR.png

Using Unity 2017.3.0f3, Ionic 3.19.0, Cordova 7.1.0. In the current scenario, the Unity project only contains a blank scene (with the integration scripts and files). We're also not using Vuforia for now. The Ionic project is a bare minimum too (only one button calling openUnity(), and the plugin).

We have tried building several times on different Macs and different devices. I'm pretty sure we're not missing any steps.

Any ideas?

Appreciate the help!

Ian

Ps. Just to be thorough, here is an ionic info dump:

cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.0
ionic (Ionic CLI) : 3.19.0

global packages:
cordova (Cordova CLI) : 7.1.0

local packages:
@ionic/app-scripts : 3.1.6
Cordova Platforms : ios 4.5.4
Ionic Framework : ionic-angular 3.9.2

System:
ios-deploy : 1.9.2
Node : v8.9.1
npm : 5.5.1
OS : macOS Sierra
Xcode : Xcode 9.2 Build version 9C40b

UnitySetGraphicsDevice and UnityRenderEvent cause link errors

Hi,

I'm trying to follow your tutorial to see how to link a Cordova project with Unity on iOS (without Vuforia for now) and I got linking errors that prevent me to compile:
Undefined symbols for architecture armv7:
"_UnitySetGraphicsDevice", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
"_UnityRenderEvent", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o

Do I need to add a framework ? Because I couldn't find their definition anywhere.

Mapbox

Hi guys,

I wonder if you guys have tried Mapbox in Unity with this plugin yet.
I encountered this error.

screen shot 2018-05-30 at 11 44 39 am

I found out I need to add this $(UNITY_IOS_EXPORTED_PATH)/Libraries/Mapbox/Core/Plugins/iOS/MapboxMobileEvents/include/
to Search Header Path and libz.tbz to Linked Framework and Libraries

and then I stuck with this error.
screen shot 2018-05-30 at 11 51 29 am

I appreciate if someone can help me on this.

ngFactory issue with Android project

Hello,
First of all, thanks for your ressources and your explanations. I followed it for an Android project, and everything related to Android part works well (I'm an Android native dev, it may helps... :) but I'm Ionic and Unity newbie).

My sample app is pretty simple : I put a button on the home page, and when I click on it, it calls openUnity().

But when I click the button, I see in the Android Logcat :

D/SystemWebChromeClient: ng:///AppModule/HomePage.ngfactory.js: Line 115 : ERROR
06-01 01:23:13.830 17298-17298/io.ionic.starter I/chromium: [INFO:CONSOLE(115)] "ERROR", source: ng:///AppModule/HomePage.ngfactory.js (115)
06-01 01:23:13.833 17298-17298/io.ionic.starter D/SystemWebChromeClient: ng:///AppModule/HomePage.ngfactory.js: Line 115 : ERROR CONTEXT
06-01 01:23:13.833 17298-17298/io.ionic.starter I/chromium: [INFO:CONSOLE(115)] "ERROR CONTEXT", source: ng:///AppModule/HomePage.ngfactory.js (115)
06-01 01:23:13.843 17298-17298/io.ionic.starter W/cr_Ime: updateState: type [0->0], flags [0], show [false],

...and nothing happens. The app doesn't crash, but nothing happens. However, the Unity project alone works well : I already built it and deployed as a standalone app, and it works fine.

As I'm a newbie in Ionic, I may be missing something, but I don't understand clearly what. Your sample code makes me think I wouldn't have to call the Unity activity with the Ionic NavController navCtrl.push() method like we should do in a normal "launch new Activity" context.

However, if a change my Ionic button behaviour, and make it call a dummy function (displaying a simple alert dialog with a dummy message), it works. (hopefully !! ^^ if not I'd better worry)

Could you please give more info/context/details about calling this.unityARCaller.launchAR(...) ?
Thanks.

Here is my very simple home.ts file :

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  unityARCaller: any;

  constructor(public navCtrl: NavController) {

  }

  openUnity() {
  	// it is possible to send a string message to Unity-side (optional)
  	this.unityARCaller.launchAR("my message for Unity-side", this.uSuccessCallback, this.uFailedCallback );
  }

  uSuccessCallback = (param) => {
	   // param:String is the (optional) message received from Unity-side
	//  alert( param );
  };

  uFailedCallback = (error) => {
  	// should ignore this callback
  };

  openAR(){
    // alert("Launch AR")
    this.openUnity();
  }
}

And my (as simple as previous one) home.html file :

<ion-header>
  <ion-navbar>
    <ion-title>
      Ionic Blank
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  <button ion-button (click)="openAR()">Start AR</button>
</ion-content>

I'm running Ionic 3.0.0, Cordova 7.0.1

iOS build failed Undefined symbols for architecture arm64

I try to follow instruction for iOS. After I build project I recieve this error.

Undefined symbols for architecture arm64:
"_UnitySetGraphicsDevice", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
"_UnityRenderEvent", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Do you have any suggestion?
screen shot 2560-06-14 at 4 15 19 pm

Launcher does not work with a project with Ionic Storage

Simple to reproduce. I created a blank project with a button to open my unity app (android). Worked no problems.
Then added ionic storage to my project https://ionicframework.com/docs/storage/ :
ionic cordova plugin add cordova-sqlite-storage
npm install --save @ionic/storage

Rebuilt my app... then when trying to open unity got an error message "Failure to initialize Your hardware does not support this application, sorry" (all on my physical device, s7 edge)

I think the root of the problem is that storage adds a bunch of folders under "android>jnilibs" folder
fff

no Bulk_UnityEngine.UI_2.cpp file with older unity version (2017.2.2)

What versions of Unity and Vuforia are supported? I'm asking because I tested this out initially with a Unity 2018.1.5 and Vuforia 7.1.35 and everything worked (I used xCode 8.3 to do most of the project configurations, and then opened the configured project in xCode 9.4 so that I could build for iOS 11.4, and everything worked beautifully).

However, I realized the Unity project I need to use in my app does not work on newer unity versions, so I rebuilt it using Unity 2017.2.2 and Vuforia 6.5.25. Now I'm running into the following error:

clang: error: no such file or directory $UNITY_BUILD_FOLDER/Classes/Native/Bulk_UnityEngine.UI_2.cpp

and I see that the file is not included in the build directory from older Unity version. I've been trying to see if I can use the libil2cpp folder from the 2018.1.5 version build (or at least to copy over some of the include files), but I'm sort of going in circles because then other files are missing or renamed.

I will continue trying to patch this together, and if no luck, I will attempt a fresh build from the very beginning.

In the meantime, would be helpful to know:

  • Are Unity 2017.2.2 builds are even supported?
    
  • If they are supported, what could trying to include the "Bulk_UnityEngine.UI_2.cpp" file?
    

BTW, this repo is AWESOME, and its obvious you put a lot of work into it and are very much on top of responding to issues. Thanks so much for that. It's really amazing of you.

Errors in main.mm file : Use of undeclared identifier

Hello,
thank you for this tutorial. Followed all the steps, but in the main.mm file i have the following
errors: (screen the image bellow)

  • use of undeclared identifier 'UnityParseCommandLine'
  • use of undeclared identifier 'nil'
  • use of undefined identifier 'NSLog'
    20171031_183039
    Sorry for the image quality

This is the file content:
`#include "RegisterMonoModules.h"
#include "RegisterFeatures.h"
#include

// Hack to work around iOS SDK 4.3 linker problem
// we need at least one __TEXT, __const section entry in main application .o files
// to get this section emitted at right time and so avoid LC_ENCRYPTION_INFO size miscalculation
static const int constsection = 0;

void UnityInitTrampoline();

// WARNING: this MUST be c decl (NSString ctor will be called after +load, so we cant really change its value)
const char* AppControllerClassName = "AppDelegate";

int main(int argc, char* argv[])
{
@autoreleasepool
{
UnityInitTrampoline();
UnityParseCommandLine(argc, argv);

    RegisterMonoModules();
    NSLog(@"-> registered mono modules %p\n", &constsection);
    RegisterFeatures();
    
    // iOS terminates open sockets when an application enters background mode.
    // The next write to any of such socket causes SIGPIPE signal being raised,
    // even if the request has been done from scripting side. This disables the
    // signal and allows Mono to throw a proper C# exception.
    std::signal(SIGPIPE, SIG_IGN);
    
    UIApplicationMain(argc, argv, nil, [NSString stringWithUTF8String:AppControllerClassName]);
}

return 0;

}

#if TARGET_IPHONE_SIMULATOR && TARGET_TVOS_SIMULATOR

#include <pthread.h>

extern "C" int pthread_cond_init$UNIX2003(pthread_cond_t *cond, const pthread_condattr_t *attr)
{ return pthread_cond_init(cond, attr); }
extern "C" int pthread_cond_destroy$UNIX2003(pthread_cond_t *cond)
{ return pthread_cond_destroy(cond); }
extern "C" int pthread_cond_wait$UNIX2003(pthread_cond_t *cond, pthread_mutex_t *mutex)
{ return pthread_cond_wait(cond, mutex); }
extern "C" int pthread_cond_timedwait$UNIX2003(pthread_cond_t *cond, pthread_mutex_t *mutex,
const struct timespec *abstime)
{ return pthread_cond_timedwait(cond, mutex, abstime); }

#endif // TARGET_IPHONE_SIMULATOR && TARGET_TVOS_SIMULATOR
`

error - ionic cordova plugin add

I use windows powershell and build android.But it is wrong. How do I do?

PS D:\Projects\MyApp> ionic cordova build android
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_coo6rr94g5y9x4vy26v2tw0nc.run(D:\Projects\MyApp\platforms\android\app\build.gradle:147)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

FAILURE: Build failed with an exception.

  • Where:
    Build file 'D:\Projects\MyApp\platforms\android\app\build.gradle' line: 268

  • What went wrong:
    A problem occurred evaluating project ':app'.

Project with path ':UnityProject' could not be found in project ':app'.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s
(node:1332) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:

BUILD FAILED in 1s
at ChildProcess.whenDone (D:\Projects\MyApp\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

This is my settings.gradle

include ":"
include ":CordovaLib"
include ":app"
include ':UnityProject'
project(':UnityProject').projectDir = new File('D:\Projects\MyApp\platforms\android\ARSystem')

'OneSignal/OneSignal.h' file not found after plugin integration

Hello, I have I Ionic project that works well, builds an run. The project uses one signal plugin for notifications.
After I have installer the unityIonicIntegration plugin it stops build and throws this error : 'OneSignal/OneSignal.h' file not found

No visible @interface for 'unityARCaller' declares the selector 'receivedMessageFromUnity:'

I have followed each and every steps of UnityIonicIntegration to complete integration of unity to ionic .

my code in .m file

- (void)sendMessageToIonic:(NSString*)message
{
//    [self setTitleOfButtonNamed:buttonOne withTitle:btnOneTitle];
     [self.ionicComms receivedMessageFromUnity:message];
}

I have also tried to put same parameter as a method declaration .h file

  • (void)sendMessageToIonic:(NSString*)message;

still i am getting above error. so, how could i solve this error?

ionic issue: Unable to find a matching configuration of project

Hello,

I am trying to achieve the integration of my ionic2 project with my unity project. I have a unity project which contains a 3d model. Inside my ionic application, I want to load that 3D model on click of a button.

First of all, I had a few basic questions:
1) Should I use my entire unity project for this or Should I use the exported WebGL of my project?

2) Should I keep that unity project inside my ionic application directory or should I keep both projects separate?

I tried both the options i.e using the entire project & using the WebGL

I followed all the steps given in the documentation (I am not using android studio for this integration)

  1. Installed the plugin & added the code in my typescript file

  2. I kept the IonicComms.cs file in the assets folder of my unity project

  3. I edited the GradleBuilder.js file to put the following content in my settings.gradle file
    include ":UnityProject"
    project(":UnityProject").projectDir = new File("complete path to my unity project")

  4. I edited build.gradle file where I tried both options:
    compile project(':UnityProject')
    or
    implementation(project(path: "UnityProject"))
    (because compile is deprecated)
    & used
    apply plugin: 'com.android.library'

  5. I deleted unity-classes.jar

  6. I deleted activity tag from android manifest file as well.

I am getting an error in the build process

Could not determine the dependencies of task ':compileDebugJavaWithJavac'.
Could not resolve all task dependencies for configuration ':debugCompileClasspath'
Could not resolve project :UnityProject.
Required by: project :
Unable to find a matching configuration of project :UnityProject: None of the consumable configurations have attributes.

I tried googling this error as well but it was of no help. Please help me with those 3 questions.

QCAR Folder

When we export our project for iOS there isn't a Data\Raw\QCAR folder. Instead there is a Data\Raw\Vuforia folder. Is there something that has to be done to get the QCAR folder?

Just tested with a new project. Working with Ionic 3.9.2 . Only a minor fix needed

Thank you for this project. Your are a life saver.
I followed the documentation for android and worked great on Ionic 3.9.2 (still need to test with IoS). The only thinkg missing is that the plugin won't add without a "package.json" in the plugin folder. I followed https://stackoverflow.com/a/44455103 to generate a simple package.json and it worked. Also there are some minor changes in the calls of ionic, instead of "ionic platform add" it is now "ionic cordova platform add".

Running in the background

Hi there,

First of all thanks to all who contributed to this, a really helpful plugin/ feature for a Cordova app.

My only question is, is there any way of stopping the Unity side from running in the background?

Application.Quit() is exiting the entire process ID of the app and I would just like to stop the Unity service from running in the background.

Thanks,

George

error: cannot find symbol class UnityPlayer

Hello, I encounter a compilation problem under android studio 3.1.2, when I delete the unity-classes.jar file in the libs folder of the android project, I have 7 compilation errors:

error: can not find UnityPlayer class symbol
error: can not find symbol class UnityPlayerActivity
error or method not applicable or a method from a supertype
error: registerReceiver (IonicToUnityBroadcastReceiver, IntentFilter)
error or method not applicable or a method from a supertype
error: can not find symbol variable super
error: can not find symbol method setResult (Int, Intent)

Various il2cpp and mscorlib errors

Hello,

I’m currently trying to build an empty unity project and a blank Ionic project on ios following your guide.
I have followed every step multiple times with different projects from scratch.
I am practically a beginner in all the ionic/web/html side for the record, so maybe i’m missing something obvious.
The ionic project works on its own when built and run from xcode or CLI.
The unity project works on its own as well.
After following the iOS steps, though, various errors start coming but seem all related to il2cpp and mscorlib.

Software used :
Unity 2017.4 and 2018.3
Ionic 4 and 3
Angular : Latest

extern "C" IL2CPP_METHOD_ATTR int32_t MonoCMethod_get_core_clr_security_level_m1431438660 (MonoCMethod_t3191134373 * __this, const RuntimeMethod* method)
{
	typedef int32_t (*MonoCMethod_get_core_clr_security_level_m1431438660_ftn) (MonoCMethod_t3191134373 *);
	using namespace il2cpp::icalls;
	return  ((MonoCMethod_get_core_clr_security_level_m1431438660_ftn)mscorlib::System::Reflection::MonoCMethod::get_core_clr_security_level) (__this);
}

mscorlib::System::Reflection::MonoCMethod::get_core_clr_security_level

No member named 'get_core_clr_security_level' in 'il2cpp::icalls::mscorlib::System::Reflection::MonoCMethod'

extern "C" IL2CPP_METHOD_ATTR void CustomAttributeData_ResolveArgumentsInternal_m4232068489 (RuntimeObject * __this /* static, unused */, ConstructorInfo_t5769829 * ___ctor0, Assembly_t * ___assembly1, intptr_t ___data2, uint32_t ___data_length3, ObjectU5BU5D_t2843939325** ___ctorArgs4, ObjectU5BU5D_t2843939325** ___namedArgs5, const RuntimeMethod* method)
{
	typedef void (*CustomAttributeData_ResolveArgumentsInternal_m4232068489_ftn) (ConstructorInfo_t5769829 *, Assembly_t *, intptr_t, uint32_t, ObjectU5BU5D_t2843939325**, ObjectU5BU5D_t2843939325**);
	using namespace il2cpp::icalls;
	 ((CustomAttributeData_ResolveArgumentsInternal_m4232068489_ftn)mscorlib::System::Reflection::CustomAttributeData::ResolveArgumentsInternal) (___ctor0, ___assembly1, ___data2, ___data_length3, ___ctorArgs4, ___namedArgs5);
}

mscorlib::System::Reflection::CustomAttributeData::ResolveArgumentsInternal

No member named 'CustomAttributeData' in namespace 'il2cpp::icalls::mscorlib::System::Reflection'; did you mean 'CustomAttributesCache'?
Replace 'mscorlib::System::Reflection::CustomAttributeData' with 'CustomAttributesCache'
No member named 'ResolveArgumentsInternal' in 'CustomAttributesCache'

and 6 other similar errors, not sure if it's useful to paste them.
screen shot 2019-03-01 at 13 54 37

If you have any question or suggestion I would be extremely thankful !

iOS Splash Screen

We have tried a variety of iOS splash screen settings, but it seems that regardless of what we do we get a stretched version of the normal app splash screen when we open the Unity portion of our app. Has anyone had any luck changing the Unity splash screen when using this plugin?

Error MainActivity

Hello I have an error while running the application under android when I call the function to launch unity, I have the following error:

06-29 16:04:47.106 18699-18699/fr.xx.xx E/ActivityThread: Activity fr.xx.xx.MainActivity has leaked IntentReceiver org.apache.cordova.plugin.CordovaUnityLauncher$UnityToIonicBroadcastReceiver@ec2200e that was originally registered here. Are you missing a call to unregisterReceiver()?

Compilation is not a problem.

Thank you for your help

undeclared identifiers

I'm getting the following errors after following all the instructions:

Classes/AppDelegate.mm:45:13: Use of undeclared identifier 'UnityRegisterRenderingPlugin'

Classes/AppDelegate.mm:50:12: Use of undeclared identifier 'UnityGetMainWindow'

Classes/AppDelegate.mm:109:9: Use of undeclared identifier 'UnitySendMessage'

Classes/AppDelegate.mm:123:9: Use of undeclared identifier 'UnitySendMessage'

I can see these methods are in the file UnityInterface.h so I added an import line to the file but then I get linking errors.

Undefined symbols for architecture arm64:
"_UnityGetMainWindow", referenced from:
-[AppDelegate unityWindow] in AppDelegate.o
"OBJC_CLASS$_VuforiaRenderDelegate", referenced from:
objc-class-ref in AppDelegate.o
"OBJC_CLASS$_UnityAppController", referenced from:
objc-class-ref in AppDelegate.o
"_UnitySendMessage", referenced from:
-[AppDelegate sendMessageToUnity:] in AppDelegate.o
-[AppDelegate sendMessageToUnity:parameter:] in AppDelegate.o
"_VuforiaRenderEvent", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
"_UnityRegisterRenderingPlugin", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any ideas? Any help is appreciated.

Make installable through git instead of local clone?

Could you restructure the repo so that you could add the plugin like this?

ionic cordova plugin add https://github.com/kevin-smets/UnityIonicIntegration.git#1.0.0

This is just a fork where I added a package.json and moved some resources around to make it installable remotely.

iOS build fails: linker issues

After following steps outlined in readme, I am having issues building to an iOS device. Xcode provides the following error:

Screen Shot 2019-03-29 at 1 31 03 PM

Any ideas?

Edit:
I see some references in the error log to "MetalRenderData"... I have double checked and my Unity project settings have auto graphics api unchecked and OpenGLES2 is the only enabled option

'il2cpp-config.h' file not found

Hi!

I am currently try to make unity vuforia and ionic work and I follow every single step, but I always get 'il2cpp-config.h' file not found error and I cant figure out the problem.

I go through the folders and this file is in the libil2cpp folder but I deleted this folder as the tutorial said.

Android: Trouble pulling in unity classes

I just couldn't seem to figure this out. Did everything on the list, but i'm getting this error in my build:
screen shot 2018-08-17 at 4 52 35 pm

After some searching around, I ended up adding the unity-classes.jar to the main android project as a library, but then I receive this error, which seems like its trying to add it in twice. I've tried different combinations of where to implement this, but I keep getting one error or the other:
screen shot 2018-08-17 at 4 52 15 pm

The Unity build works by itself without the plugin, so I'm not sure what is going wrong here.
Any help would be much appreciated!

EasyAR and VoidAR integration

Hi, this is not an issue, it's just to let you and the users know that this also works with EasyAR and VoidAR.
I already managed to make this work perfectly with those SDK's.
Here's how I did it:

For Android:
*All the unity steps are the same, then, after building the project for gradle, you just have to add the following line in the dependencies of the build.gradle file of the Ionic project (platforms/android/build.gradle):

For EasyAR:
compile fileTree(dir: '/<path to your Unity exported project>/libs', include: 'EasyAR.jar')

For VoidAR:
or compile fileTree(dir: '/<path to your Unity exported project>/libs', include: 'VoidAR.jar')
Remember to change the path for your relative or absolute path.

image

Because if you don't reference the .jar file there, the module will close because it can't find the .jar classes.

  • If you are using EasyAR, remember to match the BundleId or PackageName with the one that you used in the EasyAR platform, but when you are exporting from unity to gradle, you have to change these values for something else, and match the PackageName / BundleId on the EasyAR platform with the PackageName / BundleId of the Ionic / android project (present in AndroidManifest.xml and injected from config.xml) instead, because if you don't do this, you'll keep getting the "Invalid Key or Package Name" error.

For IOS:
The steps are literally the same, but when you open the AR view, you will probably get a black screen. If that's happening, do the following:

  1. On Classes/AppDelegate.mm add the following lines at the top under the imports:
extern "C" void ezarUnitySetGraphicsDevice(void* device, int deviceType, int eventType);
extern "C" void ezarUnityRenderEvent(int marker);

Then, in that same class, on the shouldAttachRenderDelegate() method, add the following inside the if:
UnityRegisterRenderingPlugin(&ezarUnitySetGraphicsDevice, &ezarUnityRenderEvent);

I hope it helps.

Error starting unity: GL_INVALID_ENUM : glTexImage2D: <- error from previous GL command

Hi, I followed the steps for a v1 ionic app, and every time I click the button to open the unity part, the screen became black for 1 second and then goes back to the ionic view.
After starting the app I get the following erros:

5.820 24867-24938/io.ionic.starter E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
10-02 07:48:45.920 24867-24938/io.ionic.starter E/chromium: [ERROR:gl_surface_egl.cc(335)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
10-02 07:48:46.390 24867-24938/io.ionic.starter E/chromium: [ERROR:gl_surface_egl.cc(335)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
10-02 07:48:47.690 24867-24937/io.ionic.starter E/chromium: [ERROR:budget_service.cc(145)] Unable to connect to the Mojo BudgetService.
10-02 07:48:47.930 24867-24938/io.ionic.starter E/chromium: [ERROR:texture_manager.cc(3410)] [.RenderWorker-0x5579f8bfc0]GL ERROR :GL_INVALID_ENUM : glTexImage2D: <- error from previous GL command

and when I click the button to launch unity, I get the following erros:

10-02 07:50:01.390 24867-24938/io.ionic.starter E/chromium: [ERROR:texture_manager.cc(3410)] [.RenderWorker-0x5579f8bfc0]GL ERROR :GL_INVALID_ENUM : glTexImage2D: <- error from previous GL command
10-02 07:50:01.450 24867-24938/io.ionic.starter E/chromium: [ERROR:gles2_cmd_decoder.cc(8216)] [.RenderWorker-0x5579f8bfc0.GpuRasterization]GL ERROR :GL_INVALID_ENUM : glFramebufferTexture2D: <- error from previous GL command

I thought it was due to my unity export opengl, but I tried everything (Opengl2, Opengl3, Autographics Enabled) and I still getting the same error and don't see the unity app.

Error:Failed to resolve: :VuforiaWrapper:

Hi there,

I am using Unity 2017.3.0f3 with Vuforia 7.0.36. I now get this error
Error:Failed to resolve: :VuforiaWrapper: when syncing.

I suspect it has to do with this in build.gradle for the UnityProject

dependencies {
	compile fileTree(dir: 'libs', include: ['*.jar'])
	compile(name: 'VuforiaWrapper', ext:'aar')
}

I used to build with Unity 2017.2.0b10, and the VuforiaWrapper dependency was not there. When I remove that dependency the project builds, but of course Vuforia does not work.

Any ideas? The error only occurs when integrating, meaning that I can build the Unity Grade project on its own without problems.

Much appreciated!

Ian

Ps. Seems like this individual has a similar problem: https://developer.vuforia.com/forum/unity/error-import-unity-project-android-studio

undeclared identifiers

I'm getting the following errors after following all the instructions:

Classes/AppDelegate.mm:45:13: Use of undeclared identifier 'UnityRegisterRenderingPlugin'

Classes/AppDelegate.mm:50:12: Use of undeclared identifier 'UnityGetMainWindow'

Classes/AppDelegate.mm:109:9: Use of undeclared identifier 'UnitySendMessage'

Classes/AppDelegate.mm:123:9: Use of undeclared identifier 'UnitySendMessage'

I can see these methods are in the file UnityInterface.h so I added an import line to the file but then I get linking errors.

Undefined symbols for architecture arm64:
"_UnityGetMainWindow", referenced from:
-[AppDelegate unityWindow] in AppDelegate.o
"OBJC_CLASS$_VuforiaRenderDelegate", referenced from:
objc-class-ref in AppDelegate.o
"OBJC_CLASS$_UnityAppController", referenced from:
objc-class-ref in AppDelegate.o
"_UnitySendMessage", referenced from:
-[AppDelegate sendMessageToUnity:] in AppDelegate.o
-[AppDelegate sendMessageToUnity:parameter:] in AppDelegate.o
"_VuforiaRenderEvent", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
"_UnityRegisterRenderingPlugin", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any ideas? Any help is appreciated.

iOS Unity part fails

Hi,

I followed the tutorial with partial luck. The app builds and launch on iPhone X but when i press the button in Cordova part to launch Unity the app just closes. No error or something.

Unity app is basic ARKit app to show model on table.

I've added ARKit, min SDK is 11.4.

What else can i send you so you could help me?

EDIT
i moved forward with:
#15
but now I get:
http://prntscr.com/ku5h7f

iOS - Error opening the Unity Activity - NSInvalidArgumentException: [NSNull UTF8String]: unrecognized selector sent to instance

Hello,

I'm building a cross platform app using Ionic + Unity with Vuforia, and its currently working smoothly with Android.
I've been struggling with making it work properly in iOS. As soon as I launch unity, the splash screen shows up and the app crashes with the following error:

Uncaught exception: NSInvalidArgumentException: -[NSNull UTF8String]: unrecognized selector sent to instance 0x1b2da0650'

It also points to the following line on Other sources/main.mm
captura de ecra 2018-07-09 as 03 49 55

Full log:
https://pastebin.com/raw/jHfSXZ2s

I've searched around and no one seems to be having this issue.
Any clue? my main.mm seems fine.

Thanks.

Android studio error: Unable to merge dex

Followed the instructions in the Readme. When I try to build to device I get the following error:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Not really sure how to go about fixing this. Any ideas?

Webview activity is always restarted

Hi, I'm trying to integrate your plugin with a plain cordova app. I successfully managed to start the Unity Activity, but once finish is called, the main cordova activity is restarted. Am I missing something?
Thank you.

I also do not get the onActivityResult callback.

Android build file: package com.unity3d.player does not exist

Hey all! When I try to build on a clean project after adding the ionic plugin from the tutorial, this is the error log I get. Not sure what I can do to solve it. Do I need to be on a older gradle version?

Ionic:

   ionic (Ionic CLI)  : 4.1.1 (/Users/ivan.mayes/.npm_modules/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.11

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0
   Cordova Plugins       : no whitelisted plugins (0 plugins total)

System:

   Android SDK Tools : 26.1.1 (/Users/ivan.mayes/Library/Android/sdk)
   NodeJS            : v10.6.0 (/usr/local/bin/node)
   npm               : 6.1.0
   OS                : macOS High Sierra
   Xcode             : Xcode 9.4.1 Build version 9F2000
BUILD FAILED in 24s
38 actionable tasks: 38 executed
(node:20377) UnhandledPromiseRejectionWarning: Error: /Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:13: error: package com.unity3d.player does not exist
import com.unity3d.player.UnityPlayer;
                         ^
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:14: error: package com.unity3d.player does not exist
import com.unity3d.player.UnityPlayerActivity;
                         ^
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:16: error: cannot find symbol
public class UnityPlayerExtendedActivity extends UnityPlayerActivity
                                                 ^
  symbol: class UnityPlayerActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:24: error: cannot find symbol
                                UnityPlayer.UnitySendMessage("IonicComms", intent.getStringExtra( "func" ), intent.getStringExtra( "param" ) );
                                ^
  symbol:   variable UnityPlayer
  location: class IonicToUnityBroadcastReceiver
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:34: error: method does not override or implement a method from a supertype
        @Override protected void onCreate (Bundle savedInstanceState)
        ^
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:36: error: cannot find symbol
                Intent intent = getIntent();
                                ^
  symbol:   method getIntent()
  location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:42: error: cannot find symbol
                registerReceiver(broadcastReceiver, new IntentFilter( CordovaUnityLauncher.IONIC2UNITY_SEND_MESSAGE_BROADCAST ) );
                ^
  symbol:   method registerReceiver(IonicToUnityBroadcastReceiver,IntentFilter)
  location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:43: error: cannot find symbol
                super.onCreate(savedInstanceState);
                ^
  symbol:   variable super
  location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:46: error: method does not override or implement a method from a supertype
        @Override protected void onDestroy ()
        ^
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:48: error: cannot find symbol
                unregisterReceiver( broadcastReceiver );
                ^
  symbol:   method unregisterReceiver(IonicToUnityBroadcastReceiver)
  location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:49: error: cannot find symbol
                super.onDestroy();
                ^
  symbol:   variable super
  location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:59: error: cannot find symbol
                        sendBroadcast( ionicMessage );
                        ^
  symbol:   method sendBroadcast(Intent)
  location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:75: error: cannot find symbol
                setResult(Activity.RESULT_OK, resultIntent);
                ^
  symbol:   method setResult(int,Intent)
  location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:77: error: cannot find symbol
                finish();
                ^
  symbol:   method finish()
  location: class UnityPlayerExtendedActivity
14 errors

FAILURE: Build failed with an exception.

About 64-bit ARM, x86 and x64 Android Devices

Hi.
I want to comment something about "About 64-bit ARM, x86 and x64 Android Devices" section.
I had the same problem you coment in this section but I found the folders arm64-v8a, armeabi or x86_64 in the libs folder and not on the jniLibs.

Thank you for your fantastic plugin!!

"ProjectName" was compiled with optimization - stepping may behave oddly; variables may not be available.

2018-10-26 01:36:59.799248+1000 PurposeUniversity[752:156426] showUnityWindow
-> applicationDidFinishLaunching()
PurposeUniversity was compiled with optimization - stepping may behave oddly; variables may not be available.

I followed all instructions and xcode projects runs without any issues.
But when I click a button to show unity player it shows above error and stops working.

Original project is using Vuforia and faced same error.
So I created new empty unity project but got same error.

Unity version : 2018.2.1f1

How can I solve this issue?
Thanks.

iOS 11.3 and Xcode 9.3 problems

Hi everyone!

This comment is related to #16

When you build your app in Xcode to iOS 11.3 and you start unity the camera shows black screen. The UI and everything else works fine but everything is black. The problem is currently you can't build your Vuforia(or any Unity app but I am not tested it) with Xcode 11.3.

The solution is really weird but working. These are the steps:

-First download Xcode 9.2
-Extract it and rename to "Xcode 9.2" and put it into the Application folder (important note: Do not delete or replace Xcode 9.3 because you still need it)
-After you install you have to find Xcode 9.3 -> right click -> Show Package Contents -> Contents -> Developer -> Platforms -> iPhoneOS.platform -> DeviceSupport -> copy 11.3 folder and paste it the same place in Xcode 9.2
-Open the project in Xcode 9.2 and Build
-And it will be working again

Kind regards,
Máté

'UnityAppController.h' file not found

After following the steps I am getting the following error from Classes\AppDelegate.h:

'UnityAppController.h' file not found

I have completed and re-verified the following steps:

--In Configurations of your project, set all the configurations as unityconfig

--In Build Settings, set the value of UNITY_IOS_EXPORTED_PATH to the path of your Unity iOS build folder (do this for PROJECT and the TARGETS)

--In Build Settings, select Prefix Header and press Delete to revert its value back to the default value (in case it is overridden)(do this for PROJECT and the TARGETS)

Any ideas if there is something else that could be missing?

error - ionic cordova plugin add

When I run the command:
ionic cordova plugin add https://github.com/yasirkula/UnityIonicIntegration.git ,

I get this error:

(node:4992) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Failed to fetch plugin https://github.com/yasirkula/UnityIonicIntegration.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: cmd: Command failed with exit code 1 Error output:
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0: Cloning into 'C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0'...
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0: git-upload-pack 'C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645': git-upload-pack: command not found
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0: fatal: Could not read from remote repository.
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0:
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0: Please make sure you have the correct access rights
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0: and the repository exists.
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0:
npm ERR! Windows_NT 10.0.17134
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "https://github.com/yasirkula/UnityIonicIntegration.git" "--production" "--save"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! code 128

npm ERR! Command failed: git -c core.longpaths=true clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0
npm ERR! Cloning into 'C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0'...
npm ERR! git-upload-pack 'C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645': git-upload-pack: command not found
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     D:\Desenvolvimento\workspace\anime-buzz-mobile\animebuzz-mobile\npm-debug.log

Issue about building second time with Ionic

Hi,

I worked on integrating Unity into a Cordova app (only on Android for now) and I found a better way to avoid error while building with Cordova a second time.
Actually, what makes the error is the file Settings.Gradle is auto-generated during the building so it overrides the line

project(':UnityProject').projectDir = new File('C:\absolute path\to your\unity export folder')

Basically you'll need to add this line each time after you build Cordova. But there is another way, you can add this line automatically. To do so, you'll need to

  • go to path/to/project/platform/android/cordova/lib/builders/GradleBuilder.js
  • go to line 100 (approximatively) where you can find and add the last line:
    fr.writeFileSync(path.join(this.root, 'settings.gradle'), '//GENERATED FILE - DO NOT EDIT\n' + 'include ":"\n' + settingsGradlePaths.join('') + 'project(":UnityProject").projectDir = new File("C:\\absolute path\\to your\\unity export folder")');

I did this with Cordova but I think it would be no different with Ionic, and thanks to that you don't need to remove then add android platform, which requires to re-import Unity and redo all the code on AS each time.

Hope this will be useful for you !

Clarify Android steps in one point

Hi yasirkula,

thank you! Your solution accompanied by the tutorial work like a charm for me!

Just one thing you could maybe explain more clear in your tutorial:

"Open build.gradle of android module and insert the following line into dependencies, where all the other compile command(s) are located at:"

This step in the Android section is perfectly clear if you changed any gradle files before. I myself did it the first time ;) So I opened the file and put the "compile ..." line into the dependencies section I saw at first glance. But this is a sub-section of the "buildscript" section. Didn't work as could be expected than ;)

Maybe something like "into dependencies (section at top level, not a sub-set of other sections like buildscript)..." or so would help others to avoid that mistake and keep them from searching google for the android studio error message ;)

Best regards
Greg

iOS : video frame is black (but sound is ok)

Hi @yasirkula ,

I followed each step of your very precise and thorough tutorial for iOS, and I got absolutely no problem.
(just a parenthesis : this time, on iOS, no dark Unity screen unlike android ;-) )

My Unity project recognises a photo and play a video overlay (with music). I hear the music but the video frame remains black.

Someone has the same problem on StackOverflow, and they advise to disable multi-threading, but my Unity version is more recent, and I can't find this setting.
https://stackoverflow.com/questions/36563405/vuforia-video-playback-video-is-black?rq=1

It seems problem isn't due to your process, but I dare to ask : did you encounter the same problem ? :)

Thank you very much in advance.

EDIT :
Oh, it works on an iPhone SE with iOS 10, but not with an iPodTouch on iOS 9.

Problem with gvr and unitygvr files

Hi.
I am working with a Unity 2017.3 project and I have problems to solve dependences on the Unity's build.gradle because I must to compile a gvr.aar file and unitygvr.aar file on the libs folder, this files are created with my Unity project.
The Android Studio throws "Failed to resolve: gvr" and "Failed to resolve: unitygvr"

This is my Unity build.gradle fragment:

allprojects {
   repositories {
      flatDir {
        dirs 'libs'
      }
   }
}

apply plugin: 'com.android.library'

dependencies {
	compile fileTree(dir: 'libs', include: ['*.jar'])
	compile(name: 'gvr', ext:'aar')
	compile(name: 'unitygvr', ext:'aar')
}

How can I fix that?
Thanks

Android: Vuforia video black screen

Hi there,

We have a Vuforia marker with a video that plays when the marker is scanned. The video is included in the Unity project. The video just appears black on Android devices and eventually crashes the unity part of the app. We've got other markers that display 3D assets too and they work perfectly fine on Android.

If we only run the Unity project separately the video works on Android, so this only happens when the project is integrated.

Everything is fine on iOS.

We've tried removing the multi-threaded rendering and transcoding the videos (and the override for android option). We also tried vp8 and h.264 codecs (specified in Unity).

We've been battling with this for 2 solid days and I'm out of ideas.

Do you perhaps have a clue of what could be the problem?

Kind regards,

Ian

ARKit

Have anyone tried with ARKit?

When I try to build using this plugin I got this error, I'm not sure how to fix it.

screen shot 2018-05-24 at 9 19 54 am

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.