App works in Sim but crashes out on phone

Hi, I’ve updated to 3720 and built my app. It runs fine in the simulator, but when I copy the apk it to my Samsung S22+ and run it, it crashes out right away. This is same code that was working on older version of corona. The only change is I upgraded the google iap library and added the new adaptive icons.

Is there anything else an older project needs when upgrading to the latest solar2d version?

Thanks, Greg

Did you try adb? That’s very good for debugging on android phones.
If I have to guess, you are probably using a plugin which has been temporarily broken by an update tho.

Thanks for your reply,

I have tracked it down to admob. My code is probably way outdated, I am debugging that now.

Its fun to be back working in solar2d! Greg

1 Like

Hi,

As soon as I comment out admob my app works. I’ve updated the Admob AppID and made sure the code is exactly as the solar2d documentation shows. I really think its the actual plugin that is crashing on load.

As soon as I uncomment the admob plugin in build.settings the app will crash right away.

Solar2d version:3720
in my Build.settings: [“plugin.admob”] = { publisherId = “com.coronalabs”},
in my Startup.lua: local admob = require( “plugin.admob” )

Any ideas? Thanks, Greg

AdMob was last updated in October 2024. Have you tried a build since then? If so, then it sounds like a bad interaction between the latest Solar2D build and AdMob, if, on the other hand, this is the first time you’ve tried building since October, then AdMob might be the problem.

I would suggest rolling back the version of AdMob, since that’s the easiest- change your AdMob plugin call in build.settings to this:

["plugin.admob"] =
{
publisherId = "com.coronalabs",
version = "v38",
},

Version 38 is actually about 18 months old (current version is 45), but it goes back before the latest round of API and Android version updates. (You can look at the AdMob release timeline here.)

The other thing to try would be keeping AdMob at version 45, and rolling back to earlier versions of Solar2D. This is pretty easy if you’re on a Mac, since you can have multiple versions of Solar2D installed simultaneously, but a bit more of a pain in the butt if you’re on Windows.

Hopefully between those two variables, you’ll be able to figure out where the conflict lies.

Thank you for the suggestions but no luck yet:

With version 3720: I tried admob versions = 44, 38, 37 and the same crash on device

I rolled back to 3717 and same crash on device

I remove admob from my app and it runs great on device.

I took a sample app, added admob to it and get the same crash on device.

Thanks, Greg

You need to see the error so you can tell if something is wrong on your side or else.
Adb logcat would be the best option, or you could catch unhandled error to show them on the screen.

Hi II.Sui,

You are absolutely correct, I need to get adb working. I’m having a tough time making that happen. I’m about 90% there. For now I have removed admob from my projects.

Thanks, Greg

Just to do a bit of first-principle troubleshooting, are you sure you have com.google.android.gms.ads.APPLICATION_ID correctly defined in build.settings?

Thank you Colin, I appreciate the feedback, the app in question has been on the app store for at least ten years with admob running. If I literally just add the line [“plugin.admob”] = { publisherId = “com.coronalabs”}, to my build.settings the app will crash on my phone immediately. That being the case I have released it without admob for now and see what I can deduce. I did build a sample app and the same thing happened.

If my admob application id was wrond, wouldn’t I get an error message in the console and not a hard crash?

Thanks, Greg

Most of the time crash is related to

com.google.android.gms.ads.APPLICATION_ID

settings =
{
    android =
    {
        applicationChildElements =
        {
            [[
                <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
                    android:value="[YOUR_ADMOB_APP_ID]"/>  -- replace with your app id. See: https://goo.gl/fQ2neu
            ]],
        },
    },

this needs to be in your app or you will get a crash

Hi Scott,

That may be the problem. I don’t think I had the correct tree/brace structure with the meta-data tag. I will test it out and report back.

Thanks, Greg

Hard crash without console output is definitely the behavior when you include the AdMob plugin but don’t have com.google.android.gms.ads.APPLICATION_ID in build.settings.

here is my build.settings file. Would the crash occur if my admob app id is wrong?

settings = {

splashScreen = { enable = false },

orientation = {
	default = "landscapeRight",
	supported = { "landscapeRight", "landscapeLeft" }
},


plugins =
{
	
 ["plugin.google.iap.billing.v2"] = { publisherId = "com.solar2d"}, 
 ["plugin.amazon.iap"] = {publisherId = "com.coronalabs", supportedPlatforms = { ["android-kindle"]=true }},
--["plugin.admob"] =  { publisherId = "com.coronalabs"}, 
["plugin.admob"] = {publisherId = "com.coronalabs", version ="v37"},
 ["plugin.openssl"] ={publisherId = "com.coronalabs"},

},      


iphone = 
{
	xcassets = "Images.xcassets",
	plist = {
		UIStatusBarHidden = true,
		UIPrerenderedIcon = true, -- set to false for "shine" overlay
	        UIApplicationExitsOnSuspend = false,
		UILaunchStoryboardName = "LaunchScreen",  -- Required!
		NSAppTransportSecurity =
        {
            NSExceptionDomains =
            {
                ["stellartrek.com"] =
                {
                    NSIncludesSubdomains = true,
                    NSThirdPartyExceptionAllowsInsecureHTTPLoads = true,
                },
            },
            NSAllowsArbitraryLoads = true,
        },
		
		UIAppFonts = {
			"Roddenberry.otf",
		},             
	}
},

android =
{

	usesPermissions =
    {
       "android.permission.INTERNET",
       "android.permission.WRITE_EXTERNAL_STORAGE",
       "android.permission.ACCESS_NETWORK_STATE",
       "com.android.vending.BILLING",
       "com.android.vending.CHECK_LICENSE",
       "android.permission.VIBRATE",  
    },

	applicationChildElements =
    {
		[[<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="[ca-app-pub-97136305344xxxxx~21982xxxxx]"/>]],
    },
    
}

}

Take out the brackets between the quotes. It should look like this:

android:value="ca-app-pub-97136305344xxxxx~21982xxxxx"

Son of a gun if that wasn’t the problem!!! Thank you for point that out!!! Once again it seems like the problem was between the keyboard and the seat! :slight_smile:

Have a great day, Greg

The convention of using brackets in “[Put your info here]” has tripped me up on more than one occasion. That’s how I knew to check for it. :rofl:

Glad to hear you’re back on track.