I made a Flappy Bird remake and I just got done with it not too long ago, everything worked as expected, but when I try to add Google's ads, the ads display, but the game doesn't execute and run, it's just a black screen. I'm using LibGDX for my game also. Here's the MainActivity.java code and Main.xml code.
MainActivity.java :
package com.kensleeinc.SuperBird;
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.kilobolt.ZombieBird.R;
import com.kilobolt.ZombieBird.ZBGame;
public class MainActivity extends AndroidApplication
{
private AdView adView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.useGL20 = false;
initialize(new ZBGame(), cfg);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}
}
Main.xml :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_unit_id"/>
</RelativeLayout>
Can anyone help me with this? Thanks!
Heres my log.txt -
11-28 19:41:07.521: E/AndroidRuntime(2889): FATAL EXCEPTION: main
11-28 19:41:07.521: E/AndroidRuntime(2889): Process: com.kilobolt.ZombieBird, PID: 2889
11-28 19:41:07.521: E/AndroidRuntime(2889): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kilobolt.ZombieBird/com.kensleeinc.SuperBird.MainActivity}: java.lang.NullPointerException
11-28 19:41:07.521: E/AndroidRuntime(2889): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395)
11-28 19:41:07.521: E/AndroidRuntime(2889): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2453)
11-28 19:41:07.521: E/AndroidRuntime(2889): at android.app.ActivityThread.access$900(ActivityThread.java:173)
11-28 19:41:07.521: E/AndroidRuntime(2889): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
11-28 19:41:07.521: E/AndroidRuntime(2889): at android.os.Handler.dispatchMessage(Handler.java:102)
11-28 19:41:07.521: E/AndroidRuntime(2889): at android.os.Looper.loop(Looper.java:136)
11-28 19:41:07.521: E/AndroidRuntime(2889): at android.app.ActivityThread.main(ActivityThread.java:5579)
11-28 19:41:07.521: E/AndroidRuntime(2889): at java.lang.reflect.Method.invokeNative(Native Method)
11-28 19:41:07.521: E/AndroidRuntime(2889): at java.lang.reflect.Method.invoke(Method.java:515)
11-28 19:41:07.521: E/AndroidRuntime(2889): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
11-28 19:41:07.521: E/AndroidRuntime(2889): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
11-28 19:41:07.521: E/AndroidRuntime(2889): at dalvik.system.NativeStart.main(Native Method)
11-28 19:41:07.521: E/AndroidRuntime(2889): Caused by: java.lang.NullPointerException
11-28 19:41:07.521: E/AndroidRuntime(2889): at com.kensleeinc.SuperBird.MainActivity.onCreate(MainActivity.java:26)
11-28 19:41:07.521: E/AndroidRuntime(2889): at android.app.Activity.performCreate(Activity.java:5451)
11-28 19:41:07.521: E/AndroidRuntime(2889): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
11-28 19:41:07.521: E/AndroidRuntime(2889): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2359)
11-28 19:41:07.521: E/AndroidRuntime(2889): ... 11 more