#java #android #android_studio #java_ee
LogcatEvent LogДобавляя тестовый ad unit ID(с офиц. сайта AdMob for Androids)(ca-app-pub-3940256099942544/6300978111),
всё работает отлично, и тип эта реклама поздравляет меня, что я смог её разместить.
Но стоит мне поставить мой ad unit ID(моего приложения), ничего не появляется...
Вот собственно файлы и их коды:
activity_main.xml:
MainActivity.java:
package app.notruetester.ru.tets;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.TextView;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import java.util.Random;
public class MainActivity extends AppCompatActivity{
private AdView mAdView;
TextView textView,textView2;
Button button;
EditText editText;
CheckBox checkBox,checkBox2,checkBox3,checkBox4,checkBox5,checkBox6;
AdView adView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView) findViewById(R.id.textView);
textView2 = (TextView) findViewById(R.id.textView2);
button = (Button) findViewById(R.id.button);
editText = (EditText) findViewById(R.id.editText);
textView.setTextSize(20);
editText.setText("2");
checkBox = (CheckBox) findViewById(R.id.checkBox);
checkBox2 = (CheckBox) findViewById(R.id.checkBox2);
checkBox3 = (CheckBox) findViewById(R.id.checkBox3);
checkBox4 = (CheckBox) findViewById(R.id.checkBox4);
checkBox5 = (CheckBox) findViewById(R.id.checkBox5);
checkBox6 = (CheckBox) findViewById(R.id.checkBox6);
// AdView adView = AdView(this);
// adView.setAdSize(AdSize.BANNER);
// adView.setVisibility(View.VISIBLE);
MobileAds.initialize(this, "XXXX");
mAdView = (AdView) findViewById(R.id.ad_view);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
public void onButtonClick(View view){
if (!checkBox.isChecked() & !checkBox2.isChecked() & !checkBox3.isChecked() &
!checkBox4.isChecked() & !checkBox5.isChecked() & !checkBox6.isChecked() ){
checkBox3.setChecked(true);
checkBox4.setChecked(true);
}
String pass = "";
Random r = new Random();
int a= (editText.getText() == null)?0:Integer.parseInt(editText.getText().toString());
int cntchars = a + r.nextInt(1);
String values = "";
if (checkBox.isChecked()){
values += "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";}
if (checkBox2.isChecked()){
values += "!@#$%^&*()";}
if (checkBox3.isChecked()){
values += "0123456789";}
if (checkBox4.isChecked()){
values += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";}
if (checkBox5.isChecked()){
values += "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";}
if (checkBox6.isChecked()){
values += "abcdefghijklmnopqrstuvwxyz";}
int length = values.length();
for (int i = 0; i < a; ++i) {
Random rnd = new Random(System.currentTimeMillis());
int number = 0 + rnd.nextInt(length - 0 + 1);
pass += (char)((r.nextInt(values.length())) + values.charAt(number));
}
textView2.setText(pass);
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("")
.setMessage("Сгенерированный пароль скопирован в буфер обмена")
.setCancelable(false)
.setNegativeButton("ОК, понял, спасибо",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
AndroidManifest:
Стате, если кто-то не понял и кому-то интересно, что за проект я пишу, то это генератор
паролей(просто так, вдруг это как-то поможет)
P.S. У рекламного баннера свойство visibility стоит как visible
Собственно сам вопрос:
Как заставить AdMob работать нормально?
Прошу помочь, буду очень благодарен, бьюсь уже второй день с этой проблей((
Больше LogCat'а:
08-31 13:00:40.311 2659-9883/app.notruetester.ru.tets D/dalvikvm: GC_FOR_ALLOC freed
53K, 17% free 4793K/5752K, paused 3ms, total 3ms
08-31 13:00:40.315 2659-9883/app.notruetester.ru.tets W/GooglePlayServicesUtil: Google
Play services is missing.
08-31 13:00:40.315 2659-2659/app.notruetester.ru.tets W/Ads: The webview is destroyed.
Ignoring action.
08-31 13:00:40.375 2659-2659/app.notruetester.ru.tets I/Ads: Scheduling ad refresh
60000 milliseconds from now.
08-31 13:00:40.375 2659-4529/app.notruetester.ru.tets W/GooglePlayServicesUtil: Google
Play Store is missing.
08-31 13:00:40.379 2659-2659/app.notruetester.ru.tets I/Ads: Ad finished loading.
08-31 13:00:40.379 2659-2659/app.notruetester.ru.tets D/webviewglue: nativeDestroy
view: 0xb831b7f8
08-31 13:00:40.395 2659-2761/app.notruetester.ru.tets W/PicturePileLayerContent:
Warning: painting PicturePile without content!
08-31 13:00:40.395 2659-2761/app.notruetester.ru.tets W/PicturePileLayerContent:
Warning: painting PicturePile without content!
08-31 13:00:41.703 2659-2761/app.notruetester.ru.tets W/PicturePileLayerContent:
Warning: painting PicturePile without content!
08-31 13:00:41.979 460-523/system_process D/MobileDataStateTracker: default: setPolicyDataEnable(enabled=true)
08-31 13:01:40.379 2659-2659/app.notruetester.ru.tets I/Ads: Starting ad request.
08-31 13:01:40.379 2659-2659/app.notruetester.ru.tets I/Ads: This request is sent
from a test device.
08-31 13:01:40.383 2659-10781/app.notruetester.ru.tets W/GooglePlayServicesUtil:
Google Play Store is missing.
08-31 13:01:40.383 2659-10781/app.notruetester.ru.tets W/GooglePlayServicesUtil:
Google Play Store is missing.
08-31 13:01:40.455 2659-10786/app.notruetester.ru.tets D/dalvikvm: GC_FOR_ALLOC freed
822K, 18% free 4743K/5752K, paused 14ms, total 15ms
08-31 13:01:40.707 2659-10786/app.notruetester.ru.tets D/dalvikvm: GC_FOR_ALLOC freed
768K, 18% free 4737K/5752K, paused 7ms, total 7ms
08-31 13:01:40.711 2659-10786/app.notruetester.ru.tets D/dalvikvm: GC_FOR_ALLOC freed
36K, 17% free 4782K/5752K, paused 2ms, total 2ms
08-31 13:01:40.715 2659-10786/app.notruetester.ru.tets I/dalvikvm-heap: Grow heap
(frag case) to 4.879MB for 36886-byte allocation
08-31 13:01:40.715 2659-10786/app.notruetester.ru.tets D/dalvikvm: GC_FOR_ALLOC freed
24K, 18% free 4794K/5792K, paused 4ms, total 4ms
08-31 13:01:40.723 2659-10786/app.notruetester.ru.tets W/GooglePlayServicesUtil:
Google Play services is missing.
08-31 13:01:40.723 2659-2659/app.notruetester.ru.tets W/Ads: The webview is destroyed.
Ignoring action.
08-31 13:01:40.751 2659-2659/app.notruetester.ru.tets D/webviewglue: nativeDestroy
view: 0xb84970c8
08-31 13:01:40.763 2659-2659/app.notruetester.ru.tets I/Ads: Scheduling ad refresh
60000 milliseconds from now.
08-31 13:01:40.763 2659-3635/app.notruetester.ru.tets W/GooglePlayServicesUtil: Google
Play Store is missing.
08-31 13:01:40.771 2659-2659/app.notruetester.ru.tets I/Ads: Ad finished loading.
08-31 13:01:40.787 2659-2761/app.notruetester.ru.tets W/PicturePileLayerContent:
Warning: painting PicturePile without content!
08-31 13:01:40.787 2659-2761/app.notruetester.ru.tets W/PicturePileLayerContent:
Warning: painting PicturePile without content!
08-31 13:01:41.827 2659-2761/app.notruetester.ru.tets W/PicturePileLayerContent:
Warning: painting PicturePile without content!
08-31 13:01:41.999 460-523/system_process D/MobileDataStateTracker: default: setPolicyDataEnable(enabled=true)
Ответы
Ответ 1 Вы используете не то значение при инициализации AdMob. А именно - у вас в строке
MobileAds.initialize(this, "ca-app-pub-8900900048721624/5809873614");
используется, видимо, ID баннера, а не ID приложения. Это 2 разных значения. Проверьте
в настройках приложения в AdMob какое значение вам надо подставить при инициализации.
Также захардкоженные размеры баннера не ОК. Лучше поставить ширину во весь экран
и высоту по содержимому.
Ну и выкладывать в общий доступ эти ID - плохая идея. Кто-то может их заюзать, накликать
очень много с одного девайса и ваш акк заблокируют навсегда за накрутку и вы ничего
не сможете доказать.
Комментариев нет:
Отправить комментарий