• Najnowsze pytania
  • Bez odpowiedzi
  • Zadaj pytanie
  • Kategorie
  • Tagi
  • Zdobyte punkty
  • Ekipa ninja
  • IRC
  • FAQ
  • Regulamin
  • Książki warte uwagi

Nauka ustawiania reklam AdMob w aplikacji

Object Storage Arubacloud
0 głosów
208 wizyt
pytanie zadane 18 czerwca 2018 w Android, Swift, Symbian przez matir85 Bywalec (2,410 p.)

Witam.

Potrzebuję pomocy z dodaniem i ustawieniem reklam w aplikacji. Wszystko robię zgodnie z tym co jest napisane w instrukcji adMob i pomimo że z poziomu Android Studio wszystko wygląda ok to gdy próbuję uruchomić aplikację z reklamom na telefonie lub w emulatorze to wyrzuca błąd i aplikacja nie uruchamia się. Ponadto ostatnio pojawił się nowy problem aplikacja przestała się kompilować i informuje że jakiś path jest nie aktualny i nie wiem jak mam go zaktualizować.

Proszę o pomoc.

Okno Głowne

package pl.nynacode.naukareklam;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioButton;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;

public class OknoPierwsze extends AppCompatActivity {

    private AdView mAdView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_okno_pierwsze);

        MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");

        mAdView = findViewById (R.id.adView);
        AdRequest adRequest = new AdRequest.Builder (). build ();
        mAdView.loadAd (adRequest);
    }



    public void Opcja1(View view){
        Intent intent = new Intent(OknoPierwsze.this, Opcja1.class);
        startActivity(intent);
        RadioButton radioButton = (RadioButton) findViewById(R.id.rbOpcja1);
        radioButton.setChecked(false);
    }
    public void Opcja2(View view){
        Intent intent = new Intent(OknoPierwsze.this, Opcja2.class);
        startActivity(intent);
        RadioButton radioButton = (RadioButton) findViewById(R.id.rbOpcja2);
        radioButton.setChecked(false);
    }
    public void Opcja3(View view){
        Intent intent = new Intent(OknoPierwsze.this, Opcja3.class);
        startActivity(intent);
        RadioButton radioButton = (RadioButton) findViewById(R.id.rbOpcja3);
        radioButton.setChecked(false);
    }
    public void Opcja4(View view){
        Intent intent = new Intent(OknoPierwsze.this, Opcja4.class);
        startActivity(intent);
        RadioButton radioButton = (RadioButton) findViewById(R.id.rbOpcja4);
        radioButton.setChecked(false);
    }
}
<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".OknoPierwsze">

    <TextView
        android:id="@+id/tvTytul"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="30dp"
        android:layout_marginTop="30dp"
        android:text="Okno Pierwsze"
        android:textAlignment="center"
        android:textColor="@android:color/black"
        android:textSize="30sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ScrollView
        android:id="@+id/svTresc"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/tvTytul">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <RadioGroup
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:paddingTop="10dp">

                <RadioButton
                    android:id="@+id/rbOpcja1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:onClick="Opcja1"
                    android:paddingBottom="10dp"
                    android:paddingTop="10dp"
                    android:text="Opcja 1" />

                <RadioButton
                    android:id="@+id/rbOpcja2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:onClick="Opcja2"
                    android:paddingBottom="10dp"
                    android:paddingTop="10dp"
                    android:text="Opcja 2" />

                <RadioButton
                    android:id="@+id/rbOpcja3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:onClick="Opcja3"
                    android:paddingBottom="10dp"
                    android:paddingTop="10dp"
                    android:text="Opcja 3" />

                <RadioButton
                    android:id="@+id/rbOpcja4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:onClick="Opcja4"
                    android:paddingBottom="10dp"
                    android:paddingTop="10dp"
                    android:text="Opcja 4" />
            </RadioGroup>

        </LinearLayout>
    </ScrollView>

    <com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adReklama"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:visibility="visible"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
         />

</android.widget.RelativeLayout>

Okno z opcją pierwszego wyboru

package pl.nynacode.naukareklam;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.google.android.gms.ads.MobileAds;

public class Opcja1 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_opcja1);

        MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
    }
}
<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:textAlignment="center"
    tools:context=".Opcja1">

    <TextView
        android:id="@+id/tvTyt1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="30dp"
        android:layout_marginTop="30dp"
        android:text="Opcja pierwsza"
        android:textAlignment="center"
        android:textColor="@android:color/black"
        android:textSize="30sp"
        android:textStyle="bold" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/tvTyt1">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:id="@+id/tvTxt"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="Opowieści dziwnej treści"
                android:textAlignment="center"
                android:textColor="@android:color/black"
                android:textSize="24sp" />
        </LinearLayout>
    </ScrollView>

    <com.google.android.gms.ads.AdView
        android:id="@+id/adRek1"
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:layout_width="320dp"
        android:layout_height="50dp"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-3940256099942544/6300978111" /> />
</android.widget.RelativeLayout>

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "pl.nynacode.naukareklam"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.google.firebase:firebase-ads:11.8.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'

}

apply plugin: 'com.google.gms.google-services'

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="pl.nynacode.naukareklam">

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".OknoPierwsze"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Opcja1"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
        <activity android:name=".Opcja2"  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
        <activity android:name=".Opcja3"  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
        <activity android:name=".Opcja4" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">

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

</manifest>

 

komentarz 19 czerwca 2018 przez KubenQPL Maniak (62,820 p.)
Daj output z logcata, najlepiej to co na czerwono, bo tam jest informacja o błędzie.
komentarz 19 czerwca 2018 przez matir85 Bywalec (2,410 p.)
06-19 23:52:13.408 5489-5583/? E/ContactsProvider_EventLog: Flush buffer to file cnt : 1 size : 1Kb duration : 3ms lastUpdatedAfter : 4003 ms mFlush_time_threasold : 2000 mCurrentSize : 722
06-19 23:52:32.091 3806-5016/? E/Watchdog: !@Sync 16634 [2018-06-19 23:52:32.090]
06-19 23:52:45.578 3806-3941/? E/AlarmManager: Set nextNonWakeup as mNextNonWakeupDeliveryTime=2090920810 , orig nextNonWakeup=0
06-19 23:52:49.414 3806-3941/? E/AlarmManager: Set nextNonWakeup as mNextNonWakeupDeliveryTime=2090920810 , orig nextNonWakeup=0
06-19 23:52:51.359 3396-3396/? E/audit: type=1400 audit(1529445171.357:34079): avc:  denied  { read } for  pid=22938 comm="secondary_proce" name="22938-0" dev="debugfs" ino=25616628 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:sec_debugfs:s0 tclass=file permissive=0 SEPF_SM-G950F_8.0.0_0008 audit_filtered
06-19 23:52:55.864 5489-5583/? E/ContactsProvider_EventLog: Flush buffer to file cnt : 1 size : 2Kb duration : 2ms lastUpdatedAfter : 42455 ms mFlush_time_threasold : 2000 mCurrentSize : 1069
06-19 23:53:00.147 5489-5583/? E/ContactsProvider_EventLog: Flush buffer to file cnt : 1 size : 0Kb duration : 2ms lastUpdatedAfter : 4283 ms mFlush_time_threasold : 2000 mCurrentSize : 293
06-19 23:53:00.426 17005-17110/? E/TachyonUplContactAction: [172:737] [17110] TachyonUplContactAction: [FAILURE] Upload contacts took 130 ms
06-19 23:53:00.427 17005-17110/? E/TachyonUplContactAction: [172:738] [17110] TachyonUplContactAction: jwc: UNAUTHENTICATED: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
06-19 23:53:00.427 17005-17075/? E/TachyonGrpcChannel: [172:738] [17075] TachyonGrpcChannel: grpc send error for tag=AddContacts requestId=00a42bbd-5461-436b-80bc-03d5b86f6768 with TachyonError=UNSPECIFIED
    [172:738] [17075] TachyonGrpcChannel: jwc: UNAUTHENTICATED: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
06-19 23:53:00.427 17005-17110/? E/TachyonUplContactAction: [172:738] [17110] TachyonUplContactAction: jwc: UNAUTHENTICATED: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
        at io.grpc.Status.a(PG:50)
        at kgq.a(PG:12)
        at jvp.a(PG:2)
        at juj.a(PG:6)
        at gyz.a(PG:6)
        at jvp.a(PG:2)
        at juj.a(PG:6)
        at jyg.a(PG:32)
        at jvp.a(PG:2)
        at juj.a(PG:6)
        at jyo.a(PG:11)
        at jyr.a(PG:53)
        at jyt.a(PG:8)
        at jyw.a(PG:11)
        at jzl.run(PG:5)
        at kfi.run(PG:24)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
06-19 23:53:00.427 17005-17075/? E/TachyonGrpcChannel: [172:738] [17075] TachyonGrpcChannel: jwc: UNAUTHENTICATED: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
        at io.grpc.Status.a(PG:50)
        at kgq.a(PG:12)
        at jvp.a(PG:2)
        at juj.a(PG:6)
        at gyz.a(PG:6)
        at jvp.a(PG:2)
        at juj.a(PG:6)
        at jyg.a(PG:32)
        at jvp.a(PG:2)
        at juj.a(PG:6)
        at jyo.a(PG:11)
        at jyr.a(PG:53)
        at jyt.a(PG:8)
        at jyw.a(PG:11)
        at jzl.run(PG:5)
        at kfi.run(PG:24)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
06-19 23:53:00.427 17005-17110/? E/TachyonUplContactAction: [172:738] [17110] TachyonUplContactAction: jwc: UNAUTHENTICATED: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
        at io.grpc.Status.a(PG:50)
        at kgq.a(PG:12)
        at jvp.a(PG:2)
        at juj.a(PG:6)
        at gyz.a(PG:6)
        at jvp.a(PG:2)
        at juj.a(PG:6)
        at jyg.a(PG:32)
        at jvp.a(PG:2)
        at juj.a(PG:6)
        at jyo.a(PG:11)
        at jyr.a(PG:53)
        at jyt.a(PG:8)
        at jyw.a(PG:11)
        at jzl.run(PG:5)
        at kfi.run(PG:24)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
06-19 23:53:02.105 3806-5016/? E/Watchdog: !@Sync 16635 [2018-06-19 23:53:02.104]
06-19 23:53:04.168 5489-5583/? E/ContactsProvider_EventLog: Flush buffer to file cnt : 1 size : 1Kb duration : 3ms lastUpdatedAfter : 4021 ms mFlush_time_threasold : 2000 mCurrentSize : 723

 

1 odpowiedź

–1 głos
odpowiedź 18 czerwca 2018 przez MsMaciek123 Pasjonat (24,760 p.)
Kiedyś, coś o tym słyszałem. Trzeba mieć jakąś licencje czy cosik.
komentarz 18 czerwca 2018 przez matir85 Bywalec (2,410 p.)
Mam założone konto w AdMob i wszystkie formalne wymogi ze strony google spełniam.

Podobne pytania

0 głosów
1 odpowiedź 224 wizyt
pytanie zadane 30 grudnia 2015 w Java przez szymi666 Bywalec (2,020 p.)
0 głosów
0 odpowiedzi 185 wizyt
0 głosów
0 odpowiedzi 425 wizyt

92,540 zapytań

141,382 odpowiedzi

319,481 komentarzy

61,928 pasjonatów

Motyw:

Akcja Pajacyk

Pajacyk od wielu lat dożywia dzieci. Pomóż klikając w zielony brzuszek na stronie. Dziękujemy! ♡

Oto polecana książka warta uwagi.
Pełną listę książek znajdziesz tutaj.

Akademia Sekuraka

Kolejna edycja największej imprezy hakerskiej w Polsce, czyli Mega Sekurak Hacking Party odbędzie się już 20 maja 2024r. Z tej okazji mamy dla Was kod: pasjamshp - jeżeli wpiszecie go w koszyku, to wówczas otrzymacie 40% zniżki na bilet w wersji standard!

Więcej informacji na temat imprezy znajdziecie tutaj. Dziękujemy ekipie Sekuraka za taką fajną zniżkę dla wszystkich Pasjonatów!

Akademia Sekuraka

Niedawno wystartował dodruk tej świetnej, rozchwytywanej książki (około 940 stron). Mamy dla Was kod: pasja (wpiszcie go w koszyku), dzięki któremu otrzymujemy 10% zniżki - dziękujemy zaprzyjaźnionej ekipie Sekuraka za taki bonus dla Pasjonatów! Książka to pierwszy tom z serii o ITsec, który łagodnie wprowadzi w świat bezpieczeństwa IT każdą osobę - warto, polecamy!

...