android - AdRequest Builder cannot be resolved to a type -
i finished developing game android using modified version of framework @ http://www.kilobolt.com/unit-4-android-game-development.html. followed tutorial:https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start , added ad not on main activity framework not have .xml file main activity (surface view in pure java code). however, want ads appear on main activity since contains 95% of game. managed add test view (button) on surfaceview using online tutorial when changed button adview got error:
"adrequest.builder cannot resolved type" in
adrequest adrequest = new adrequest.builder().build();
.
can tell me cause error? eclipse accepted exact same code in other activity on same project not here. have made necessary imports.
import com.google.ads.adrequest; import com.google.android.gms.ads.adview;
.
@override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); appcontext = this.getapplicationcontext(); mainlayout = new framelayout(this); adlayout = new relativelayout(this); adview = new adview(this); adview.setadunitid("ca-app-pub-3940256099942544/6300978111"); // google test id //adrequest adrequest = new adrequest.builder().build(); adview.setadsize(adsize.banner); relativelayout.layoutparams lp1 = new layoutparams(relativelayout.layoutparams.wrap_content, relativelayout.layoutparams.wrap_content); relativelayout.layoutparams lp2 = new layoutparams(relativelayout.layoutparams.match_parent, relativelayout.layoutparams.match_parent); adlayout.setlayoutparams(lp2); adlayout.addview(adview); lp1.addrule(relativelayout.align_parent_right, relativelayout.true); lp1.addrule(relativelayout.align_parent_bottom, relativelayout.true); adview.setlayoutparams(lp1); requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); getwindow().addflags(windowmanager.layoutparams.flag_keep_screen_on); boolean isportrait = getresources().getconfiguration().orientation == configuration.orientation_portrait; int framebufferwidth = isportrait ? 800 : 1280; int framebufferheight = isportrait ? 1280 : 800; bitmap framebuffer = bitmap.createbitmap(framebufferwidth, framebufferheight, config.rgb_565); displaymetrics metrics = new displaymetrics(); getwindowmanager().getdefaultdisplay().getmetrics(metrics); float scalex = (float) framebufferwidth / metrics.widthpixels; float scaley = (float) framebufferheight / metrics.heightpixels; gamescreen.devicewidth = metrics.widthpixels; gamescreen.deviceheight = metrics.heightpixels; prefs = this.getsharedpreferences("appprefs", context.mode_private); prefsexist = prefs.contains("showvalueaddition"); loaddefaultsettings(); renderview = new androidfastrenderview(this, framebuffer); graphics = new androidgraphics(getassets(), framebuffer); fileio = new androidfileio(this); audio = new androidaudio(this); input = new androidinput(this, renderview, scalex, scaley); screen = getinitscreen(prefs); mainlayout.addview(renderview); mainlayout.addview(adlayout); setcontentview(mainlayout); }
any appreciated.
use import com.google.android.gms.ads.adrequest;
Comments
Post a Comment