Can anyone help me, I am trying to implement admob in android since last two days, but getting following error messages -
08-08 19:05:33.362: W/webcore(3228): Can't get the viewWidth after the first layout 08-08 19:10:51.632: W/dalvikvm(3328): VFY: unable to resolve direct method 3204: Landroid/webkit/WebView;. (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V 08-08 19:10:51.662: I/webclipboard(3328): clipservice: android.sec.clipboard.ClipboardExManager@40534500 08-08 19:10:52.142: I/CordovaLog(3328): Changing log level to DEBUG(3) 08-08 19:10:52.142: I/CordovaLog(3328): Found preference for useBrowserHistory=false 08-08 19:10:52.142: D/CordovaLog(3328): Found preference for useBrowserHistory=false 08-08 19:10:52.152: E/dalvikvm(3328): Could not find class 'android.webkit.WebResourceResponse', referenced from method org.apache.cordova.CordovaWebViewClient.generateWebResourceResponse 08-08 19:10:52.152: W/dalvikvm(3328): VFY: unable to resolve new-instance 467 (Landroid/webkit/WebResourceResponse;) in Lorg/apache/cordova/CordovaWebViewClient; 08-08 19:10:52.152: W/dalvikvm(3328): VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;) 08-08 19:10:52.182: W/dalvikvm(3328): VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;) 08-08 19:10:52.182: W/dalvikvm(3328): VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;) 08-08 19:10:52.182: W/dalvikvm(3328): VFY: unable to resolve virtual method 3225: Landroid/webkit/WebViewClient;.shouldInterceptRequest (Landroid/webkit/WebView;Ljava/lang/String;)Landroid/webkit/WebResourceResponse; 08-08 19:10:52.182: D/DroidGap(3328): DroidGap.init() 08-08 19:10:52.192: D/CordovaWebView(3328): >>> loadUrl(file:///android_asset/www/index.html) 08-08 19:10:52.192: D/PluginManager(3328): init() 08-08 19:10:52.212: D/CordovaWebView(3328): >>> loadUrlNow() 08-08 19:10:52.272: E/Ads(3328): Could not find com.google.ads.AdActivity, please make sure it is registered in AndroidManifest.xml. 08-08 19:10:52.272: E/Ads(3328): You must have AdActivity declared in AndroidManifest.xml with configChanges. 08-08 19:10:52.282: I/webclipboard(3328): clipservice: android.sec.clipboard.ClipboardExManager@405512e0 08-08 19:10:52.332: I/webclipboard(3328): clipservice: android.sec.clipboard.ClipboardExManager@405512e0 08-08 19:10:52.902: D/AndroidRuntime(3328): Shutting down VM 08-08 19:10:52.902: W/dalvikvm(3328): threadid=1: thread exiting with uncaught exception (group=0x40018578) 08-08 19:10:52.902: E/AndroidRuntime(3328): FATAL EXCEPTION: main 08-08 19:10:52.902: E/AndroidRuntime(3328): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ApplicationNexus.Albania/com.ApplicationNexus.Albania.Albania}: java.lang.NullPointerException 08-08 19:10:52.902: E/AndroidRuntime(3328): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) 08-08 19:10:52.902: E/AndroidRuntime(3328): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 08-08 19:10:52.902: E/AndroidRuntime(3328): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 08-08 19:10:52.902: E/AndroidRuntime(3328): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 08-08 19:10:52.902: E/AndroidRuntime(3328): at android.os.Handler.dispatchMessage(Handler.java:99) 08-08 19:10:52.902: E/AndroidRuntime(3328): at android.os.Looper.loop(Looper.java:130) 08-08 19:10:52.902: E/AndroidRuntime(3328): at android.app.ActivityThread.main(ActivityThread.java:3687) 08-08 19:10:52.902: E/AndroidRuntime(3328): at java.lang.reflect.Method.invokeNative(Native Method) 08-08 19:10:52.902: E/AndroidRuntime(3328): at java.lang.reflect.Method.invoke(Method.java:507) 08-08 19:10:52.902: E/AndroidRuntime(3328): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 08-08 19:10:52.902: E/AndroidRuntime(3328): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 08-08 19:10:52.902: E/AndroidRuntime(3328): at dalvik.system.NativeStart.main(Native Method) 08-08 19:10:52.902: E/AndroidRuntime(3328): Caused by: java.lang.NullPointerException 08-08 19:10:52.902: E/AndroidRuntime(3328): at com.ApplicationNexus.Albania.Albania.onCreate(Albania.java:22) 08-08 19:10:52.902: E/AndroidRuntime(3328): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 08-08 19:10:52.902: E/AndroidRuntime(3328): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 08-08 19:10:52.902: E/AndroidRuntime(3328): ... 11 more
Following is the code of my main java file -
import org.apache.cordova.*;
import com.google.ads.*;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import android.widget.*;
public class Albania extends DroidGap {
private AdView adView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
super.setIntegerProperty("loadUrlTimeoutValue", 70000);
adView = new AdView(this, AdSize.BANNER, "a1502224a0ab1f8");
LinearLayout layout = (LinearLayout) findViewById(R.id.adView);
layout.addView(adView);
adView.loadAd(new AdRequest()); }
here is my activity_appname.xml
<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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".Albania" />
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, S567041ba118d"
ads:loadAdOnCreate="true"/>
</RelativeLayout>
here is my android manifest.xml file
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Albania"
android:label="@string/title_activity_albania"
android:configChanges="orientation|keyboardHidden|orientation|keyboard|screenSize|uiMode|screenLayout|locale"
android:hardwareAccelerated="true" >
<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>