ADMOB XML The following classes could not be instantiated: - com.google.android.gms.ads.AdView



Ok, so I tried some guides here but none helped me, there were so many updates to the admob so I can't know how my admob should look like, but I hope you can help me :)


here is my xml file:



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/patternsplash"
android:orientation="vertical" xmlns:app="http://ift.tt/1bhZ3VK">

<Button
android:id="@+id/play"
android:layout_width="120dp"
android:layout_height="70dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="150dp"
android:background="@drawable/startb" />

<Button
android:id="@+id/help"
android:layout_width="120dp"
android:layout_height="70dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="30dp"
android:background="@drawable/helpb" />

<com.google.android.gms.ads.AdView
xmlns:ads="http://ift.tt/1bhZ3VK"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:adSize="BANNER"
app:adUnitId="ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYY" />

</LinearLayout>


Here is my class (Im trying to add the admob ad to the main menu called splashscreen [it was a splashscreen and I changed it to a main menu]) :



package com.FirstAppDevelopment.BlueTAP;

import com.FirstAppDevelopment.BlueTap.R;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;

public class SplashScreen extends Activity {
private AdView adView;
private static final String AD_UNIT_ID = "ca-app-pub-XXXXXXXXXXXXXXXXX/YYYYYYYYYYY";

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_splash);
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(AD_UNIT_ID);
LinearLayout layout = (LinearLayout) findViewById(R.layout.activity_splash);
layout.addView(adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
.addTestDevice("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
.build();
adView.loadAd(adRequest);
final Button button = (Button) findViewById(R.id.play);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
Intent myIntent = new Intent(SplashScreen.this,
FirstActivity.class);
startActivity(myIntent);
}
});
final Button button1 = (Button) findViewById(R.id.help);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
Intent intent = new Intent(SplashScreen.this, help.class);
startActivity(intent);
}
});
}
@Override
public void onResume() {
super.onResume();
if (adView != null) {
adView.resume();
}
}

@Override
public void onPause() {
if (adView != null) {
adView.pause();
}
super.onPause();
}

@Override
public void onDestroy() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}


My proguard:



# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://ift.tt/1dvuuBa
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
# -keep class * extends java.util.ListResourceBundle {
# protected Object[][] getContents();
#}
#-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
# public static final *** NULL;
#}
#-keepnames @com.google.android.gms.common.annotation.KeepName class *
#-keepclassmembernames class * {
# @com.google.android.gms.common.annotation.KeepName *;
#}
#-keepnames class * implements android.os.Parcelable {
# public static final ** CREATOR;
#}
#}


My AndroidManifest:



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
package="com.FirstAppDevelopment.BlueTap"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />

<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
</uses-permission>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/CustomActionBarTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

<activity
android:name="com.FirstAppDevelopment.BlueTAP.SplashScreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.FirstAppDevelopment.BlueTAP.FirstActivity"
android:label="@string/app_name" >
</activity>
<activity android:name="com.FirstAppDevelopment.BlueTAP.Level2" />
<activity android:name="com.FirstAppDevelopment.BlueTAP.Shop" />
<activity android:name="com.FirstAppDevelopment.BlueTAP.help" />
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>

</manifest>


Can anyone find my problem :( ?


Tiada ulasan:

Catat Ulasan