UnityIonicIntegration icon indicating copy to clipboard operation
UnityIonicIntegration copied to clipboard

ionic issue: Unable to find a matching configuration of project

Open adikhadilkar opened this issue 5 years ago • 5 comments

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.

adikhadilkar avatar May 16 '19 09:05 adikhadilkar

Hi,

  1. You have to export your unity project to GRADLE, and then use your GRADLE exported project.
  2. You can either have it inside or outside of your Ionic project, but you have to add the correct path (relative or absolute) to the GRADLE exported project. I recommend you to put the gradle exported project into the platforms/android folder, so if you are in windows, you can reference the folder as .\\<relative path to your gradle project here> for this example, I'll use .\\AugmentedReality

As I see, you are getting the error because you didn't put the path to the gradle project on the following part:

include ":UnityProject"
project(":UnityProject").projectDir = new File("complete path to my unity project")

remember that you have to replace "complete path to my unity project" with the path to your actual gradle exported project for example .\\AugmentedReality So you should modify this on the GradleBuilder.js file (remember that you have to send four backslash ' \ ' because the first ones escapes the next one ) for something like this:

+ 'include ":UnityProject"\nproject(":UnityProject").projectDir = new File(".\\\\AugmentedReality")'

and the settings.gradle file will always be:

include ":UnityProject"
project(":UnityProject").projectDir = new File(".\\AugmentedReality")

I hope it helps.

juan9506 avatar May 16 '19 16:05 juan9506

Thanks again @juan9506 for the help 👏 👍

@adikhadilkar If the suggested modifications won't work for you, please try using Android Studio for the integration.

yasirkula avatar May 17 '19 10:05 yasirkula

@juan9506 Extremely sorry for the late reply.

I just put "complete path to my unity project" to show that I have put the path there.

I have given actual the path to my unity project in gradle builder file but I was using the WEB/GL export which is wrong.

Thanks a lot for your solution. I will try to add gradle export this time and let you know.

adikhadilkar avatar Jun 14 '19 06:06 adikhadilkar

@yasirkula Thanks. I will first give it a try without android studio & if it still doesn't work then I will use the android studio.

adikhadilkar avatar Jun 14 '19 06:06 adikhadilkar

@juan9506 As per your suggestion, I exported my unity project to Gradle & now I have an exported Gradle build named "defaul1"

I put my IonicComms.cs file inside that "Gradle build" in the "assets" folder (defaul1\src\main\assets)

I modified the GradleBuilder.js file

// Write the settings.gradle file.
    fs.writeFileSync(path.join(this.root, 'settings.gradle'),
        '// GENERATED FILE - DO NOT EDIT\n' +
        'include ":"\n' + settingsGradlePaths.join('') + 
        'include ":UnityProject"\n' + 
        'project(":UnityProject").projectDir = new File(".\\\\defaul1")');

Now my settings.gradle file looks like this:

// GENERATED FILE - DO NOT EDIT
include ":"
include ":CordovaLib"
include ":UnityProject"
project(":UnityProject").projectDir = new File(".\\defaul1")

I am now getting a different error but I think it is related to the path of Gradle /unity project.

* What went wrong:
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:
          - Configuration 'debugApiElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
              - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
          - Configuration 'debugMetadataElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Metadata'.
              - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'java-api' but no value provided.
          - Configuration 'debugRuntimeElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
              - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'.
          - Configuration 'releaseApiElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
              - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
          - Configuration 'releaseMetadataElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Metadata'.
              - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'java-api' but no value provided.
          - Configuration 'releaseRuntimeElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
              - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'.

I tried different combinations with paths but all of them are resulting in one of the above-mentioned errors.

I am a little confused about the path in GradleBuilder.js file & what it should be. Can you help me with that?

My Gradle project is currently in platforms -> android directory & I have kept my IonicComms.cs file in the following directory (platforms\android\defaul1\src\main\assets).

please let me know how to solve this path issue or if I am missing any step

Thank you.

adikhadilkar avatar Jun 14 '19 13:06 adikhadilkar