Permalink
Fetching contributors…
Cannot retrieve contributors at this time
70 lines (44 sloc) 3.77 KB

Android Studio 1.5.+ project To Build UnityARPlayer.jar

Written By: John Wolf

Last Updated: 2016-11-07


The "UnityARPlayer.jar" File Build Process

This process has only been tested using Android Studio 1.5.1 installed on Mac OS X.

With a 1.5.1 or greater version of the Android Studio IDE, open the Android Studio project:

    [ARToolKit for Unity Repo]/
        src/Android_Unity_Player_Source/AndroidStudioProj

After the project and the Android Studio IDE is open, check that the SDK and NDK paths are set correctly. (It's a requirement to have the latest Android SDK and NDK downloaded on your devbox.) In the Android Studio IDE, go to "File"/"Project Structure...". In the resulting dialog box, click "SDK Location" in the section along the left margin. In the main window on the right, check the paths on under "Android SDK location:" and "Android NDK location:".

Place the following updated dependencies of:

        arBaseLib-release/aRBaseLib-release.aar
        BT200Ctrl/BT200Ctrl.jar
        Unity classes/classes.jar (where this found is indicated below)

under the following path:

    [ARToolKit for Unity Repo]/
        /src/Android_Unity_Player_Source/AndroidStudioProj/

Warning: The Unity classes/classes.jar content can change in new Unity editor IDE versions. Therefore, match version between the Unity Editor IDE and the Unity classes.jar file used in your Android Studio project.

The classes/classes.jar file ships with Unity and can be located here:

  • On Unity 5.3 for Mac OS X:
    /Applications/Unity/Unity.app/[Show Package Contents]
        /Applications/Unity/Contents/PlaybackEngines/AndroidPlayer/
        Variations/["mono" | "il2cpp"]/Release/Classes/classes.jar
  • On Unity 5.4 or greater for Mac OS X:
    /Applications/Unity/PlaybackEngines/AndroidPlayer/Variations/["mono" | "il2cpp"]/Release/
  • For Unity 5.3 on Windows 10:
    C:\Program Files\Unity5.3\Editor\Data\PlaybackEngines\AndroidPlayer\Variations["mono" | "il2cpp"]\Release\Classes\classes.jar
  • For Unity 5.4 or greater on Windows 10:
    [TBA]

Currently, ARToolKit was tested only using the "mono" subdirectory path classes.jar file. Therefore, "il2cpp" isn't supported.

The sources of BT200Ctrl.jar are not published jet so just keep the one that ships with this project.

Build the Java source files to class files by doing: "Build"/"Make Project"

Export the class files as a ".jar" file named "UnityARPlayer.jar".

In the right margin of the Android Studio main windows, click and open: "Gradle". This results in a window openning on the right side of the Android Studio IDE labeled "Gradle project". Twirl open "AndroidStudioProj" followed by twirling open another "AndroidStudioProj" icon. Then twirl open "Tasks" followed by "other." Scroll to "jarRelease." Double click "jarRelease" from the "Gradle projects" windows. This collects the built class files and packages them into:

    [ARToolKit for Unity Repo]/src/Android_Unity_Player_Source/
        AndroidStudioProj/UnityARPlayer/build/libs/UnityARPlayer.jar

Placing the "UnityARPlayer.jar" File

Copy the updated "UnityARPlayer.jar" file:

from

    [ARToolKit for Unity Repo]/src/Android_Unity_Player_Source/
        AndroidStudioProj/UnityARPlayer/build/libs/UnityARPlayer.jar

to

    [ARToolKit for Unity Repo]/src/Unity/Assets/Plugins/Android/

Task Complete.