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

2 Likes

@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

Android 10+ api 30 also broke native webview especially with removal of cleartext allowance. Local html files in temp or document directory no longer loading in app via native webview, get ERR_ACCESS_DENIED. @vlads can you take a look at that as well please. I don’t think can revert back as clear text is no longer allowed by google.

This link has some guide on what change has to be made to that api in 30 for it to work:

1 Like

Thanks for letting me know. I’ll fix it later today

Hello!
As a workaround, try calling

webview:setNativeProperty("setAllowFileAccess", true)

right after creating a webview (before any load occurred).

Cheers!

EDIT: changed . to :

Thanks Vlad cheers

Edit: Worked perfectly on device, thanks

Another issue I noticed which wasn’t there on earlier builds is that on windows simulator, any network.request to an api made on windows 7 is returning an error. Not sure if this is due to my installation but thought I’d mention it here. On android devices the call goes through fine.

error -1 Certificate required

Additionally, I have a sizable app build around 1.2gb which I used to upload via expansion files, 15mb apk and 1.2gb app obb file. With the new solar2d build, the output app bundle on upload is giving the following error on google play store:
“Your Android App Bundle has an invalid signature. Upload again with a valid signature.”
The apk is uploading just fine.

Thank you for reporting this.

Nice, but I download a pdf file from web into a local directory beacuse the url need authentication :

network.download( url, “GET”, downloadpdf_networkListener,params, “worksheet.pdf”, system.DocumentsDirectory, 0, 0 )

after in the “downloadpdf_networkListener” I would like to open it :

local wasOpened = system.openURL(system.pathForFile(“worksheet.pdf”,system.DocumentsDirectory))

It not works, beacuse Android 11 occurs permision error for this local directory. How can I solve this ?

Thanks
wwwbetyar

Hello everyone,
also i have the same problem with system.openURL() function for android versions with API greater than 29.

Compared to before, now I can’t open a downloaded pdf document in system.DocumentsDirectory

It seems to be a permissions problem but I don’t know what to do.
Can someone help me?..

Thank you

Adobe pdf works always for me. Another pdf viewers not really. It was my only solution.

Thanks szabo.attila.cegled, :slightly_smiling_face: but I would necessarily need a solution that allows me to open pdf from any third-party app.

I think we won’t be the only ones having this problem developing Apps for newer Android versions.

Let’s hope for some help :crossed_fingers:

Thanks