Extension Template Repository

I have built an extension and tried to download a file to the ASD (app-specific dir). This works fine on devices with API < 29.
But on devices with API > 28 I get this error:


I get the same error with the full path.

Here is my code:

Java

@SimpleFunction(description = "Downloads APK to AppSpecificDir (ASD): /storage/emulated/0/Android/data//files/. Note: No WRITE permission required.")
public void DownloadApkToASD(String url,String fileName){

	String name = fileName;
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setMimeType(URLConnection.getFileNameMap().getContentTypeFor(url));
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
	
	int version_api = Build.VERSION.SDK_INT;
	if (version_api > 28){
	request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,name); //downloads to /storage/emulated/0/Download, not to the ASD (as it should)
	}
	else {
	request.setDestinationInExternalPublicDir(context.getExternalFilesDir(null).toString().replace("/storage/emulated/0",""), name);  // doesn't work for API > 28	
	}

DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
dm.enqueue(request);

}

Does anyone have any idea how to solve this?
I compiled it with the old Extension Template (without AndroidX):
import android.support.v4.content.FileProvider;