Posts tagged with google-ads-api

I have an iPad app using Google Mobile Ads SDK through CocoaPods and would like to port it to Mac Catalyst. However, the underlying Pods like Google App Measurement does not support Mac Catalyst. When I try to port it, it shows a compile time error saying "...building for Mac Catalyst, but compiling for iOS Simulator" (roughly paraphrasing here).

I tried this solution on Medium (scroll down to "Automate the Process" section). Namely I modified the Podfile to exclude the incompatible libraries from compiling on Mac Catalyst. However when I do that, it removes the previous errors but is giving me two new errors:

Undefined symbol: _OBJC_CLASS_$_GADMobileAds Undefined symbol: _OBJC_CLASS_$_GADRequest 

I don't know how to remove these errors and make it compile on Mac Catalyst. Do you know how to solve them?

I am developing library and using that library as aar to my app as below sample project.

Library Project:

public class UserDevice {     private static final String TAG = "UserDevice";     private static Context mContext;     public UserDevice(final Context context) {         mContext = context.getApplicationContext();     }     private static String getAdvertisementId(Context context) {         String _myads = null;         try {             String id = com.google.android.gms.ads.identifier.AdvertisingIdClient.getAdvertisingIdInfo(context).getId();             if (id != null) {                 _myads = id;             }         } catch (Exception e) {             Log.e(TAG, "Could not get det ID.", e);         }         return _myads;     } } //build.gradle android {     compileSdkVersion 29     buildToolsVersion "29.0.3"     defaultConfig {         minSdkVersion 16         targetSdkVersion 29         versionCode 1         versionName "1.0"         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"         consumerProguardFiles 'consumer-rules.pro'     } ... } dependencies {     // default dependencies     // ...     implementation 'com.google.android.gms:play-services-base:17.2.1'     implementation 'com.google.android.gms:play-services-ads:19.0.1' } 

App Project:

class MainActivity : AppCompatActivity() {     override fun onCreate(savedInstanceState: Bundle?) {         super.onCreate(savedInstanceState)         setContentView(R.layout.activity_main)         val device = UserDevice(this) //         btn_show_ads.setOnClickListener {             label_ads_id.text = device.myads             Log.d("App", "Device Ads id is: ${device.myads}")         }     } } /// build.gradle dependencies {     // default dependencies     // ...     compile(name: 'adslibrary', ext: 'aar')     // compile project(path: ':adslibrary') } 

But what happened here is that it giving error

2020-05-11 10:11:32.489 21925-21991/com.bhavdip.myadstest E/AndroidRuntime: FATAL EXCEPTION: Thread-2     Process: com.bhavdip.myadstest, PID: 21925     java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/ads/identifier/AdvertisingIdClient;         at com.bhavdip.adslibrary.CRDevice.getAdvertisementId(Unknown Source:2)         at com.bhavdip.adslibrary.CRDevice$1.run(Unknown Source:4)         at java.lang.Thread.run(Thread.java:764)      Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.identifier.AdvertisingIdClient" on path: DexPathList[[zip file "/data/app/com.bhavdip.myadstest-fP-f0WbH8_ErVLG3QBcgkQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.bhavdip.myadstest-fP-f0WbH8_ErVLG3QBcgkQ==/lib/arm, /system/lib, /vendor/lib]]         at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)         at java.lang.ClassLoader.loadClass(ClassLoader.java:379)

I already added and am using gms:play-services-ads dependency in library. The app again asks me to add those dependency forcefully.

If I will add the dependency to the app it works fine, but I don't want to add that dependency again. I don't want to expose my library dependency to end user or developer. Adds below dependency to my-library.

//For advertisement ID implementation 'com.google.android.gms:play-services-ads:19.1.0' implementation 'com.google.android.gms:play-services-base:17.2.1' 

Reference links: I tried this and this too. I also checked all answers in reference links.

I have tried multidex, transitive and also changed implementation to api or compile. in app project like this.

// Use transitive compile(name: 'adslibrary', ext: 'aar') {     transitive = true } 

----- EDIT for Questions -----

  • What is transitive? How it works?
  • How multidex works in library?

I might miss something to change. Please help me out of this problem.

I have added the NuGet Google.AdWords 24.10.1 package to a .net core console app. In the SDK documentation they say that .net core is supported. The problem is that the library functions crash on first call with tho following error:

Could not load type 'System.Web.Hosting.HostingEnvironment' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.":"System.Web.Hosting.HostingEnvironment"}

I cant understand if this package is supported or not in the core app?

This line causes a crash: AdWordsUser user = new AdWordsUser();

I'm using google ads to generate keywords ,

I'm not sure if i did follow the right instructions.

I created at first a manager account https://developers.google.com/adwords/api/docs/guides/accounts-overview#test_accounts then i apply for test account ( but in my status test account is close) even manager :( and i don't know why.

Teams from google ads said that in their system they are open ...however

When i test my app with developer token and outh2 : i got this message

ApiException was thrown with message '{     "message": "The caller does not have permission",     "code": 7,     "status": "PERMISSION_DENIED",     "details": [         {             "@type": 0,             "data": "type.googleapis.com\/google.ads.googleads.v3.errors.GoogleAdsFailure"         },         {             "@type": 0,             "data": [                 {                     "errorCode": {                         "authorizationError": "CUSTOMER_NOT_ENABLED"                     },                     "message": "The customer can't be used because it isn't enabled."                 }             ]         }     ] }' 

Do you have experience with google ads api ?