Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8109017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:17:23+00:00 2026-06-06T01:17:23+00:00

I have been trying for the past two days now to implement Admob ads

  • 0

I have been trying for the past two days now to implement Admob ads into an app which is being developed for Android 2.2 and above. I have searched online and tried all of the answers I have found, but still, nothing. I followed all the instructions on the admob site, and have tried both the java (posted below) and the xml version. Everytime I use xml, I get the error “failed to instantiate com.google.ads.AdView”. I have tried the fixes for that but it still crashes. So far I have changed the “minSdkVersion” to 8 (for developing on 2.2), and the “target” to android=14, which is needed for the AdMob sdk. Any help would be much appreciated!

Menu class

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

public class Menu extends Activity{

Button start, HTP;
private AdView adView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    start = (Button) findViewById(R.id.bStart);
    HTP = (Button) findViewById(R.id.bHTP);


    start.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent myIntent = new Intent(Menu.this,
                    MyGameActivity.class);
            Menu.this.startActivity(myIntent);
            }
        });

    HTP.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent myIntent = new Intent(Menu.this,
                    HowToPlay.class);
            Menu.this.startActivity(myIntent);
        }
    });


    // Create the adView
    adView = new AdView(this, AdSize.BANNER, "publisher id in quotes");

    // Lookup your LinearLayout assuming it’s been given
    // the attribute android:id="@+id/mainLayout"
    LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);

    // Add the adView to it
    layout.addView(adView);

    // Initiate a generic request to load it with an ad
    adView.loadAd(new AdRequest());
  }

  @Override
  public void onDestroy() {
    if (adView != null) {
      adView.destroy();
    }
    super.onDestroy();
  }

}

Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tacomaapps.game"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" /> 

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
    android:icon="@drawable/ic_game"
    android:label="Cube Jump" >
    <activity
        android:name=".Splash"
        android:label="Cube Jump"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>


    <activity
        android:name=".Menu"
        android:label="Cube Jump"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="com.tacomaapps.MENU" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

    <activity
        android:name=".MyGameActivity"
        android:label="Cube Jump"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        android:screenOrientation="landscape" >
    </activity>

    <activity
        android:name=".HowToPlay"
        android:label="Cube Jump"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        android:screenOrientation="landscape" >
    </activity>
    <activity android:name="com.google.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>        
</application>

Main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:id="@+id/mainLayout"
android:layout_height="match_parent"
android:background="@drawable/menuback"
android:baselineAligned="true"
android:orientation="horizontal" >


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="210dp"
    android:layout_weight="1.0"
    android:weightSum="100" >

    <Button
        android:id="@+id/bFillSpace"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="45"
        android:visibility="invisible"
        android:text="Button" />

    <Button
        android:id="@+id/bStart"
        android:layout_width="150dp"
        android:layout_height="63dp"
        android:layout_margin="5dp"
        android:layout_weight="5"
        android:background="@drawable/play" />

    <Button
        android:id="@+id/bHTP"
        android:layout_width="150dp"
        android:layout_height="63dp"
        android:layout_margin="5dp"
        android:layout_weight="5"
        android:background="@drawable/htp_button" />

    <Button
        android:id="@+id/bFillSpace2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="45"
        android:visibility="invisible"
        android:text="Button" />
</LinearLayout>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:17:25+00:00Added an answer on June 6, 2026 at 1:17 am

    Your code is perfectly fine and runs at my end.

    I would like you to Verify following thing.

    1 You have created “libs” folder in project and added GoogleAdMobAdsSdk-X.X.X.jar there and reference it from there.By default, they doesn’t exist.If you are directly referencing jar file from \extras\google\admob_ads_sdk then program crashes with java.lang.NoClassDefFoundError: com.google.ads.AdView Strange but true.

    You project structure should look something like this

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying these for past two days and getting stuck at same
For the past few days I have been trying to play any sound over
I have been searching for the past through days, trying to figure out how
For the past couple of days, I have been trying to get GWT to
For the past few days, I have been trying to figure out how to
I have been playing around with tableviews for the past few days trying to
I have been trying to understand this algorithm for past two hours, but can't
Over the past few days I have been trying to create/run a project in
I have been trying to wrap my head around this issue for the past
I have been trying to print my lang and long coordinates for the past

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.