Closed Frobei closed 7 years ago
That is handy tip to know, thank you. The reason I have suggested removing and adding the android platform is actually because the UnityArCallerPluginIonic plugin depends on the unity-classes.jar file that we remove from the jniLibs folder and ionic build gives errors if the file does not exist. Readding the android platform replaces the removed unity-classes.jar with a new one but maybe just ionic prepare android
would suffice in that case, I should check it.
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
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
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 !