Android API level 30 is here in 3651

UPDATE: Please use 3651

since 3650 had issues with Google License Checking

Android API level 30

Android introduced breaking change in Android 11 (api 30) which we are now targeting). Major change affecting system.canOpenURL() call. It now requires to list all schemes you’ll use in the build.setting (AndroidManifest.xml).
Hovewer, due to quicks with Android implementation, even listing scheme sometimes gives the wrong result (for example, if user chose to always use the App to open https://twitter.com links, the query for this URL would return false if no special <query> element is added. Confusing, indeed.
Current recommendation is use openURL instead o canOpenURL. It will always return reliable result, if URL was handled.
For example, consider following code:

	local mapURL = "https://maps.google.com/maps?q=Hello,+Solar2D!@" .. currentLatitude .. "," .. currentLongitude
	if system.canOpenURL( mapURL ) then
		-- Show location on map
		system.openURL( mapURL )
	else
		native.showAlert( "Alert", "No browser found to show location on map!", { "OK" } )
	end

Is better written as

	local mapURL = "https://maps.google.com/maps?q=Hello,+Solar2D!@" .. currentLatitude .. "," .. currentLongitude
	if not system.openURL( mapURL ) then
		native.showAlert( "Alert", "No browser found to show location on map!", { "OK" } )
	end

Latter code would work realiably without need to add any manifest entries via build.settings.

Example entries

If you do want to query if some app can handle URL, here are some code examples for your build.settings:

settings =
{
    android =
    {
        manifestChildElements = 
        {
            [[
            <queries>
                <package android:name="com.facebook.katana" />
                <package android:name="com.instagram.android" />
                <intent>
                    <action android:name="android.intent.action.VIEW" />
                    <data android:scheme="http" />
                </intent>
            </queries>
            ]],
        },
    },
}

Read more about following change at the android developers blog.

Download first release: https://github.com/coronalabs/corona/releases/tag/3651

1 Like

@vlads, although new builds require api 30 now, UPDATES don’t require it until November. Does this build still support api 29, or must I use 3649 until November?

@vlads S2D version 3651 (and 3650) have now broken my app for Android builds. Here is all the log shows:

^[[A08-19 11:22:19.886 22272 23300 V Corona : > Class.forName: network.LuaLoader
08-19 11:22:19.886 22272 23300 V Corona : < Class.forName: network.LuaLoader
08-19 11:22:19.887 22272 23300 V Corona : Loading via reflection: network.LuaLoader
08-19 11:22:19.897 22272 23300 I Corona : Platform: SM-A115M / ARM Neon / 11 / Adreno ™ 506 / OpenGL ES 3.2 V@0502.0 (GIT@8fc5070, I2b41315a24, 1611346138) (Date:01/22/21) / 2021.3651 / English | US | en_US | en
08-19 11:22:19.925 22272 23300 V Corona : > Class.forName: shared.google.play.services.base.LuaLoader
08-19 11:22:19.926 22272 23300 V Corona : < Class.forName: shared.google.play.services.base.LuaLoader
08-19 11:22:19.926 22272 23300 V Corona : Loading via reflection: shared.google.play.services.base.LuaLoader
08-19 11:22:19.957 22272 23300 V Corona : > Class.forName: licensing.LuaLoader
08-19 11:22:19.962 22272 23300 V Corona : > Class.forName: CoronaProvider.licensing.google.LuaLoader
08-19 11:22:19.963 22272 23300 V Corona : < Class.forName: CoronaProvider.licensing.google.LuaLoader
08-19 11:22:19.967 22272 23300 V Corona : Loading via reflection: CoronaProvider.licensing.google.LuaLoader
08-19 11:22:20.496 22272 23300 I Corona : [Lua::RuntimeDispatchEvent()] WARNING: This function is deprecated. Use Lua::DispatchRuntimeEvent() instead.

Version 3649 works fine. Any suggestions about how to fix this?

there has to be more to the logs than this. So far so good. What else do you see?

What do you see on screen when this is happening?

Thank you for reporting this. New build is building. It would come online and this issue should be fixed in next build.
Sorry for inconvenience.

1 Like

Looks like notifications.v2 broke with this update, and later versions too, on Android devices. When trying to get the device token the following error occurs and show when debugging in Android Studio:

I/Corona: ERROR: Runtime error
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/iid/FirebaseInstanceId;
Java Stack Trace:
plugin.notifications.v2.LuaLoader$GetDeviceToken.invoke(LuaLoader.java:267)
com.naef.jnlua.LuaState.lua_pcall(Native Method)
com.naef.jnlua.LuaState.call(LuaState.java:564)
com.ansca.corona.CoronaLua.dispatchEvent(CoronaLua.java:140)
network.NetworkRequest$LuaCallback$1.executeUsing(NetworkRequest.java:612)
com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:179)
com.ansca.corona.events.EventManager.sendEvents(EventManager.java:100)
com.ansca.corona.Controller.updateRuntimeState(Controller.java:319)
com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:434)
com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1625)
com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1380)
at getDeviceToken (External Function)
at ? (?:0)
at ? (?:0)
at (Unknown Function) (?:0)
at ? (?:0)
at (Unknown Function) (?:0)
create error file