Skip to content

Commit

Permalink
Version 3.1.0 of the Google Mobile Ads Unity Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Ram Parameswaran committed Oct 8, 2016
1 parent 244d4bb commit add3cfc
Show file tree
Hide file tree
Showing 39 changed files with 147 additions and 2,992 deletions.
11 changes: 11 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
Google Mobile Ads Unity Plugin Change Log

*************
Version 3.1.0
*************
- Integrate plugin with play-services-resolver-1.2.1.0.
- Removal of CocoaPods integration.

Built and tested with:
- Google Play services 9.6.0
- Google Mobile Ads iOS SDK 7.12.0
- Unity Jar Resolver 1.2.1.0

*************
Version 3.0.7
*************
Expand Down
41 changes: 37 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ project.ext {
if (unity_exe == null || unity_exe.isEmpty()) {
unity_exe ='/Applications/Unity/Unity.app/Contents/MacOS/Unity'
}
resolverPackageUri = System.getProperty("RESOLVER_PACKAGE_URI")
if (resolverPackageUri == null) {
resolverPackageUri = (
'https://github.com/googlesamples/unity-jar-resolver/raw/master/' +
'play-services-resolver-1.2.1.0.unitypackage')
}
pluginSource = file('source/plugin').absolutePath
pluginBuildDir = file('temp/plugin-build-dir').absolutePath
buildPath = file('temp').absolutePath
exportPath = file('GoogleMobileAds.unitypackage').absolutePath
resolverPath = file('play-services-resolver.unitypackage').absolutePath
}

// Delete existing android plugin jar file.
Expand All @@ -45,6 +52,21 @@ task copyAndroidLibraryJar(type: Copy) {

copyAndroidLibraryJar.dependsOn(clearJar, buildAndroidPluginJar)

task downloadResolver() {
description = "Download the Play Services Resolver"
doLast {
def resolver = new File("${resolverPath}")
if (!resolver.exists()) {
new URL("${resolverPackageUri}").withInputStream{
inputStream -> resolver.withOutputStream{ it << inputStream }}
}
}
}

task deleteResolver(type: Delete) {
delete { "${resolverPath}" }
}

// Build unity package using through command line interface.
// Create new unity project with files in temporary build directory and export files within Assets/GoogleMobileAds
// to a unity package.
Expand All @@ -54,7 +76,17 @@ task exportPackage() {
doLast {
exec {
executable "${unity_exe}"
args "-g.building", "-batchmode", "-projectPath", "${pluginBuildDir}", "-logFile", "temp/unity.log", "-exportPackage", "Assets/GoogleMobileAds", "Assets/Plugins", "Assets/PlayServicesResolver", "${exportPath}", "-quit"
args "-g.building",
"-batchmode",
"-projectPath", "${pluginBuildDir}",
"-logFile", "temp/unity.log",
"-importPackage", "${resolverPath}",
"-exportPackage",
"Assets/GoogleMobileAds",
"Assets/Plugins",
"Assets/PlayServicesResolver",
"${exportPath}",
"-quit"
}
}
}
Expand All @@ -65,8 +97,9 @@ task createTempBuildFolder(type: Copy) {
}

task clearTempBuildFolder(type:Delete) {
delete {"${buildPath}"}
delete {"${buildPath}"}
}

exportPackage.dependsOn(createTempBuildFolder, copyAndroidLibraryJar)
exportPackage.finalizedBy(clearTempBuildFolder)
exportPackage.dependsOn(createTempBuildFolder, copyAndroidLibraryJar,
downloadResolver)
exportPackage.finalizedBy(clearTempBuildFolder, deleteResolver)
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ private void RequestRewardBasedVideo()
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "ca-app-pub-3940256099942544/6905715713";
string adUnitId = "INSERT_AD_UNIT_HERE";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/9998782919";
string adUnitId = "INSERT_AD_UNIT_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
Expand Down Expand Up @@ -458,4 +458,4 @@ public void HandleRewardBasedVideoLeftApplication(object sender, EventArgs args)
}

#endregion
}
}
4 changes: 2 additions & 2 deletions source/android-library/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.android.gms:play-services:9.6.0'
}

task clearJar(type: Delete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ public class RewardBasedVideo {
*/
private boolean isLoaded;

private final Object mLock = new Object();

public RewardBasedVideo(Activity activity, UnityRewardBasedVideoAdListener adListener) {
this.activity = activity;
this.adListener = adListener;
Expand Down Expand Up @@ -149,7 +147,8 @@ public void run() {
* Destroys the {@link RewardedVideoAd}.
*/
public void destroy() {
rewardBasedVideo.destroy();
// Currently there is no destroy() method for the RewardedVideoAd class. This method is a
// placeholder in case there is any cleanup to do here in the future.
}
}

2 changes: 1 addition & 1 deletion source/android-library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.tools.build:gradle:2.2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Dec 18 19:33:03 EST 2015
#Fri Sep 30 15:07:15 PDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
2 changes: 1 addition & 1 deletion source/plugin/Assets/GoogleMobileAds/Api/AdRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace GoogleMobileAds.Api
{
public class AdRequest
{
public const string Version = "3.0.7";
public const string Version = "3.1.0";
public const string TestDeviceSimulator = "SIMULATOR";

public class Builder
Expand Down
88 changes: 88 additions & 0 deletions source/plugin/Assets/GoogleMobileAds/Editor/AdMobDependencies.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright (C) 2016 Google, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using UnityEditor;

/// AdMob dependencies file.
[InitializeOnLoad]
public class AdMobDependencies : AssetPostprocessor
{
/// Initializes static members of the class.
static AdMobDependencies() { SetupDeps(); }

static void SetupDeps() {
#if UNITY_ANDROID
// Setup the resolver using reflection as the module may not be
// available at compile time.
Type playServicesSupport = Google.VersionHandler.FindClass(
"Google.JarResolver", "Google.JarResolver.PlayServicesSupport");
if (playServicesSupport == null) {
return;
}
object svcSupport = Google.VersionHandler.InvokeStaticMethod(
playServicesSupport, "CreateInstance",
new object[] {
"AdMobUnity",
EditorPrefs.GetString("AndroidSdkRoot"),
"ProjectSettings"
});

Google.VersionHandler.InvokeInstanceMethod(
svcSupport, "DependOn",
new object[] { "com.google.android.gms", "play-services-ads",
"LATEST" },
namedArgs: new Dictionary<string, object>() {
{"packageIds", new string[] {
"extra-google-m2repository",
"extra-android-m2repository"} }
});

// Marshmallow permissions requires app-compat.
Google.VersionHandler.InvokeInstanceMethod(
svcSupport, "DependOn",
new object[] { "com.android.support", "appcompat-v7", "23.1.0+" },
namedArgs: new Dictionary<string, object>() {
{"packageIds", new string[] { "extra-android-m2repository" }},
});
#elif UNITY_IOS
Type iosResolver = Google.VersionHandler.FindClass(
"Google.IOSResolver", "Google.IOSResolver");
if (iosResolver == null) {
return;
}
Google.VersionHandler.InvokeStaticMethod(
iosResolver, "AddPod",
new object[] { "Google-Mobile-Ads-SDK" },
namedArgs: new Dictionary<string, object>() {
{ "version", "7.8+" }
});
#endif // UNITY_IOS
}

// Handle delayed loading of the dependency resolvers.
private static void OnPostprocessAllAssets(
string[] importedAssets, string[] deletedAssets,
string[] movedAssets, string[] movedFromPath) {
foreach (string asset in importedAssets) {
if (asset.Contains("IOSResolver") ||
asset.Contains("JarResolver")) {
SetupDeps();
break;
}
}
}
}

84 changes: 0 additions & 84 deletions source/plugin/Assets/GoogleMobileAds/Editor/CocoaPodHelper.cs

This file was deleted.

12 changes: 0 additions & 12 deletions source/plugin/Assets/GoogleMobileAds/Editor/CocoaPodHelper.cs.meta

This file was deleted.

5 changes: 0 additions & 5 deletions source/plugin/Assets/GoogleMobileAds/Editor/Podfile

This file was deleted.

8 changes: 0 additions & 8 deletions source/plugin/Assets/GoogleMobileAds/Editor/Podfile.meta

This file was deleted.

Loading

0 comments on commit add3cfc

Please sign in to comment.