Everyone is thinking that “It is really hard to Exporting and running the Unity3D project to Android Studio”, but the thing is it is not really hard. In this article, we will be covering how to export the Unity3D project and run it from the Android studio.
Make sure you are using the latest version of Unity and Android Studio. We are using the latest version for this article. Follow the steps to run Unity3D projects on Android Studio.
Step 1: Exporting To Android Studio:
1.1 The first step is to create a root folder that will hold the exported folders and files from Unity. We can call it “AndroidTestProject” and the full directory will be like “C:/AndroidTestProject“.
1.2 Exporting files and folders to the directory “C:/AndroidTestProject“. To export follow the steps,
1.2.1 Go to “File -> Build Settings“, Build Settings window will appear.
1.2.2 Under the Platform section select Android and tick the “Google Android Project” checkbox.
1.2.3 After enabling the “Google Android Project” checkbox, click on the Export button on the bottom.
1.2.4 When you click on Export it will ask to select the export directory, Select C:/AndroidTestProject then click on the “Select Folder” button at the bottom.
Unity will build the project, after generating the project, a new folder will be created in the directory C:/AndroidTestProject. The folder name will be the “Product Name” which you gave in “Player Settings“, for demo purposes we have given as “test” as Product Name. so in this case the folder name will be “test” which is located at “C:/AndroidTestProject/test“.
Step 2: Importing into Android Studio:
2.1 Create a new folder “AndroidStudio” in C: -> AndroidTestProject folder, the full path will be “C:/AndroidTestProject/AndroidStudio“.
2.2 To Import, open Android Studio, when you open Android Studio just click on “Import project (Eclipse ADT, Gradle, etc.)” to import the Unity project. If “Import project (Eclipse ADT, Gradle, etc.)” is not displayed then close the current project by going to File -> Close Project, then you can select “Import project (Eclipse ADT, Gradle, etc.)”.
2.3 Go to C: -> AndroidTestProject -> test, select the test folder, and click on ok.
2.4 When you click on ok a new window will pop up, in that the “Import Destination Directory” should be “C:/AndroidTestProject/AndroidStudio” which we create in 1st step(2.1). Then click on Next.
2.5 In the next step we want to Select/Tick all the checkboxes, then click on the Finish button.
When we click on Finish the Android Studio will load the project, we will get an error like,
Error: Minimum supported Gradle version is 2.14.1. The current version is 2.10. If using the Gradle wrapper, try editing the distributionUrl in C:\AndroidTestProject\AndroidStudio\gradle\wrapper\gradle-wrapper.properties to Gradle-2.14.1-all.zip Fix Gradle wrapper and re-import project Gradle settings
When you get this error just click on “Fix Gradle wrapper and re-import project Gradle settings” message if you cant see this error message make sure you are in the message tab.
Wait for Android Studio to fix the Gradle problem, when the problem is fixed, go to Build -> Make Project.
When the project is done building we can run the app, to run go to Run -> Run app.
Create a new emulator or chose the existing emulator to run the app.
Now you can successfully export the project from Unity and successfully import the project into Android Studio and you can run the app from Android Studio itself.
Leave a Comment