What are the exact steps to add AdMob to my app?

edited December 2017 in Android Mode

Hello all!

I am new to coding, been only doing it daily for a month or two, and I just finished my first game for android. I would like to add it to the Google Play Store with AdMob. I have registered for AdMob, and now I need to incorporate the ads to my code, however, I have no idea how to do that.

I already saw https://forum.processing.org/two/discussion/16686/how-to-add-admob and I read through all of it twice, but am still completely at a loss. The topic is really messy and riddled with trials and errors, and has code and symbols that I have never used nor understood at all, making its contents practically unreadable for someone with as little coding experience as me. What is a manifest? What's a .jar file, why do I need it and where do I get it?

I put so much effort into my game and I am so eager to see it in the store, but I just can't get past this final step.

If some kind soul could give me and, likely, the thousands of other newcomers looking for an answer, a step-by-step walkthrough of exactly what I need to download, where I need to download it, and provide an organized snippet of code that I can adapt for my program, words can't describe how grateful I would be.

Thank you all in advance!


  • edited October 2017


    This is the default AdMob guide that I have gone through but also don't understand as it's made for Android Developer Studio.

  • "The topic is really messy and riddled with trials and errors, and has code and symbols that I have never used nor understood at all, making its contents practically unreadable for someone with as little coding experience as me."

    Welcome to programming.

  • edited October 2017 Answer ✓


    • first step: get your Ad unit id from your admob account; it should be something like ca-app-pub-(+ a lot of numbers); if only for testing use the ad unit id given by Google: ca-app-pub-3940256099942544~3347511713; then choose a format among the 3 provided: as for now choose "banner" which is the more simple.

    • second step: use the code i have already given and that i give again:

                  import android.os.Looper;//for setup() if needed
                  import android.os.Bundle;
                  import android.view.Window;
                  import android.widget.RelativeLayout;
                  import android.app.Activity;
                //  import com.google.ads.*;//
                  import com.google.android.gms.ads.AdRequest;
                  import com.google.android.gms.ads.AdView;
                  import com.google.android.gms.ads.AdSize;
                  import com.google.android.gms.ads.MobileAds;
                  public void setup(){
                    size(800, 1000);
                  public void draw(){
                  @ Override
                  public void onCreate(Bundle savedInstanceState) {
                  //here you get the window
                  Window window = getActivity().getWindow();
                  //here you add a layout to your window; working with AS or Eclipse you can skip that because you can modify the xml; with processing you have to do that by code
                   RelativeLayout adsLayout = new RelativeLayout(this.getActivity());
                  //here you set the params for your layout
                   RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
                      RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);
                  // now you create your View
                  AdView adView = new AdView(this.getActivity());
                  // here you add the view to the layout and build your AdRequest
                      AdRequest newAdReq = new AdRequest.Builder()
            // .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)//
             //  .addTestDevice("xxxxxxxxxxxxxxxxx")// this is the id  from your phone for testing; you can get it using TelephonyManager
                  ///and finally ad the whole stuff to your window
    • step 3: modify your Manifest a) adding permissions:::

                   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
                    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
                    <uses-permission android:name="android.permission.INTERNET"/>
                    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
                    <uses-permission android:name="android.permission.SET_ORIENTATION"/>
                                            b) adding metadata for your com.google.android.gms.version: this is the number corresponding to the version you want the client-user have : of course if it is not installed or if it s too old your app will not run; here you can write with some lines a method for checking the client phone and open a dialog asking for updating or installing;

    all these details are explained in the link you posted in this forum and you can find an example i have given for the Manifest;

    • step 4: verify that googlePlayServices is installed in your SDK (SDK menu, Extras)

    • step 5: try and see wether the imports can be solved; if not (that was the case in the discussion you have seen) get the .jar from the url i have given in the same discussion, create a folder "code" in your sketch and add the .jar. When you download it it is a .zip and its name contains the version number you have to write in your Manifest.

  • @akenaton THANK YOU!

    Where in my code should I place the manifest?

  • @randomdude===

    you have only to edit the Manifest; nothing to do (in this case) by code.

  • Ooh I see.

    And does it matter where in the manifest I add these permissions (start, middle, end)?

  • edited October 2017

    No need to modify the manifest directly. Instead, if you are using Processing, go to the Android in the menu bar and click on sketch permissions. There you can check the permission you want to enable. This action will update your manifest for you.

    ***Edit: Here I am only referring to permissions btw.


  • @kfrajer===

    you are right for permissions, but in this case it s necessary to edit the manifest in order to add (metadata) the com.google.android.gms.version required.

  • I can't compose the metadata on my own. Is it too much to ask to give a bit more detailed explanation on how to add metadata?

  • edited October 2017


    yes that is possible:: see the link you posted here and see my manifest example... and be conscious that you ask for things rather complicated && know nothing about android

  • @akenaton

    I don't just know nothing about Android - I basically know nothing about coding altogether.

    I started merely a month ago. But I am a quick learner and have gotten pretty far already, relying (and owing) only to experienced programmers like you who are willing to help.

    I don't know what I can do to show my gratitude for your help. It is in my nature to want to know more, so I will probably keep asking rather complicated things. If you think I know too little to achieve the things I want to achieve, you don't have to bother to answer. However, so far I have been able to grasp everything I ask about if somebody provides a good description.

    AdMob is clear to me now and has been successfully implemented in my code.


  • @randomdude===

    be happy when coding! but think= learning is for each day!

  • @randomdude===

    && never think that you "KNOW"

  • @akenaton

    I am having tremendous fun while coding, that is why I am so eager to get better -- FASTER. I have so many ideas that I want to see come to life!! I just need the experience and knowledge. And I can acquire experience and knowledge much more efficiently by relying on others sharing theirs with me.

    "If I have seen further it is by standing on the shoulders of giants." -Isaac Newton

  • @akenaton ===

    For some reason after reinstalling processing it stopped recognizing the com.google imports no matter what I do. This is my manifest:

    <?xml version="1.0" encoding="UTF-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package=""> <uses-sdk android:minSdkVersion="17" android:targetSdkVersion="26"/> <application android:icon="@drawable/icon" android:label=""> <activity android:name=".MainActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:configChanges="keyboard|keyboardHidden|orientation" android:name="com.google.ads.AdActivity"/> <meta-data android:name="com.google.android.gms.version" android:value="ca-app-pub-3940256099942544/6300978111"/> </application> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.SET_ORIENTATION"/> </manifest>

    I got the ca-app-pub for testing from the admob site.

    Maybe it's a problem with the .jar file. The .zip that you have sent a link to in the other topic has a LOT of files in it -- which one exactly do I need to put in my code folder? I'm confused

  • edited December 2017


    error in your manifest for metadata: as value you are puting your unitId and not your gms.version...

  • edited December 2017



    Strange, it's not the same gms.version that I had before I reinstalled Processing...

    This new SDK is really confusing. I tried to find the gms version and all I found was this manifest inside the gms folder:

    I'm not sure which one is the actual version that I should be using (not familiar with xml). Do you have any idea?

  • edited December 2017


    try to put "@integer/google_play_services_version" instead of any number

    • normally (i am not sure if it is still ok) the exact integer value is here= google-play-services_lib>res>values>version.xml and you can use this; yet, harcoding is bad as this value can change in the future.

    • looking to your xml i think that the actual value (last updated) is : "20170........."; try this value.

  • edited December 2017


    I tried both the number after lastUpdated and @integer/google_play_services (found the second on stackOverflow) and none of them work.

    The weird thing is that the imports dont give an error, but their functions do. I'm not sure if it's a processing bug. Here is a sample with your code.

    However when I start the sketch I do get this in console:

    No library found for com.google.android.gms.ads No library found for com.google.android.gms.ads No library found for com.google.android.gms.ads No library found for com.google.android.gms.ads

    Followed by a long error.

    Maybe it won't work with this SDK. Can you recommend me an SDK? What SDK are you using?

  • Can anyone recommend an SDK that has a clear gms version and works with AdMob?

  • @randomdude===

    are you sure that googlePLayservices is installed in your SDK (folder "extras")???

  • @akenaton

    There is a folder named 'google' in my SDK's extras folder. There are multiple folders inside folders but among all the folders inside the 'google' folder there is one named 'gms' and inside there are many folders called 'play-services', 'play-services-ads', 'play-services-all-wear', etc, so presume google play services is installed.

    Can you recommend me a new SDK please?

  • @randomdude=== installed: verify with the sdk manager

  • @akenaton ===

    That's the problem, I can't seem to find an sdk manager in this sdk.....

    That is why I have to do everything manually.

  • @randomdude===

    I dont think that you have a "special" SDK; so go to "tools" and launch "android": that launches the SDK manager.

  • edited December 2017


    I tried that long ago - it closes immediately after it launches. It simply will not open.

    I think that the best idea is to reinstall everything again and try a new SDK...

  • @randomdude===

    anyway dont install your new SDK with P5: download it and install it manually...

  • edited December 2017


    I tried downloading from here https://developer.android.com/studio/index.html#downloads Tried getting the SDK under 'Get Just the Command Line Tools' and its manager also did not open. I found this post on StackOverflow: https://stackoverflow.com/questions/14504325/cant-get-android-sdk-manager-to-open And I did find 'find_java.bat' and edited it as the post said but it still does not help, SDK manager will not open.............. It feels like every step forward takes me 2 steps backwards :(

  • @randomdude===

    When you edit the .bat is the path to java the good one? When you try to run android from the command line is there some error message?

  • @akenaton===

    I thought it’s the good one but apparently I don’t have a java.exe in my pc... I’m sorry for my inexperience.

    What should I do? What executable exactly should I make a path to?

  • edited December 2017


    take the path in your.bat

    verify that you find, following the path, a folder with jdk1.8 as name; if not of course the manager cannot run

  • A folder with the name 'jdk1.8' or anything with 'jdk' does not exist in my computer.

    This is how the .bat looked before any editing (no path), if it helps:

    @echo off
    rem Copyright (C) 2007 The Android Open Source Project
    rem Licensed under the Apache License, Version 2.0 (the "License");
    rem you may not use this file except in compliance with the License.
    rem You may obtain a copy of the License at
    rem      http://www.apache.org/licenses/LICENSE-2.0
    rem Unless required by applicable law or agreed to in writing, software
    rem distributed under the License is distributed on an "AS IS" BASIS,
    rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    rem See the License for the specific language governing permissions and
    rem limitations under the License.
    rem This script is called by the other batch files to find a suitable Java.exe
    rem to use. The script changes the "java_exe" env variable. The variable
    rem is left unset if Java.exe was not found.
    rem Useful links:
    rem Command-line reference:
    rem   http://technet.microsoft.com/en-us/library/bb490890.aspx
    rem Query whether this system is 32-bit or 64-bit
    rem Note: Some users report that reg.exe is missing on their machine, so we
    rem check for that first, as we'd like to use it if we can.
    set sys_32=%SYSTEMROOT%\system32
    if exist %sys_32%\reg.exe (
        rem This first-pass solution returns the correct architecture even if you
        rem call this .bat file from a 32-bit process.
        rem See also: http://stackoverflow.com/a/24590583/1299302
        %sys_32%\reg query "HKLM\Hardware\Description\System\CentralProcessor\0"^
        | %sys_32%\find /i "x86" > NUL && set arch_ext=32|| set arch_ext=64
    ) else (
        rem This fallback approach is simpler, but may misreport your architecture as
        rem 32-bit if running from a 32-bit process. Still, it should serve to help
        rem our users without reg.exe, at least.
        if "%PROCESSOR_ARCHITECTURE%" == "x86" (set arch_ext=32) else (set arch_ext=64)
    rem Check we have a valid Java.exe in the path. The return code will
    rem be 0 if the command worked or 1 if the exec failed (program not found).
    for /f "delims=" %%a in ('"%~dps0\find_java%arch_ext%.exe" -s') do set java_exe=%%a
    if not defined java_exe goto :CheckFailed
    rem Check if we can find a javaw.exe at the same location than java.exe.
    rem If that doesn't work, just fall back on the java.exe we just found.
    for /f "delims=" %%a in ('"%~dps0\find_java%arch_ext%.exe" -s -w') do set javaw_exe=%%a
    if not exist "%javaw_exe%" set javaw_exe=%java_exe%
    goto :EOF
    echo ERROR: No suitable Java found. In order to properly use the Android Developer
    echo Tools, you need a suitable version of Java JDK installed on your system.
    echo We recommend that you install the JDK version of JavaSE, available here:
    echo   http://www.oracle.com/technetwork/java/javase/downloads
    echo If you already have Java installed, you can define the JAVA_HOME environment
    echo variable in Control Panel / System / Avanced System Settings to point to the
    echo JDK folder.
    echo You can find the complete Android SDK requirements here:
    echo   http://developer.android.com/sdk/requirements.html
    goto :EOF
  • edited December 2017


    then android manager cannot run:: download && instal the jdk for your OS (from oracle, line 59 in your .bat)

  • edited December 2017


    I downloaded and installed it. I tried opening android.bat both without editing my find_java and after editing find_java with the proper path - both times I get a 'This app can't run on your PC" message .....................

  • @akenaton===

    Reinstalled processing all over again, downloaded new SDK; android.bat again did not open - again no error, just getting a window appear for 0.1 seconds then it disappears and nothing happens like before.

    Edited find_java.bat with the proper path. Still same thing - window appears and disappears immediately.

  • I also tried this:

    Computer -> Advanced system settings -> Environment variables -> PATH -> edit: make sure they are in this order: C:\Program Files\Java**my JDK folder**\bin;%SystemRoot%\system32

    Did not change a thing.

  • I also tried EVERYTHING here:: https://stackoverflow.com/questions/5199811/android-sdk-manager-wont-open

    NOTHING worked. I don't even have 'set java_exe' in my android.bat!

    This is the android.bat:

    @echo off
    setlocal enableDelayedExpansion
    echo **************************************************************************
    echo The "android" command is deprecated.
    echo For manual SDK, AVD, and project management, please use Android Studio.
    echo For command-line tools, use tools\bin\sdkmanager.bat
    echo and tools\bin\avdmanager.bat
    echo **************************************************************************
    set DIRNAME=%~dp0
    if "%DIRNAME%" == "" set DIRNAME=.\
    if not defined wrapper_bin_dir (
      set wrapper_bin_dir=bin
    set avd_verbs=;list;create;move;delete;
    set avd_objects=;avd;target;device;
    call:checkMatch "%avd_verbs%" "%avd_objects%" %* || (
      call:invoke "%DIRNAME%%wrapper_bin_dir%\avdmanager" %* || exit /b 1
      exit /b 0
    set sdk_verbs=;list;update;
    set sdk_objects=;sdk;
    call:checkMatch "%sdk_verbs%" "%sdk_objects%" %* || (
      call:runSdkCommand %* || exit /b 1
      exit /b 0
    echo Invalid or unsupported command "%*"
    echo Supported commands are:
    echo android list target
    echo android list avd
    echo android list device
    echo android create avd
    echo android move avd
    echo android delete avd
    echo android list sdk
    echo android update sdk
    exit /b 1
      setlocal enableDelayedExpansion
      set trysdk=""
      if defined USE_SDK_WRAPPER (set trysdk="%USE_SDK_WRAPPER%")
      call:findSdkParam %* || (
        set trysdk=y
      if %trysdk%=="" (
        echo "android" SDK commands can be translated to sdkmanager commands on a best-effort basis.
        echo (This prompt can be suppressed with the --use-sdk-wrapper commend-line argument
        echo or by setting the USE_SDK_WRAPPER environment variable^)
        set /p trysdkresponse="Continue? [y/N]: "
        if /I "!trysdkresponse!"=="y" (
          set trysdk=y
      if %trysdk%=="" (
        echo Aborted
        exit /b 1
      if "!verb!"=="list" (
        call:invoke "%DIRNAME%%wrapper_bin_dir%\sdkmanager" --list --verbose || exit /b 1
        exit /b 0
      if "!verb!"=="update" (
        set args=
        set prev=
        set update_all=1
        call:sdkUpdate %* || exit /b 1
        exit /b 0
      setlocal enableDelayedExpansion
      set paramsWithArgument=;-p;--obsolete;-u;--no-ui;--proxy-host;--proxy-port;-t;--filter;
      set verb="%~1"
      set object="%~2"
      set args=
      set prev=""
      shift & shift
        if "%~1"=="" (goto:sdkupdatedone)
        set arg="%~1"
        set unquotedarg=%~1
        if !arg!=="--use-sdk-wrapper" (
        ) else if !arg!=="!verb!" (
        ) else if !arg!=="!object!" (
        ) else if !arg!=="-n" (
          echo "update sdk -n is not supported"
          exit /b 1
        ) else if !arg!=="-s" (
          set args=!args! --no_https
        ) else if !arg!=="--no-https" (
          set args=!args! --no_https
        ) else if !arg!=="-a" (
          set args=!args! --include_obsolete
        ) else if !arg!=="--all" (
          set args=!args! --include_obsolete
        ) else if "!paramsWithArgument:;%unquotedarg%;=!" neq "!paramsWithArgument!" (
          rem nothing
        ) else if "!arg:~1,1!"=="-" (
          echo Unrecognized argument !arg!
          exit /b 1
        ) else if !prev!=="--proxy-host" (
          set args=!args! --proxy=http --proxy_host=!unquotedarg!
        ) else if !prev!=="--proxy-port" (
          set args=!args! --proxy_port=!unquotedarg!
        ) else if !prev!=="-t" (
          set has_filter=y
          call:parseFilter !arg! || exit /b 1
          rem unquoted comma-separated lists are treated as separate args, so if
          rem the next arg isn't recognized as a flag, treat it as a filter element
        ) else if !prev!=="--filter" (
          set has_filter=y
          call:parseFilter !arg! || exit /b 1
          rem unquoted comma-separated lists are treated as separate args, so if
          rem the next arg isn't recognized as a flag, treat it as a filter element
        ) else (
          echo Unrecognized argument !arg!
          exit /b 1
        set prev=!arg!
      if not defined has_filter (
        set args=%args% --update
      call:invoke "%DIRNAME%%wrapper_bin_dir%\sdkmanager" %args% || exit /b 1
      exit /b 0
      for %%i in (%~1) do (
        set filter=%%i
        if "!filter!"=="tool" (
          set args=!args! tools
        ) else if "!filter!"=="tools" (
          set args=!args! tools
        ) else if "!filter!"=="platform-tool" (
          set args=!args! platform-tools
        ) else if "!filter!"=="platform-tools" (
          set args=!args! platform-tools
        ) else if "!filter!"=="doc" (
          set args=!args! docs
        ) else if "!filter:~0,4!"=="lldb" (
          set args=!args! !filter:-=;!
        ) else if "!filter:~0,11!"=="build-tools" (
          set args=!args! !filter:build-tools-=build-tools;!
        ) else if "!filter!"=="ndk" (
          set args=!args! ndk-bundle
        ) else if "!filter:~0,8!"=="android-" (
          set args=!args! platforms;!filter!
        ) else if "!filter:~0,6!"=="extra-" (
          set tmp=!filter:extra-=extras-!
          set args=!args! !tmp:-=;!
        ) else (
          echo Filter !filter! is not supported
          exit /b 1
      exit /b 0
        if "%~1"=="" ( exit /b 0 )
        set arg=%~1
        if "%arg%"=="--use-sdk-wrapper" (
          exit /b 1
      set verbs=%~1
      set objects=%~2
      set verb=""
      set object=""
      shift & shift
        if "%~1"=="" ( goto:done )
        set arg=%~1
        if "%arg:~0,1%"=="-" ( goto:loop )
        if !verb!=="" if "!verbs:;%arg%;=!" neq "!verbs!" (
          set verb=!arg!
        if !verb! neq "" if "!objects:;%arg%;=!" neq "!objects!" (
          set object=!arg!
      if !verb! neq "" if !object! neq "" exit /b 1
      exit /b 0
      echo Invoking %*
      call %* || exit /b 1
      exit /b 0
  • Also the oracle link installed jdk-9.0.1 not jdk1.8 or jdk1.7 ....

  • @randomdude===

    are you sure that it can run with your OS??? - Have you downloaded the good version for your OS (64 or X356????)

  • edited December 2017


    Yes, 10000% sure. I have Windows 10 64bit, downloaded the 64bit version for windows. This is the error that I get when I try to open android.bat from powershell (I get this when I use ".\android", otherwise if I type "start android" I get the same thing when I try to start it by clicking on it):

    PS C:\Users\User\Documents\Processing\android\sdk\tools> .\android
    The "android" command is deprecated.
    For manual SDK, AVD, and project management, please use Android Studio.
    For command-line tools, use tools\bin\sdkmanager.bat
    and tools\bin\avdmanager.bat
    Invalid or unsupported command ""
    Supported commands are:
    android list target
    android list avd
    android list device
    android create avd
    android move avd
    android delete avd
    android list sdk
    android update sdk
    PS C:\Users\User\Documents\Processing\android\sdk\tools>

    By the way, in case I don't say it enough, THANK YOU so much for trying to help me despite everything.

  • edited December 2017

    This error I get when I try to open 'sdkmanager' in the bin folder. If I open it normally the error flashes for a moment and the screen closes but opening it with powershell allowed me to see the error for longer:

    PS C:\Users\User\Documents\Processing\android\sdk\tools\bin> .\sdkmanager
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
            at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
            at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
            at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
            at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
            at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
    Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
            at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
            at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
            at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
            ... 5 more
    PS C:\Users\User\Documents\Processing\android\sdk\tools\bin>
  • According to this https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j maybe the problem is with my JDK version. I will try to find an older JDK and try with it, then I will report my result...

  • edited December 2017


    I opened tools/bin with powershell and used '.\sdkmanager --list' and I can confirm that I did NOT have Google Play Services installed. I then installed it using powershell and now I have these packages installed:

    Installed packages:=====================] 100% Computing updates...
      Path                               | Version | Description                        | Location
      -------                            | ------- | -------                            | -------
      build-tools;26.0.3                 | 26.0.3  | Android SDK Build-Tools 26.0.3     | build-tools\26.0.3\
      extras;android;m2repository        | 47.0.0  | Android Support Repository, rev 47 | extras\android\m2repository\
      extras;google;google_play_services | 46      | Google Play services               | extras\google\google_play_services\
      extras;google;m2repository         | 58.0.0  | Google Repository, rev 58          | extras\google\m2repository\
      extras;google;usb_driver           | 11.0.0  | google usb_driver, rev 11          | extras\google\usb_driver\
      patcher;v4                         | 1       | SDK Patch Applier v4               | patcher\v4\
      platform-tools                     | 27.0.0  | Android SDK Platform-Tools 27      | platform-tools\
      platforms;android-26               | 2       | Android SDK Platform 26, rev 2     | platforms\android-26\
      tools                              | 26.1.1  | Android SDK Tools 26.1.1           | tools\

    However AdMob STILL DOES NOT WORK.

    I tried a few different gms versions in the manifest with no success. The imports are still not recognized. Do I need to install another package?

  • The problem could be because my sketch is missing a .jar file... however I am using rev30 and it has no libproject folder and I am puzzled as to what to do (I prefer not to use old rev), because that same problem was in the post that I linked at the beginning of this post and it was not solved there ....

  • After doing this processing finally recognizes the imports:

    These were the steps: 1. Download and unzip this: https://dl-ssl.google.com/android/repository/google_play_services_8298000_r28.zip

    1. Open Google Play Services and copy 'libproject' folder

    2. Go to your sdk folder and follow this path: android\sdk\extras\google\google_play_services

    3. Paste libproject there

    4. Go to libproject\google-play-services_lib\libs

    5. Copy google-play-services.jar --- this is the jar that the sketch will use

    6. Paste jar in CODE folder in sketch. That's it!

    However I now when I try to run the code I get this error:

    FAILURE: Build failed with an exception.

    • What went wrong: Execution failed for task ':app:transformClassesWithDexForDebug'.

      com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

    • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    I also tried getting using r28 (not just copying libproject but replacing the whole google_play_services folder) and I still get this error.

  • edited December 2017

    I presume this bug was because I am using the full library, so I opened the .jar file and deleted most of the libraries that I don't use and now I get this:

    Process: processing.test.admob_test, PID: 15035
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzev;
  • edited December 2017


    So I also had to do that:

    Open the .jar file that you have put in your CODE folder inside your sketch; Go to com >> google >> android >> gms and delete Wallet and Wearable (maybe you could delete more for faster compiling but I haven't experimented)

    Now edit your manifest and make sure to add the following: Instead of:

    android:configChanges="keyboard|keyboardHidden|orientation" android:name="com.google.ads.AdActivity"/>

    Add this instead:

    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:name="com.google.android.gms.ads.AdActivity"/>

    That's it! Now it works!!

Sign In or Register to comment.