Unity App Crashes due to Admob plugin

2,538 views
Skip to first unread message

Ahil Eswaran

unread,
Apr 26, 2015, 10:44:25 PM4/26/15
to google-adm...@googlegroups.com
I had successfully intergrated admob into my app and had released my app with ads running perfectly. However after a few days  the  app started to crash when started. I tried to remove the plugin and building it without ads and it worked, however when i try reimporting the plugin and i try building it gives me errors like unable to convert classes to de format or it just crahses. After many attempts i got the game to pop up but when the gameover screen is loaded with interstitial ads it crashes without the scene popping. The game only crashes in Android 5.0 and works fabulously in Android 4.4

Using Unity 5.0

interstitial ads script

using System.Collections;
using System;
using UnityEngine;
using GoogleMobileAds;
using GoogleMobileAds.Api;

// Example script showing how to invoke the Google Mobile Ads Unity plugin.
public class GoogleMobileAdsDemoScript : MonoBehaviour
{
InterstitialAd interstitial;

void Start () {

//---- Interstitial Ad -----
// Initialize an InterstitialAd.
// Put your admob interstitial ad id here:
interstitial = new InterstitialAd("ca-app-pub-5231647176770223/1182412990");
//Add callback for when ad is loaded
interstitial.AdLoaded += HandleAdLoaded;
// Create an ad request.
AdRequest requestInterstitial = new AdRequest.Builder().Build();
// Load the interstitial with the request.
interstitial.LoadAd(requestInterstitial);
}
public void HandleAdLoaded(object sender, EventArgs args) {
interstitial.Show ();
}
void OnDestroy(){
if (interstitial!=null) {
interstitial.AdLoaded -= HandleAdLoaded;
interstitial.Destroy ();
}

}
}

Tried this script to but also crashed

using UnityEngine;
using System.Collections;
using GoogleMobileAds;
using GoogleMobileAds.Api;


public class GoogleMobileAdsInt : MonoBehaviour {

private InterstitialAd interstitial;

private void RequestInterstitial()
{
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "ca-app-pub-2455861829005131/1839047605";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Create an interstitial.
interstitial = new InterstitialAd(adUnitId);
interstitial.LoadAd(RequestInterstitial);
}

private void ShowInterstitial()
{
if (interstitial.IsLoaded())
{
interstitial.Show();
}
else
{
print("Interstitial is not ready yet.");
}
}
}



Andrew Brogdon (Mobile Ads SDK Team)

unread,
Apr 27, 2015, 2:10:39 PM4/27/15
to google-adm...@googlegroups.com
It's difficult to know exactly where the issue lies without some kind of crash information.  Can you post your logcat output when the crash takes place (and for the preceding few minutes)?

-Andrew

Ahil Eswaran

unread,
Apr 27, 2015, 11:35:16 PM4/27/15
to google-adm...@googlegroups.com
Hi this is my logcat (ADB using CMD) from start of the app to the crash, the app lasted for about 15-20 seconds. I'm not sure what the issue is. Please Help me


I/ActivityManager(  889): START u0 {act=android.intent.action.MAIN cat=[android.
intent.category.LAUNCHER] flg=0x10200000 cmp=com.Cherry.ShapeThief/com.unity3d.p
layer.UnityPlayerActivity} from uid 10009 on display 0
W/ActivityManager(  889): mDVFSHelper.acquire()
E/ActivityManager(  889): checkUser: useridlist=null, currentuser=0
E/ActivityManager(  889): checkUser: useridlist=null, currentuser=0
E/ActivityManager(  889): checkUser: useridlist=null, currentuser=0
E/ActivityManager(  889): checkUser: useridlist=null, currentuser=0
I/ActivityManager(  889): Start proc com.Cherry.ShapeThief for activity com.Cher
ry.ShapeThief/com.unity3d.player.UnityPlayerActivity: pid=14210 uid=10261 gids={
50261, 9997, 3003} abi=armeabi-v7a
D/ActivityManager(  889): post active user change for 0
I/ActivityManager(  889): Displayed com.Cherry.ShapeThief/com.unity3d.player.Uni
tyPlayerActivity: +243ms
D/Unity   (14210): GL_AMD_compressed_ATC_texture GL_AMD_performance_monitor GL_A
MD_program_binary_Z400 GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_fra
mebuffer GL_EXT_robustness GL_EXT_texture_format_BGRA8888 GL_EXT_texture_type_2_
10_10_10_REV GL_NV_fence GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_textur
e GL_OES_depth24 GL_OES_EGL_image GL_OES_EGL_sync GL_OES_EGL_image_external GL_O
ES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_fragment_precision_high GL
_OES_get_program_binary GL_OES_packed_depth_stencil GL_OES_depth_texture_cube_ma
p GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_3D GL_OES_texture
_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture
_npot GL_OES_vertex_half_float GL_OES_vertex_type_10_10_10_2 GL_OES_vertex_array
_object GL_QCOM_alpha_test GL_QCOM_binning_control GL_QCOM_driver_control GL_QCO
M_perfmon_global_mode GL_QCOM_extended_get GL_QCOM_extended_get2 GL_QCOM_tiled_r
endering GL_QCOM_writeonly_rendering GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EX
T_
D/Unity   (14210): texture_sRGB_decode GL_EXT_texture_filter_anisotropic GL_EXT_
multisampled_render_to_texture GL_EXT_color_buffer_float GL_EXT_color_buffer_hal
f_float GL_EXT_disjoint_timer_query
W/ActivityManager(  889): mDVFSHelper.release()
W/Unity   (14210): The referenced script on this Behaviour is missing!
W/Unity   (14210):
W/Unity   (14210): (Filename:  Line: 1713)
W/Unity   (14210):
W/Unity   (14210): The referenced script on this Behaviour is missing!
W/Unity   (14210):
W/Unity   (14210): (Filename:  Line: 1713)
W/Unity   (14210):
W/Unity   (14210): The referenced script on this Behaviour is missing!
W/Unity   (14210):
W/Unity   (14210): (Filename:  Line: 1713)
W/Unity   (14210):
W/Unity   (14210): The referenced script on this Behaviour is missing!
W/Unity   (14210):
W/Unity   (14210): (Filename:  Line: 1713)
W/Unity   (14210):
W/Unity   (14210): The referenced script on this Behaviour is missing!
W/Unity   (14210):
W/Unity   (14210): (Filename:  Line: 1713)
W/Unity   (14210):
W/Unity   (14210): The referenced script on this Behaviour is missing!
W/Unity   (14210):
W/Unity   (14210): (Filename:  Line: 1713)
W/Unity   (14210):
W/Unity   (14210): The referenced script on this Behaviour is missing!
W/Unity   (14210):
W/Unity   (14210): (Filename:  Line: 1713)
W/Unity   (14210):
I/Unity   (14210): HandleAdLoaded event received.
I/Unity   (14210):
I/Unity   (14210): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bug.gen.cpp Line: 56)
I/Unity   (14210):
W/Unity   (14210): The referenced script on this Behaviour is missing!
W/Unity   (14210):
W/Unity   (14210): (Filename:  Line: 1713)
W/Unity   (14210):
W/Unity   (14210): The referenced script on this Behaviour is missing!
W/Unity   (14210):
W/Unity   (14210): (Filename:  Line: 1713)
W/Unity   (14210):
W/Unity   (14210): The referenced script on this Behaviour is missing!
W/Unity   (14210):
W/Unity   (14210): (Filename:  Line: 1713)
W/Unity   (14210):
W/Unity   (14210): The referenced script on this Behaviour is missing!
W/Unity   (14210):
W/Unity   (14210): (Filename:  Line: 1713)
W/Unity   (14210):
I/ActivityManager(  889): Process com.Cherry.ShapeThief (pid 14210)(adj 0) has d
ied(136,271)
W/ActivityManager(  889): Force removing ActivityRecord{2c8b36cb u0 com.Cherry.S
hapeThief/com.unity3d.player.UnityPlayerActivity t2397}: app died, no saved stat
e
W/ActivityManager(  889): mDVFSHelper.acquire()
D/ActivityManager(  889): handle home activity for 0
D/ActivityManager(  889): post active user change for 0
W/ActivityManager(  889): mDVFSHelper.release()
V/ActivityManager(  889): Display changed displayId=0
                       


--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/M_L9rhIbtyQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Brogdon (Mobile Ads SDK Team)

unread,
Apr 28, 2015, 6:16:29 PM4/28/15
to google-adm...@googlegroups.com
Hmm.  Our SDK uses "Ads" as its log tag, and I don't see any lines with that tag in what you've posted.  Is the application actually executing any of the Mobile Ads SDK methods? What happens if you temporarily comment them out?

-Andrew
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.

Ahil Eswaran

unread,
Apr 28, 2015, 6:19:12 PM4/28/15
to google-adm...@googlegroups.com
The banner ad seems to be loaded and works normally however when i get to the gameover screen where the interstitial is supposed to be loaded the app crashes. 

I/Unity   (14210): HandleAdLoaded event received

To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/M_L9rhIbtyQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.

Andrew Brogdon (Mobile Ads SDK Team)

unread,
Apr 29, 2015, 8:24:55 PM4/29/15
to google-adm...@googlegroups.com
I don't actually see the line that would write "HandleAdLoaded event received" to the logs in your source. Have you changed the code since your original post?

-Andrew


On Tuesday, April 28, 2015 at 3:19:12 PM UTC-7, Ahil Eswaran wrote:
The banner ad seems to be loaded and works normally however when i get to the gameover screen where the interstitial is supposed to be loaded the app crashes. 

I/Unity   (14210): HandleAdLoaded event received
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/M_L9rhIbtyQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.

Ahil Eswaran

unread,
Apr 29, 2015, 9:45:01 PM4/29/15
to google-adm...@googlegroups.com
No it's in one of the lines in the log i sent earlier on 

Sent from my iPhone
To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.

Andrew Brogdon (Mobile Ads SDK Team)

unread,
Apr 30, 2015, 7:19:23 PM4/30/15
to google-adm...@googlegroups.com
Okay, in that case, I would fall back to my earlier suggestion and comment out all the AdMob loading/displaying code and add it back one line at a time, seeing at what point things begin to break.  Also, I notice that the first of the two scripts you posted is calling the Show() method of the interstitial inside the onAdLoaded handler, which is not the correct thing to do.  Interstitials should be displayed when the application has reached a natural pause in the action, which isn't likely to have happened exactly when the ad finishes loading.

-Andrew


On Wednesday, April 29, 2015 at 6:45:01 PM UTC-7, Ahil Eswaran wrote:
No it's in one of the lines in the log i sent earlier on 

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages