Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by hammondt · Jan 09, 2017 at 02:32 AM · plugingoogle playpluginsgooglegoogle-play-store

Unity Google Play Services

I'm attempting to add Google Play Services using the Jar Resolver that Google put out - https://github.com/googlesamples/unity-jar-resolver to create a plugin we can re-use to easily add Google Play Services to our projects.

I've created a copy of their example dependency class:

 // <copyright file="GPGSDependencies.cs" company="Google Inc.">
 // Copyright (C) 2015 Google Inc. All Rights Reserved.
 //
 //  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.
 // </copyright>
 
 using System;
 using System.Collections.Generic;
 using UnityEditor;
 
 
 /// Sample dependencies file.  Change the class name and dependencies as required by your project, then
 /// save the file in a folder named Editor (which can be a sub-folder of your plugin).
 ///   There can be multiple dependency files like this one per project, the  resolver will combine them and process all
 /// of them at once.
 [InitializeOnLoad]
 public class MyDependencies : AssetPostprocessor {
 #if UNITY_ANDROID
   /// <summary>Instance of the PlayServicesSupport resolver</summary>
   public static object svcSupport;
 #endif  // UNITY_ANDROID
 
   /// Initializes static members of the class.
     static MyDependencies() {
 
         //
         //
         // NOTE:
         //
         //       UNCOMMENT THIS CALL TO MAKE THE DEPENDENCIES BE REGISTERED.
         //   THIS FILE IS ONLY A SAMPLE!!
         //
           RegisterDependencies();
         //
   }
 
 
   /// <summary>
   /// Registers the dependencies needed by this plugin.
   /// </summary>
   public static void RegisterDependencies() {
 #if UNITY_ANDROID
     RegisterAndroidDependencies();
 #elif UNITY_IOS
     RegisterIOSDependencies();
 #endif
   }
 
   /// <summary>
   /// Registers the android dependencies.
   /// </summary>
   public static void RegisterAndroidDependencies() {
 
     // 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;
     }
     svcSupport = svcSupport ?? Google.VersionHandler.InvokeStaticMethod(
       playServicesSupport, "CreateInstance",
       new object[] {
           "GooglePlayGames",
           EditorPrefs.GetString("AndroidSdkRoot"),
           "ProjectSettings"
       });
 
     // For example to depend on play-services-games version 9.6.0  you need to specify the
     // package, artifact, and version as well as the packageId from the SDK manager in case
     // a newer version needs to be downloaded to build.
 
     Google.VersionHandler.InvokeInstanceMethod(
       svcSupport, "DependOn",
       new object[] {
       "com.google.android.gms",
       "play-services-games",
       "9.6.0" },
       namedArgs: new Dictionary<string, object>() {
           {"packageIds", new string[] { "extra-google-m2repository" } }
       });
 
     // This example gets the com.android.support.support-v4 library, version 23.1 or greater.
     // notice it is in a different package  than the play-services libraries.
 
     Google.VersionHandler.InvokeInstanceMethod(
       svcSupport, "DependOn",
       new object[] { "com.android.support", "support-v4", "23.1+" },
       namedArgs: new Dictionary<string, object>() {
           {"packageIds", new string[] { "extra-android-m2repository" } }
       });
 
     Google.VersionHandler.InvokeInstanceMethod(
       svcSupport, "DependOn",
             new object[] { "com.hyprmx.mediate", "HyprMediate-SDK", "1.1.0" });
 
   }
 
   /// <summary>
   /// Registers the IOS dependencies.
   /// </summary>
   public static void RegisterIOSDependencies() {
 
     // Setup the resolver using reflection as the module may not be
     // available at compile time.
     Type iosResolver = Google.VersionHandler.FindClass(
         "Google.IOSResolver", "Google.IOSResolver");
     if (iosResolver == null) {
       return;
     }
 
     // Dependencies for iOS are added by referring to CocoaPods.  The libraries and frameworkds are
     //  and added to the Unity project, so they will automatically be included.
     //
     // This example add the GooglePlayGames pod, version 5.0 or greater, disabling bitcode generation.
 
     Google.VersionHandler.InvokeStaticMethod(
       iosResolver, "AddPod",
       new object[] { "GooglePlayGames" },
       namedArgs: new Dictionary<string, object>() {
           { "version", "5.0+" },
           { "bitcodeEnabled", false },
       });
   }
 
   // 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")) {
         RegisterDependencies();
         break;
       }
     }
   }
 }

However, I'm getting an error in Unity: Assets/Plugins/MyDependencies.cs(96,5): error CS0103: The name Google' does not exist in the current context`

Any ideas how I can update the code such that Google does resolve so I can run the class? It seems like they've provided dlls to assist with this however I can't figure out how to get them to resolve. I tried to reference them using using dll1 etc. but they didn't seem to be found.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by evanngo · Jun 19, 2017 at 05:24 AM

I have a same problem but still can't fix it

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by hammondt · Jun 19, 2017 at 10:26 AM

@evanngo You should check out Theoremreach.com. In their unity plugin they do this for you and you can get access to it. Also it's a really great monetization tool. I ended up using their plugin to solve this.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image evanngo · Jun 20, 2017 at 07:18 AM 0
Share

Can you tell me about Theoremreach.com plugin? I'm trying to add $$anonymous$$ediaRouteButton in my project, but I can't import com.android.support:appcompat-v7:23.4.0 library in Unity project.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

87 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What is "good" Install/Uninstall rate for growing-good apps? 0 Answers

play services resolver error after installing GoogleMobileAds plugin 2 Answers

Google Play Services Singleton HELP! 2 Answers

Google Mobile Ads cause Failed to build apk error 0 Answers

How to use App indexing Api's by extending a class with Prime31 's UnityPlayerActivity ? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges