IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Ajout de pub sur mon application


Sujet :

Android

  1. #1
    Membre à l'essai
    Homme Profil pro
    Collégien
    Inscrit en
    Juillet 2013
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 24
    Localisation : France

    Informations professionnelles :
    Activité : Collégien

    Informations forums :
    Inscription : Juillet 2013
    Messages : 9
    Points : 12
    Points
    12
    Par défaut Ajout de pub sur mon application
    Bonjour.
    J'essaie d'ajouter une pub sur mon application.
    Quand je lance l'application elle s'arrête.
    Voilà le code:
    Manifest:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.journaldunmenteur"
        android:versionCode="5"
        android:versionName="1.1.6" >
     
     
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="17" />
     
        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
           	android:label="@string/app_name"
            android:theme="@style/AppTheme" >
     
    	<activity
            android:name=".MainActivity"
            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=".deux"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".trois"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".troisdeux"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".troistrois"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".deuxdeux"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".deuxtrois"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".troisquatre"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".troiscinq"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".troissix"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".deuxquatre"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".quatre"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".cinq"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".six"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".sept"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".huit"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".neuf"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".dix"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".onze"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".douze"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".treize"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".quatorze"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".quinze"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".seize"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".dixsept"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".dixhuit"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".dixneuf"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".vingt"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".vingtetun"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".vingtdeux"
        	android:label="@string/app_name" >
        </activity>
     
        <activity
        	android:name=".vingttrois"
        	android:label="@string/app_name" >
        </activity>
        <activity
        	android:name=".vingtquatre"
        	android:label="@string/app_name" >
        </activity>    
     
        <activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout">
     
        </activity>    
     
     
    	</application>
     
     
    	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
     
    </manifest>
    activity-main
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    <?xml version="1.0" encoding="utf-8"?>
     
    <ScrollView
        xmlns:android = "http://schemas.android.com/apk/res/android"
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
     
    <RelativeLayout
     
        android:layout_width="fill_parent"
        android:layout_height="483dp"
        android:background="#0F3795"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin">
     
        <TextView
            android:id="@+id/textView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textColor="#FFFFFF"
            android:text="Bienvenue dans journal d&apos;un menteur! Choisissez le thème de mensonges." />
     
        <Button
            android:id="@+id/boutton"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/textView1"
            android:layout_below="@+id/textView1"
            android:text="Sport" />
     
        <Button
            android:id="@+id/boutton2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/boutton"
            android:layout_below="@+id/boutton"
            android:text="Mort" />
     
        <Button
            android:id="@+id/boutton3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/boutton2"
            android:layout_below="@+id/boutton2"
            android:text="Informatique" />
     
        <Button
            android:id="@+id/boutton4"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/boutton3"
            android:layout_below="@+id/boutton3"
            android:text="Famille" />
     
        <Button
            android:id="@+id/boutton5"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/boutton4"
            android:layout_below="@+id/boutton4"
            android:text="Voyages" />
     
        <Button
            android:id="@+id/boutton6"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/boutton5"
            android:layout_below="@+id/boutton5"
            android:text="Clashs" />
     
        <Button
            android:id="@+id/boutton7"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/boutton6"
            android:text="Animaux" />
     
        <Button
            android:id="@+id/boutton8"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/boutton7"
            android:layout_below="@+id/boutton7"
            android:layout_weight="3.08"
            android:text="Politique" />
     
        <Button
            android:id="@+id/boutton9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/boutton8"
            android:layout_below="@+id/boutton8"
            android:text="Quitter" />
          <com.google.ads.AdView 
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adUnitId="a151dd70004ea34"
        ads:adSize="BANNER"
        ads:loadAdOnCreate="true"/>
     
     
     
    </RelativeLayout>
     
    </ScrollView>
    Quelqu'un peut m'aider svp?

  2. #2
    Modérateur
    Avatar de Hizin
    Homme Profil pro
    Développeur mobile
    Inscrit en
    Février 2010
    Messages
    2 180
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur mobile

    Informations forums :
    Inscription : Février 2010
    Messages : 2 180
    Points : 5 072
    Points
    5 072
    Par défaut
    Citation Envoyé par floriansia
    Quelqu'un peut m'aider svp?
    Il nous faudrait l'erreur dans le LogCat, ainsi que le code qu'elle pointe pour que l'on puisse réellement t'aider.

    Par contre, je peux d'ors et déjà te donner un conseil : nomme correctement tes classes et variables !
    C'est le premier pas vers un programme lisible.
    C'est Android, PAS Androïd, ou Androïde didiou !
    Le premier est un OS, le second est la mauvaise orthographe du troisième, un mot français désignant un robot à forme humaine.

    Membre du comité contre la phrase "ça marche PAS" en titre et/ou explication de problème.

    N'oubliez pas de consulter les FAQ Android et les cours et tutoriels Android

  3. #3
    Membre habitué
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    149
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 149
    Points : 196
    Points
    196
    Par défaut
    Je ne comprend pas vraiment comment tu veux faire donc je vais te donner la solution que j'utilise pour insérer de la pub :

    Il faut ajouter ce layout dans la vue ou tu veux mettre de la pub :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
         <LinearLayout
             android:id="@+id/pub"
             android:orientation="horizontal"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content" >
    </LinearLayout>
    Et ce code dans ta partie Java au moment ou tu veux la déclencher :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    AdView adView = new AdView(this, AdSize.BANNER, "ID_ADMOB");
    LinearLayout layout = (LinearLayout)findViewById(R.id.pub);
    layout.addView(adView);
    adView.loadAd(new AdRequest());
    tu remplace ID_ADMOB par ton identifiant qu'il t'ont donné.

    et tu rajoute ces import en haut de ton code java :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    import com.google.ads.AdRequest;
    import com.google.ads.AdSize;
    import com.google.ads.AdView
    ;

    Et normalement la pub devrait s'afficher.

  4. #4
    Membre à l'essai
    Homme Profil pro
    Collégien
    Inscrit en
    Juillet 2013
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 24
    Localisation : France

    Informations professionnelles :
    Activité : Collégien

    Informations forums :
    Inscription : Juillet 2013
    Messages : 9
    Points : 12
    Points
    12
    Par défaut
    Je ne vous ait pas mis au courant: la version d'éclipse n'était pas bonne, j'ai du re-télécharger éclipse et utiliser une version android plus élevée.

  5. #5
    Membre habitué
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    149
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 149
    Points : 196
    Points
    196
    Par défaut
    Es-tu bien sûr que c'était nécessaire de retélécharger Eclipse ? Parce qu'après avoir relu le code j'ai remarqué que tu avais mis android:minSdkVersion="8" et je crois me souvenir que les pubs admob ne fonctionne pas avec Un SDKVersion < 13

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 9
    Dernier message: 16/03/2010, 11h07
  2. Ajouter un fichier pdf à mon application
    Par Jiyuu dans le forum VB.NET
    Réponses: 16
    Dernier message: 23/10/2007, 14h52
  3. Réponses: 2
    Dernier message: 12/09/2007, 22h42
  4. Skin sur mon application
    Par Freud44 dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 28/08/2007, 15h50

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo