Question

I am using an adMob banner in my application but when I run it, I got an errors as bellow:

12-17 12:32:19.098: E/Trace(1244): error opening trace file: No such file or directory (2)
12-17 12:32:19.727: D/dalvikvm(1244): GC_FOR_ALLOC freed 55K, 3% free 8039K/8259K, paused 60ms, total 63ms
12-17 12:32:19.907: I/dalvikvm-heap(1244): Grow heap (frag case) to 19.900MB for 12582928-byte allocation
12-17 12:32:20.008: D/dalvikvm(1244): GC_CONCURRENT freed 1K, 2% free 20326K/20615K, paused 30ms+19ms, total 97ms
12-17 12:32:21.677: W/Ads(1244): No Google Analytics: Library Incompatible.
12-17 12:32:21.697: D/AndroidRuntime(1244): Shutting down VM
12-17 12:32:21.697: W/dalvikvm(1244): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
12-17 12:32:21.727: E/AndroidRuntime(1244): FATAL EXCEPTION: main
12-17 12:32:21.727: E/AndroidRuntime(1244): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.antiwal7amel/com.app.antiwal7amel.MenuActivity}: java.lang.NullPointerException
12-17 12:32:21.727: E/AndroidRuntime(1244):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at android.os.Looper.loop(Looper.java:137)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at android.app.ActivityThread.main(ActivityThread.java:4745)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at java.lang.reflect.Method.invokeNative(Native Method)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at java.lang.reflect.Method.invoke(Method.java:511)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at dalvik.system.NativeStart.main(Native Method)
12-17 12:32:21.727: E/AndroidRuntime(1244): Caused by: java.lang.NullPointerException
12-17 12:32:21.727: E/AndroidRuntime(1244):     at com.app.antiwal7amel.MenuActivity.onCreate(MenuActivity.java:44)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at android.app.Activity.performCreate(Activity.java:5008)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-17 12:32:21.727: E/AndroidRuntime(1244):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-17 12:32:21.727: E/AndroidRuntime(1244):     ... 11 more

I am using it as bellow :

public class MenuActivity extends Activity   {
    AdView  adView ;
    @Override   

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_main);

        AdView ad = (AdView) findViewById(R.id.adView);
 AdRequest request = new AdRequest();
 ad.loadAd(request);

And inside my manifest also :

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

But I don't know where is the problem ! I googled it a lot with no solution

Was it helpful?

Solution

If the problem is situated in ad.loadAd(request); this is probably a problem with the id adView not existing in your activity_main layout.

Or maybe there is something wrong with the initialisation of the AdRequest. Maybe you can check why one of these elements is null. Because when you know which of them is null you can try to solve the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top