qt 6.8 EmailSender + activity() is not public in QtNative + cannot be accessed from outside package
-
Hi,
I am trying to update my qt version from 6.5.3 -> 6.8.0 LTS.
When I try to build my Qt application with android (android_arm64_v8a), i get the below error:
*> Task :compileDebugJavaWithJavac FAILED
......\EmailSender.java:43: error: activity() is not public in QtNative; cannot be accessed from outside package
Intent intent = ShareCompat.IntentBuilder.from(QtNative.activity()).getIntent();
^
......\EmailSender.java:58: error: activity() is not public in QtNative; cannot be accessed from outside package
Uri contentUri = FileProvider.getUriForFile(QtNative.activity(), authority, contentFile);
^
2 errors
FAILURE: Build failed with an exception.- What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.*
Please guide with a solution ?
Note : It is seen that similar issue is already reported by some other user. But there is no solution available
https://forum.qt.io/topic/159350/qt-6-8-0-replacement-for-qtnative-activity?_=1731299112565Thanks in advance.
- What went wrong:
-
@Parvathy2020 What Android SDK and NDK versions do you use?
-
Hi @jsulm , This is my build configuration
{
"appname": "xxx_android",
"registername": "xxx",
"config": "release",
"buildspec": "android-clang",
"qtpath": "C:/Qt/6.8.0/android_arm64_v8a",
"qmakepath": "C:/Qt/6.8.0/mingw_64/bin",
"makepath": "C:/Qt/Tools/mingw1120_64/bin",
"clangpath": "C:Qt/Tools/QtCreator/bin/clang/bin",
"cmakepath": "C:/Qt/Tools/CMake_64/bin",
"ninjapath": "C:/Qt/Tools/Ninja",
"generator": "Ninja",
"makecmd": "ninja",
"java_home": "C:/android/jdk-17.0.13+11",
"android_abi": "arm64-v8a",
"android_home": "C:/android/android_sdk",
"android_sdk_root": "C:/android/android_sdk",
"android_ndk_root": "C:/android/android-ndk-r26",
"android_ndk_host": "windows-x86_64",
"android_ndk_platform": "26",
"android_ndk_toolchain": "C:/android/android-ndk-r26/build/cmake/android.toolchain.cmake",
"android_ndk_toolchain_prefix": "arm-linux-androideabi",
"android_ndk_toolchain_version": "4.9",
"android_ndk_tools_prefix": "arm-linux-androideabi"
}Hi @jsulm Is there any change required in sdk or ndk version for resolving the issue ? Can you please support.
-
@Parvathy2020 Compare your dependencies with https://doc.qt.io/qt-6.5/android.html
-
Hi @jsulm , Dependencies are updated as per https://doc.qt.io/qt-6/android.html
But still I am getting the same error.Not able to identify what is the root cause of the issue. package v4.x.x;
Please find the source code ,
import org.qtproject.qt.android.QtNative;
import org.qtproject.qt.android.bindings.QtActivity;import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;import android.util.Log;
import androidx.core.content.FileProvider;
import androidx.core.app.ShareCompat;import java.io.File;
import java.nio.file.Path;public class EmailSender extends org.qtproject.qt.android.bindings.QtActivity
{
private static final String TAG = "xxx EmailSender";private static EmailSender m_instance; public EmailSender() { m_instance = this; } /// /// Function to create send mail intent. /// it in an email client. /// \param context application context /// \param recipient mail recipient email address /// \param subject the subject of the email /// \param body email text /// \param attachmentPath path to an attachment file. public static Intent sendMailIntent(Context context, String recipient, String subject, String body, String attachmentPathString, String chooseEmailMEssage) { Log.d(TAG, "sendEmailIntent - begin"); String[] recipients = { recipient }; Intent intent = ShareCompat.IntentBuilder.from(QtNative.activity()).getIntent(); intent.setAction(Intent.ACTION_SEND); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_EMAIL, recipients); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, body); String authority = context.getPackageName() + ".fileprovider"; if (attachmentPathString.length() > 0) { File contentFile = new File(attachmentPathString); try { Uri contentUri = FileProvider.getUriForFile(QtNative.activity(), authority, contentFile); intent.setType("application/gzip"); intent.putExtra(Intent.EXTRA_STREAM, contentUri); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } catch (IllegalArgumentException e) { Log.w(TAG, "sendEmailIntent - unable to share: " + attachmentPathString); Log.w(TAG, "sendEmailIntent : " + e.getMessage()); } } intent.setType("message/rfc822"); Intent.createChooser(intent, chooseEmailMEssage); Log.d(TAG, "sendEmailIntent - end"); return intent; }
}
-
@Parvathy2020 said in qt 6.8 EmailSender + activity() is not public in QtNative + cannot be accessed from outside package:
public class EmailSender extends org.qtproject.qt.android.bindings.QtActivity
thats no longer a valid import in Qt6, QtActivity was removed, afaik.
I was told you have to extend the base activity now a days:
import android.app.Activity; import android.os.Bundle; public class EmailSender extends Activity {
Not sure how accurate that is. I was in the process of transitioning to Qt6 but other projects triggered a priority interrupt and it's on hold right now. My experience is incomplete :(
-