I just put my first app online but it keeps crashing and I don't know why: it worked fine on the emulator.
It's a small game that uses a custom SurfaceView
and bitmaps.
I reported the crashes and I got a logcat which I don't understand.
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:3566)
at android.view.ViewGroup.addView(ViewGroup.java:3437)
at android.view.ViewGroup.addView(ViewGroup.java:3382)
at android.view.ViewGroup.addView(ViewGroup.java:3358)
at com.jumping_jack.jjack.MainActivity$1.onAdLoaded(MainActivity.java:68)
at com.google.android.gms.internal.at.onAdLoaded(Unknown Source)
at com.google.android.gms.internal.bc$a.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:310)
at com.google.android.gms.ads.internal.client.h.c(SourceFile:152)
at com.google.android.gms.ads.internal.b.v(SourceFile:1351)
at com.google.android.gms.ads.internal.b.a(SourceFile:777)
at com.google.android.gms.ads.internal.request.m.run(SourceFile:173)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5283)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalv
java.lang.NullPointerException
at com.jumping_jack.jjack.GameLoop.draw(GameLoop.java:220)
at com.jumping_jack.jjack.GameLoop.run(GameLoop.java:161)
at java.lang.Thread.run(Thread.java:856)
ik.system.NativeStart.main(Native Method)
I suspect this is the faulty code
adView.setAdListener(new AdListener() {
public void onAdLoaded(){
adLoaded = true;
mainLayout.removeView(splashScreen);
set1.recycle();
bm.recycle();
System.gc();
mainLayout.addView(sView);
adView.bringToFront();
}
}
My guess is that when the ad is reloaded it calls this function again but I'm not sure.
Also, I checked my cache it's 5.66 mb: I don't know if this is also an issue.
Please, if you understand the log, help me.
Like I said, on the emulator, it works just fine so I don't want to update it. Thank you!