# Configuration

## Android Configuration

### Export to Native

{% hint style="warning" %}
It's advised to maintain separate version control for the exported project so you can be aware of what changes being made by the next export attempt and to ensure that the changes from this documentation remain intact.
{% endhint %}

Now you can export to Android Native. Go to `File` > `Build Settings`. Select `Android` in the Platform list, then check the `Export Project`'s checkbox. Then click the `Export` button.

You will be asked to select a folder before the compiling process starts. Please create one and select it. For this example walkthrough, we named it `ExportedAndroidNative`.

<figure><img src="https://2842391565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KdF0NiQlaQn9ctLpVUh%2Fuploads%2FQKt4XsMql8i7QamOpSyO%2Fimage.png?alt=media&#x26;token=cf24e066-5c2e-4433-b1c0-614d19ded7d7" alt="" width="563"><figcaption><p><em>Build Settings</em></p></figcaption></figure>

Now you have a folder that contains a complete Android Native project.

<figure><img src="https://2842391565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KdF0NiQlaQn9ctLpVUh%2Fuploads%2FMIyJQMcrg13XMKNsWOMf%2Fimage.png?alt=media&#x26;token=85a33f76-2e32-4f95-b99c-a54a05cb1d25" alt="" width="554"><figcaption><p><em>Folder Android Native Project</em></p></figcaption></figure>

#### Open Exported Project

Please open `ExportedAndroidNative` with Android Studio.

<figure><img src="https://2842391565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KdF0NiQlaQn9ctLpVUh%2Fuploads%2FVrAFIrI8jwcqANKtwNT5%2Fimage.png?alt=media&#x26;token=80ba970a-04ab-4c6a-814d-a79c55b8a5aa" alt="" width="563"><figcaption><p>Open Exported Project</p></figcaption></figure>

If there is SDK difference between the Android Studio's SDK and the project's SDK, please select `Use Project's SDK`.

<figure><img src="https://2842391565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KdF0NiQlaQn9ctLpVUh%2Fuploads%2FVhAQ3mmP2RRvjJaTop89%2Fimage.png?alt=media&#x26;token=c8d4ba6b-ecde-49ad-9888-ffdbc0ac7c95" alt=""><figcaption><p>Project's warning</p></figcaption></figure>

{% hint style="warning" %}
If you encounter any Gradle issues, please fix them before continuing to the next step.
{% endhint %}

### Automated Post-Export Android Adjustment

{% hint style="warning" %}
This automation tool only works for the old Gradle version like v6.1.1.
{% endhint %}

Download link: <https://github.com/NoctuaLabs/noctua-android-sdk/releases>

We have provided a tool to ease the integration steps after export in Windows PC. It could automate all the adjustment below in one key strike. The usage is pretty straightforward:

```
C:\Users\foobar>postexport.exe ..\UnitySDKTest_Exported

NoctuaGG Unity Post-Export script started...
Path exists: C:\Users\foobar\src\UnitySDKTest_Exported\unityLibrary\build.gradle
Path exists: C:\Users\foobar\src\UnitySDKTest_Exported\launcher\build.gradle
A valid exported Android project directory found.

Checking and fixing dependencies...C:\Users\foobar\src\UnitySDKTest_Exported
removeGeneratedByUnityLines...
removeGeneratedByUnityLines done.
updateGradleDependencies...
updateGradleDependencies done.
addGoogleServicesPlugin...
addGoogleServicesPlugin done.
addGoogleServicesClasspath...
Found different version of google-services classpath. Replacing with: classpath 'com.google.gms:google-services:4.2.0'
addGoogleServicesClasspath done.
Checking configuration files...C:\Users\foobar\src\UnitySDKTest_Exported
Path exists: C:\Users\foobar\src\UnitySDKTest_Exported\launcher\google-services.json

Your exported project is configured properly.
Please restart Android Studio through File > Invalidate Cache / Restart, then click Invalidate and Restart.

C:\Users\foobar\src\noctuagg-unity-postexport>
```

{% hint style="warning" %}
If you prefer manual adjustment, please continue to read Manual Android Native Adjustment.
{% endhint %}

### Manual Android Native Adjustment

#### Configurations and Build Dependencies

1. Find all `AndroidManifest.xml` files in the project and remove this line within the file, if any.

```Plaintext
<!-- GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN-->
```

2. Add additional dependencies to build.gradle **(Module: unityLibrary)**:

```java
implementation 'androidx.appcompat:appcompat:1.6.1' // If you get error that related to androidx-core, please downgrade to '1.0.0-beta01'
implementation 'com.github.bumptech.glide:glide:4.11.0'
//Google Payment
implementation 'com.android.billingclient:billing:7.0.0'
//Firebase
implementation 'com.google.firebase:firebase-analytics:20.1.1'
//Adjust
implementation 'com.adjust.sdk:adjust-android:4.31.1'
implementation 'com.android.installreferrer:installreferrer:2.2'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
//Facebook
implementation 'com.facebook.android:facebook-android-sdk:14.1.0'
```

Also remove this line:

```Go
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
```

3. Add this to build.gradle **(Module: launcher)**:

```java
apply plugin: 'com.google.gms.google-services'
```

Also remove this line:

```Go
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
```

4. Add this to build.gradle **(Project: AndroidBuild)**:

```Plaintext
classpath 'com.google.gms:google-services:4.3.14'
```

Also remove this line:

```Go
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
```

5. Add `google-services.json` to `launcher` directory.

<figure><img src="https://2842391565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KdF0NiQlaQn9ctLpVUh%2Fuploads%2FFavqyltmhgLjlbI331aV%2Fimage.png?alt=media&#x26;token=91eb6932-fe6f-46f9-982e-2a23130c3beb" alt="" width="375"><figcaption></figcaption></figure>

Then restart Android Studio through `File` > `Invalidate Cache / Restart`, then click `Invalidate and Restart`. The Android Studio should be restarted and all Gradle tasks are resolved.

#### SDK's Java Class

{% hint style="info" %}
Download Noctua's Java class files from this link: <https://github.com/NoctuaLabs/noctua-android-sdk/tree/main/interface>
{% endhint %}

Then add them to `unityLibrary\src\main\java\com\noctua`. Create the directory if it does not exist.

<figure><img src="https://2842391565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KdF0NiQlaQn9ctLpVUh%2Fuploads%2FDVvrrfQxx0OYGGlJhRYK%2Fimage.png?alt=media&#x26;token=a665bc4d-4085-4e88-9f87-0e84630b1ece" alt="" width="563"><figcaption></figcaption></figure>

Change main launcher to your MainActivity.java like this

<figure><img src="https://2842391565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KdF0NiQlaQn9ctLpVUh%2Fuploads%2F2phpCIO3TxipXN7aymHS%2Fimage.png?alt=media&#x26;token=6d668b73-9e97-4c85-acc5-a86d78689e9b" alt=""><figcaption></figcaption></figure>

#### Configure

Then please follow the steps in this guide to configure

{% hint style="info" %}
[<mark style="color:red;">Configur</mark>](https://noctua-labs.gitbook.io/noctua-labs/noctua-labs/sdk-integration/preparation/android/configuration#configurations)[<mark style="color:red;">ation</mark>](https://noctua-labs.gitbook.io/noctua-labs/noctua-labs/sdk-integration/preparation/android/configuration#configurations)

Jump to the "Update Your Manifest", "SDK Checker for Debugging", and "Event Mapping" sections.
{% endhint %}

## iOS Configuration

* Add the file `NoctuaGame.cs` or your script into your Assets unity project.  You can download `NoctuaGame.cs` [here](https://drive.google.com/drive/folders/1uN0c6DGcuoz8gCNXTwbVD5GVAU0xSeEx?usp=share_link)

<figure><img src="https://2842391565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KdF0NiQlaQn9ctLpVUh%2Fuploads%2F873T9wYUOg2Gm9Kh7n00%2Fimg_v3_02bp_465f4630-0312-4584-b8cf-8adcbe4dcfdh.png?alt=media&#x26;token=29642df5-33d8-456c-a328-ae154e76520b" alt=""><figcaption></figcaption></figure>

* Add `UnitySendMessage` and `Send_Message` to Scripting Define Symbols like the picture below.

<figure><img src="https://2842391565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KdF0NiQlaQn9ctLpVUh%2Fuploads%2FWECl2oDccMMIB57BoX2r%2Fimage.png?alt=media&#x26;token=28a911e3-af26-4694-83cc-91ed4baf7158" alt=""><figcaption></figcaption></figure>

* Export To Native

<figure><img src="https://2842391565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KdF0NiQlaQn9ctLpVUh%2Fuploads%2FDtdoHRxYRm8kHn3Xq4mJ%2Fimage.png?alt=media&#x26;token=31e060da-3030-4c3a-b160-c5cfb1eb1514" alt=""><figcaption></figcaption></figure>

* Add `NoctuaConnector.h` and `NoctuaConnector.mm` to the **Classes directory**. Calling the SDK interface in Unity will eventually call the corresponding OC interface in `NoctuaConnector.mm .` You can download `NoctuaConnector` [here](https://drive.google.com/drive/folders/1dsaxPfesUUflu5hSTugdEHnl8c-dhevq?usp=drive_link)

<figure><img src="https://2842391565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KdF0NiQlaQn9ctLpVUh%2Fuploads%2FJY8VTe6UAA9soH2z5oFL%2Fimage.png?alt=media&#x26;token=5477ad70-2989-497a-b232-27659546c7e2" alt=""><figcaption></figcaption></figure>

* The developer needs to **specify the specific object of the callback result to notify Unity and the specific method of the notification object**

<figure><img src="https://2842391565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KdF0NiQlaQn9ctLpVUh%2Fuploads%2F6UKqQwHHEFoAXiOrnilD%2Fimg_v3_02bp_8bbb2a30-acec-4b4b-b501-6c9b16fbf3bh.png?alt=media&#x26;token=e4ce8eca-e4c8-40a8-8fa6-1c217c3655c6" alt=""><figcaption></figcaption></figure>

#### Configure

Then please follow the steps in this guide to configure

{% hint style="info" %}
[<mark style="color:red;">Configuration</mark>](https://noctua-labs.gitbook.io/noctua-labs/noctua-labs/sdk-integration/preparation/ios/configuration)

Jump to the "Update Your Manifest", "SDK Checker for Debugging", and "Event Mapping" sections.
{% endhint %}
