yasirkula / UnityIonicIntegration

A guide to integrating Unity 3D content into an Ionic app and sending messages between them (for Android & iOS)(tested with Vuforia plugin)
104 stars 32 forks source link

Android: Trouble pulling in unity classes #34

Open ivanmayes opened 6 years ago

ivanmayes commented 6 years ago

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!

yasirkula commented 6 years ago

You shouldn't add unity-classes.jar to your dependencies. Does uncommenting the implementation fileTree(include: '*.jar', dir: 'libs') line resolve the issue?

ivanmayes commented 6 years ago

Unfortunately not, that had been commented out just because I was trying all combinations of loading in the unity classes. Just building the project clean and following your instructions, I get the first screenshot I sent, which is the same as below when uncommenting the *.jar line. I've gone back and started another ionic boilerplate project, and refollowed the steps with the same result.

screen shot 2018-08-17 at 4 52 35 pm

yasirkula commented 5 years ago

Why do you comment that line?

juan9506 commented 5 years ago

I was just trying all the ways possible. I managed to solve my problem by downgrading Gradle to 3.5 (I didn't see the other closed issue with my same error) Now, my ionic app closes by itself without erros or logs, but I think this is due to my javascript implementation in the ionic side (I'm a newbie with ionic and typescript). Do you have some sample project so we can see how exactly do we call unity's funcionalities from typescript? I have read many times the instructions but I don't get how to launch the vuforia view from ionic.

yasirkula commented 5 years ago

@juan9506 Assuming that you plan to launch Unity from the homepage, you should insert the openUnity function (that can be found in the documentation) to home.ts and call that function whenever you want to launch Unity. You can e.g. bind it to a button's click event in home.html.

juan9506 commented 5 years ago

I keep getting the same error that unityARCaller is undefined.

yasirkula commented 5 years ago

Don't forget this line:

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