Nachding
Nachding

Reputation: 465

Import Unity Ads SDK in Android Studio

I just finished an app for Android and I would like to integrate ads on it with Unity Ads. I have to import the Unity Ads SDK project so, I went to : File/Import Module. Once done I entered the path of the folder but after that, I am blocked : Android Studio shows me that :

My problem

What should I fill ?

Upvotes: 2

Views: 8251

Answers (4)

Fabrizio Billeci
Fabrizio Billeci

Reputation: 582

A newer solution:

  1. Go to File > New > New Module > Import .JAR / .AAR package
  2. Select your .aar file (already inside /app/libs dir)
  3. Add this gradle's app dependency: implementation project(path: ':unity-ads')
  4. Now you are ready to use the SDK.

Upvotes: 6

oalpayli
oalpayli

Reputation: 265

I found solution.

  1. Download and unzip master zip

  2. Go Android Studio File --> Open Module Settings --> click plus button.

  3. When dialog open, you should choose Eclipse project module.

  4. Select unity-ads package in master project.

  5. And Finish.

Stay happy to code :)

Upvotes: 2

Townsfolk
Townsfolk

Reputation: 1334

To answer your question. You shouldn't need to put anything there. It's only if you want to be able to view the source of the library - intelli-sense. That being said, I didn't like that set up and went a different route which I found easier.

Here's what I did.

  1. Download and unzip the master zip (pre-built packages)
  2. Copy or move the ./unity-ads-sdk-master/unity-ads/libs/unity-ads.jar to your projects ./libs dir.
  3. Copy the permissions and Activity definition from the provided AndroidManifest.xml file.

    <application>
        <activity
            android:name="com.unity3d.ads.android.view.UnityAdsFullscreenActivity" 
            android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:hardwareAccelerated="true" />
    </application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    
    <!-- Note: If android:maxSdkVersion attribute leads to problems when merging manifests, you can
    remove maxSdkVersion attribute. Unity Ads on Android 4.4 or later won't need this permission so
    maxSdkVersion means it is only requested for older Androids. -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
    

    3a. Might need to refresh from your Gradle tool window.

  4. Follow rest of instructions starting from Integrate Unity Ads to Your Codebase

Upvotes: 0

Chopi
Chopi

Reputation: 1143

I have never tried to import Unity Ads to an non Unity project.

I found this in the Unity website I hope it can be helpful but it's for eclipse...

https://unityads.unity3d.com/help/Documentation%20for%20Publishers/Integration-Guide-for-Android

Upvotes: 0

Related Questions