我已在清单文件中以适当的方式设置了所有必需的权限,但我没有做错什么。
我得到的错误:
1-“ InterstitialAd.loadAd所需的缺少权限: android.permission.INTERNET“
2-“缺少所需的权限 MobileAds.initialize:android.permission.INTERNET“ 3-”缺失 BaseAdView.loadAd所需的权限: android.permission.INTERNET”
我很沮丧 关于这个错误,我不知道该如何解决。我遵循了所有解决方案,例如无效的缓存重新启动,清理重建,设置权限等。但是它根本没有用,请有人帮帮我。
MainActivity.java:
public class AnswerPaper extends Activity {
private View.OnClickListener buttonClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.but5:
Intent mIntent1 = new Intent(AnswerPaper.this, bscitactivity.class);
mIntent1.putExtra("file_name", "answers");
startActivity(mIntent1);
break;
case R.id.but6:
Intent mIntent2 = new Intent(AnswerPaper.this, bscactivity.class);
mIntent2.putExtra("file_name", "answers");
startActivity(mIntent2);
break;
case R.id.but7:
Intent mIntent3 = new Intent(AnswerPaper.this, bscbiotech.class);
mIntent3.putExtra("file_name", "answers");
startActivity(mIntent3);
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.questionspapers);
defineButtons();
Button b = (Button) findViewById(R.id.but6);
Button b2 = (Button) findViewById(R.id.but7);
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(AnswerPaper.this,pop.class));
}
});
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(AnswerPaper.this,pop.class));
}
});
}
public void defineButtons() {
findViewById(R.id.but5).setOnClickListener(buttonClickListener);
findViewById(R.id.but6).setOnClickListener(buttonClickListener);
findViewById(R.id.but7).setOnClickListener(buttonClickListener);
MobileAds.initialize(this,"ca-app-pub-2775391703689141/2346081028");
AdView adView = (AdView)findViewById(R.id.banner_AdView);
AdRequest adRequest = new AdRequest.Builder()
.build();
adView.loadAd(adRequest);
}
}
答案 0 :(得分:0)
要连接到互联网,您必须添加:
<uses-permission android:name="android.permission.INTERNET" />
直接到AndroidManifest.xml
元素内的<manifest >
。