Android build fails when the Admob lib is used together with the Location API

7 views
Skip to first unread message

Βασίλειος Τσουμάνης

unread,
Jul 28, 2020, 2:45:04 PM7/28/20
to CodenameOne Discussions
Hi when i try to android build an app with AdmobInterstitial cnlib integrated together with the Location API 
referenced in code then the build fails with the following reasons. I concluded this from a trial and error process 

and when i removed any reference from the Location API the android build was successful. Is there any advice? 


 Compiling with JDK Java compiler API.
/tmp/build2708158476482284487xxx/POIFinder/src/main/java/com/codename1/admob/AdMobNativeImpl.java:3: error: package com.google.android.gms.ads does not exist
import com.google.android.gms.ads.*;
^
/tmp/build2708158476482284487xxx/POIFinder/src/main/java/com/codename1/admob/AdMobNativeImpl.java:13: error: cannot find symbol
    private InterstitialAd interstitial;
            ^
  symbol:   class InterstitialAd
  location: class AdMobNativeImpl
/tmp/build2708158476482284487xxx/POIFinder/src/main/java/com/codename1/admob/AdMobNativeImpl.java:66: error: cannot find symbol
        interstitial = new InterstitialAd(activity);
                           ^
  symbol:   class InterstitialAd
  location: class AdMobNativeImpl
/tmp/build2708158476482284487xxx/POIFinder/src/main/java/com/codename1/admob/AdMobNativeImpl.java:68: error: cannot find symbol
        interstitial.setAdListener(new AdListener() {
                                       ^
  symbol:   class AdListener
  location: class AdMobNativeImpl
/tmp/build2708158476482284487xxx/POIFinder/src/main/java/com/codename1/admob/AdMobNativeImpl.java:106: error: cannot find symbol
            final AdRequest adRequest = new AdRequest.Builder().build();
                  ^
  symbol:   class AdRequest
  location: class AdMobNativeImpl
/tmp/build2708158476482284487xxx/POIFinder/src/main/java/com/codename1/admob/AdMobNativeImpl.java:106: error: package AdRequest does not exist
            final AdRequest adRequest = new AdRequest.Builder().build();
                                                     ^

Βασίλειος Τσουμάνης

unread,
Jul 28, 2020, 5:03:22 PM7/28/20
to CodenameOne Discussions
Hello again, 

just by replacing the following reference : 
Location l = LocationManager.getLocationManager().getLastKnownLocation();

with this : 
Location l = Display.getInstance().getLocationManager().getLastKnownLocation();

android build works just fine. 

Unfortunately i had to modify also some of my constructors in a class which they reference the Location API as 
an arg so as the build to succeed. 

Regards, 
Vasileios 
Reply all
Reply to author
Forward
0 new messages