Import Unity Ads SDK in Android Studio - android

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 :
What should I fill ?

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

I found solution.
Download and unzip master zip
Go Android Studio File --> Open Module Settings --> click plus button.
When dialog open, you should choose Eclipse project module.
Select unity-ads package in master project.
And Finish.
Stay happy to code :)

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

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.
Download and unzip the master zip (pre-built packages)
Copy or move the ./unity-ads-sdk-master/unity-ads/libs/unity-ads.jar to your projects ./libs dir.
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.
Follow rest of instructions starting from Integrate Unity Ads to Your Codebase

Related

Uploaded Android APK marked as Android Auto when not set in manifest

I've looked through my whole project directory, and for the life of me, I cannot find where it would think it is an Android Auto. Going through this page:
https://developer.android.com/training/auto/start/index.html#auto-metadata
Nowhere in my Android manifest, do I set an automotive.
Could a library add to the manifest to make it an Automotive app?
Are there other things in the manifest I can check?
Please cross check in your res/xml file and see if you have any media or notification
under - uses element.
You can also check in your manifest file if you have added Car GMS package in the meta-data element.
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="#xml/your_auto_xml_file"
/>
If the library you are importing in happens to be from the merchant who builds up the customized DHU, then these lib can infuse those properties in your project. One easy way would be to remove the library and see if it resolves the issue.

Can I remove com.google.android.gms.version from AndroidManifest when I use gradle?

I wonder if I can remove this line safely:
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
from my AndroidManifest.xml when I use gradle to build my APK.
According to the website https://developers.google.com/android/guides/setup only when I choose "ECLIPSE WITH ADT" I have to add this line. For "ANDROID STUDIO" usage this is not mentioned.
But in my case I use Eclipse (with ADT) as IDE but I build with gradle. (Actually it is a libGDX project). So I added the play-services by using gradle:
compile "com.google.android.gms:play-services:8.1.0"
So I run the app on a test device and I tested to login with play-services and it worked fine without having the line above in my AndroidManifest.xml
But, maybe the login just does not need the "com.google.android.gms.version" value and another part of the play services lib needs it? But I cannot test all the possible ways to use the lib.
Does anybody know for sure?
Or for those of you who use Android Studio + play services: Does your AndroidManifest.xml have the line above?
Yes, as of Google Play services 7.0 (improved in 7.5 to remove the restriction on applying to the full play-services dependency), the <meta-data> tag is automatically added to your Manifest file by Gradle via Manifest merging.

Including an AAR file conditionally

I am using the Estimote SDK, which is included into my project as an AAR file.
I want to use the SDK on devices which support Bluetooth LE, but also want to allow users who do not have supported hardware to install.
The manifest of the Estimote SDK includes:
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />
and this prevents the App from installing on a lot of devices.
I can overrule the android:minSdkVersion:
<uses-sdk android:minSdkVersion="18" />
with
<uses-sdk tools:overrideLibrary="com.estimote.sdk" />
but I don't know how to overrule e.g. the bluetooth_le directive.
I tried unzipping the 'aar', changing the Manifest and repacking as a zip with .aar extension, but I get:
Error:Execution failed for task ':idoms-android:processIDomsAndroidDevDebugManifest'.
> com.android.manifmerger.ManifestMerger2$MergeFailureException: java.io.FileNotFoundException: /Users/Luuk/Documents/Java/idoms-android/idoms-android/build/intermediates/exploded-aar/estimote-sdk-preview/AndroidManifest.xml (No such file or directory)
even thought the file is there. Any help would be appreciated!
#Luuk
I'm a author of Estimote Android SDK.
We will be changing <uses-feature android:name="android.hardware.bluetooth_le"> to required=false for the next SDK release .
You should consider creating 2 flavors of your apk, one that has the BLE support and that includes the SDK that you want to use, and another one that doesn't support BLE.
If you create two flavors of your app, let's call them "ble" and "normal", then you are able to declare some flavor-specific dependencies using bleCompile 'yourDependency' and normalCompile 'yourDependency' in your Gradle build file.

How to get google ads sdk to work in Intellij?

Silly question (noob here) but the tag below in AndroidManifest.xml doesnt work in IntelliJ. The app compiles successfully but crashes on launch. This manifest file works fine in Eclipse. I added the googleadmob*.jar file in the sdk part of the project structure settings.
<activity
android:name="com.google.ads.AdActivity"
...
</activity>
The problem is that you've added the jar to the SDK. It must be configured as a module library instead, refer to the documentation. In this case it will be packaged with your application, while SDK is not packaged as it's already available on the device.
If the class is still shown in red in the editor, try File | Invalidate Caches.

com.google.android.maps not available

I'm new to Android and I'm using IntelliJ to develop. I'm going through various tutorials, etc and now I'm trying to run/compile Wrox project that uses com.google.android.maps
IntelliJ wouldn't compile, it complains that this package does not exist.
How do I add it to project? I have everything downloaded in ADT. I was able to run all other projects no problem. What should I look for?
You need to target the Google APIs instead of Android - in IntelliJ, File-Project Structure SDKs and select Google APIs in Build Target.
Are you targetting the correct Android-jar? You'd want the one with the Google API:s for maps to work. Also make sure you're including the correct permission in your manifest.
And after installing the google api and setting up a project based on the correct api, don't forget the uses-libary tag in the manifest:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:debuggable="true">
<uses-library android:name="com.google.android.maps" />

Categories

Resources