[英]Builder() says cannot resolve symbol on Gradle
I am trying to add an ad to my application and I get the error when I write this code : 我试图在我的应用程序中添加广告,并且在编写此代码时收到错误消息:
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.ads.AdRequest;
import com.google.android.gms.ads.AdView;
public class isPrime extends Activity {
Button mButton = null;
TextView resultText = null;
EditText mInput = null;
RelativeLayout myLayout = null;
long input ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Look up the AdView as a resource and load a request.
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest;
adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
ie the error I get is 即我得到的错误是
Builder cannot be resolved into a Symbol
I have read through all the documentation(well at least I think I have.) I am totally new to this field. 我已经阅读了所有文档(至少我想我已经读过。)我对这个领域是全新的。 I would appreciate any help.
我将不胜感激任何帮助。
Also my XML code is : 我的XML代码也是:
<com.google.android.gms.ads.AdView android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="blahblah"/>
You are using the wrong import for AdRequest
looks like it is looking at the old admob implementation. 您对
AdRequest
使用的导入错误,就像在查看旧的admob实现一样。 Use -- 采用 -
import com.google.android.gms.ads.AdRequest;
instead of 代替
import com.google.ads.AdRequest;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.