Wie baue ich eine Werbung-Anzeige in meine App ein ???

  • 17 Antworten
  • Letztes Antwortdatum
hunter123

hunter123

Neues Mitglied
0
Hey Leute,
ich suche ein Tutorial das mir step by step mir erklärt wie ich werbung von
Google in meine App einbaue. Also ein Adsense Konto hab ich schon bloß wo
muss ich mir den code hollen? (falls es ein script ist) wie soll ich den einbauen und wo ???

Bitte um hilfe :tongue:

Gruß hunter123:laugh:
 
kleinerkathe schrieb:



Danke für die hilfe :)

Ich habe trotzdem noch ein Problem in meiner Android Manifest.xml datei, also ich hab alles so gemacht wie es in Google beschrieben wurde ich starte meine app und oben in meiner mainactivity kommt der balken für die Werbung und darin steht "You must have AdActivity declared in AndroidManifest.xml with configChanges" obwohl ich alles reinkopiert habe was in google war des mit der android:name & configchange ..

Also hier mein ganzer Android Manifest code vll seht ihr ja was was ich falsch gemacht habe::blink:

Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="nig.loot.dayzloot"
          android:versionCode="1"
          android:versionName="1.0">
          
    <uses-sdk android:minSdkVersion="8"
              android:targetSdkVersion="19" />

	<uses-permission android:name="android.permission.INTERNET"/>
 	 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  
    <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:allowBackup="true" android:theme="@style/AppTheme">
       <meta-data android:name="com.google.android.gms.version"
               android:value="a14e20856e4ad8f"/>
       
        <activity android:name="nig.loot.dayzloot.Main"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.google.android.gms.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>
	
</manifest>
 
minSDK ??:confused:
wo kann ich des finden ??

Also ich hab in den 3 Seiten die du mir geschickt hast nach geschaut und jede Variante ausprobiert kommt trotzdem der selber fehler...

Hier noch mal alles von meinem Projekt vll kannst du mir helfen :

Hier mein Java-Code:
Code:
package nig.loot.dayzloot;



import com.google.ads.AdRequest;
import com.google.ads.AdView;

import android.app.Activity;
import android.os.Bundle;


import android.annotation.SuppressLint;
import android.view.Menu;
import android.view.View;


public class Main extends Activity {
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
     // Create the adView
        AdView adView = (AdView) findViewById(R.id.adView);

       // Initiate a generic request to load it with an ad
       adView.loadAd(new AdRequest());
        
        }

Hier meine Activity-Main:

Code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    android:id="@+id/layout" >
    
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="900dp"
    android:gravity="top" >

    
    	<ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:src="@drawable/uber1"
            android:contentDescription="@string/kb" />

        <ImageButton
            android:id="@+id/zeugsbutton1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/imageView1"
            android:onClick="buttonclickwaffen"
            android:src="@drawable/weapons"
            android:contentDescription="@string/kb" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/zeugsbutton1"
            android:layout_centerHorizontal="true"
            android:src="@drawable/balken"
            android:contentDescription="@string/kb" />

        <ImageButton
            android:id="@+id/imageButton1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/imageView2"
            android:contentDescription="@string/kb"
            android:onClick="Rucksaecke"
            android:src="@drawable/backpacks" />

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/imageButton1"
            android:layout_centerHorizontal="true"
            android:src="@drawable/balken" 
            android:contentDescription="@string/kb"/>

        <ImageButton
            android:id="@+id/imageButton2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/imageView3"
            android:contentDescription="@string/kb"
            android:src="@drawable/toolbelt"
            android:onClick="Toolbelt" />

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/imageButton2"
            android:layout_centerHorizontal="true"
            android:src="@drawable/balken"
            android:contentDescription="@string/kb" />

        <ImageButton
            android:id="@+id/imageButton4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/imageView4"
            android:contentDescription="@string/kb"
            android:src="@drawable/industrialloot" />

        <ImageView
            android:id="@+id/imageView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/imageButton4"
            android:contentDescription="@string/kb"
            android:src="@drawable/balken" />

        <ImageButton
            android:id="@+id/imageButton3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/imageView5"
            android:contentDescription="@string/kb"
            android:onClick="essenall"
            android:src="@drawable/footdrink" />
        
        <com.google.ads.AdView
		    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
		    android:id="@+id/adView"
		    android:layout_width="fill_parent"
		    android:layout_height="fill_parent"
		    ads:adSize="BANNER"
		    ads:adUnitId="ca-app-pub-0315424418130722/2128404097" >
            
        </com.google.ads.AdView>
        
    
</RelativeLayout>

</ScrollView>

Und mein Manifest noch mal:

Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="nig.loot.dayzloot"
          android:versionCode="1"
          android:versionName="1.0">
    <uses-sdk android:minSdkVersion="9" />
    <uses-sdk android:targetSdkVersion="17" />

    <application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
        <activity android:name=".Main"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name="com.google.ads.AdActivity"
                  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>

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

Ist ez sau viel Code zum verstehn:unsure: aber wär echt nice wenn du mir den fehler findest dann werd ich dir danken :rolleyes2:
 
Zuletzt bearbeitet von einem Moderator:
Steht doch fast ganz oben in deinem Manifest.

lg. Dagobert
 
tut zwar nix zum thema, aber wenn man an einem so simplen task scheitert, sollte man vielleicht etwas anderes machen als mal eben werbung in die app zu integrieren.

eventuell mal grundlagen lernen?

nur ein kleiner tipp
 
swordi schrieb:
tut zwar nix zum thema, aber wenn man an einem so simplen task scheitert, sollte man vielleicht etwas anderes machen als mal eben werbung in die app zu integrieren.

eventuell mal grundlagen lernen?

nur ein kleiner tipp

Ne es interessiert mich einfach! die Grundlagen erlerne ich mir wie gesagt lernen by doing.

Und wenn ich mir nicht sicher bin und fehler habe frag ich nach!

Wenn du mir nicht helfen kannst dann brauchst du auch nicht antworten

.danke

Der ursprüngliche Beitrag von 13:37 Uhr wurde um 13:47 Uhr ergänzt:

DagobertDokate schrieb:
Steht doch fast ganz oben in deinem Manifest.

lg. Dagobert


Ja hab ich ja ich hab alles rein geschrieben was ich für die Anzeige der werbung brauche nur wenn ich meine app starte kommt immer der selber fehler..
 
kleinerkathe schrieb:


Du hast alle Links durchgeschaut und ausprobiert? Das glaub ich nicht ... minSDK ist nämlich nur von 8 auf 9 erhöht worden und nicht wie in den Links beschrieben auf irgendwas mit 13 (ich hab grad nicht nachgeschaut was genau das minSDK sein muss ...)
 
Ahh, dann sind die bei SO wieder veraltet, da stand immer was von 13 (jetzt hab ich da nachgeschaut ^^)
 
Auf jeden Fall ein cooles Tutorial ;)
 
Danke für die Links - ab und an sollte man doch mal wieder bei AdMob vorbei schauen, ich sehe gerade die ziehen die ganze Werbegeschichte auch auf die GooglePlayService Lib. Wann ist den das passiert ?

Auf der Seite habe ich leider keine Information gefunden, wann dann die "alte" variante deprecated sein wird ? (alt = klassisch) - hat da jemand Informationen ?
 
swordi schrieb:
tut zwar nix zum thema, aber wenn man an einem so simplen task scheitert, sollte man vielleicht etwas anderes machen als mal eben werbung in die app zu integrieren.

eventuell mal grundlagen lernen?

nur ein kleiner tipp

+1
 
SOOOO habs geschafft den Fehler zu fixen lag doch nicht in der AndroidManifest lag an meinem Projekt! Mein Projekt war beschädigt und konnte ürgendwie nicht auf den google.AdMob Script zu greifen....

Also hab ich beschlossen neues Projekt zu erstellen und habe es so gemacht und läuft super ;)

1. At the first hab ich den GoogleAdMObAdsSdk-6.4.1.jar in die Library eingefügt

2. Dann habe ich in die Activity_Main den Code eingefügt:

Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    tools:context=".Main" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />
    
    <com.google.ads.AdView android:layout_width="match_parent"
                           android:layout_height="wrap_content"
                           android:id="@+id/adMob"
                           android:layout_alignParentBottom="true"
                           ads:adUnitId="Deine AD-Mob ID"
                           ads:adSize="BANNER"/>

</RelativeLayout>

3. Die Android Mainfest habe ich mit diesem Code ausgestattet:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="kif.example.dayz"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="kif.example.dayz.Main"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
        android:name="com.google.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
    </application>

</manifest>
4. In meiner Main.java habe ich diesen leicht verständlichen code eingefügt: :tongue:

Code:
package kif.example.dayz;

import com.google.ads.AdRequest;
import com.google.ads.AdView;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class Main extends Activity {

	AdView adView;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
        //request TEST ads to avoid being disabled for clicking your own ads
        AdRequest adRequest = new AdRequest();
 
        //test mode on EMULATOR
        adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
        
 
        adView = (AdView)findViewById(R.id.adMob);      
 
        // Initiate a request to load an ad in test mode.
        // You can keep this even when you release your app on the market, because
        // only emulators and your test device will get test ads. The user will receive real ads.
        adView.loadAd(adRequest);
 
         
    }
 
 
    @Override
    public void onDestroy() {
        if (adView != null) {
            adView.destroy();
        }
        super.onDestroy();
    }
		
	

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}

Diese Arbeit die ich grad gemacht geht an die Leute die auch in der Anfangsphase sind und am anfang sehr viele Fehler haben :flapper:

mfg Hunter123
-------------------------------------------------------------
496309.56hlgngw.mwkr600.gif
 
Zurück
Oben Unten