[SOLVED] Crash QtActivity with Qt 5.3
-
Hello,
I install Qt 5.3 and now I have a crash when run my project. It's an Android application with QML and C++, I use the QtActivity to get contacts in the phone.
The error when run my application :
@I/Qt JAVA (29348): DEBUGGER: got pong /data/local/tmp/qt/debug-pong-org.qtproject.example.RDVU
W/dalvikvm(29348): No implementation found for native Lorg/qtproject/qt5/android/QtNative;.handleOrientationChanged:(II)V
W/System.err(29348): java.lang.reflect.InvocationTargetException
W/System.err(29348): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(29348): at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(29348): at org.qtproject.qt5.android.bindings.QtActivity.loadApplication(QtActivity.java:252)
W/System.err(29348): at org.qtproject.qt5.android.bindings.QtActivity.startApp(QtActivity.java:643)
W/System.err(29348): at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:872)
W/System.err(29348): at org.qtproject.example.RDVU.ContactActivity.onCreate(ContactActivity.java:42)
W/System.err(29348): at android.app.Activity.performCreate(Activity.java:5231)
W/System.err(29348): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
W/System.err(29348): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
W/System.err(29348): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
W/System.err(29348): at android.app.ActivityThread.access$800(ActivityThread.java:135)
W/System.err(29348): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
W/System.err(29348): at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(29348): at android.os.Looper.loop(Looper.java:136)
W/System.err(29348): at android.app.ActivityThread.main(ActivityThread.java:5017)
W/System.err(29348): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(29348): at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(29348): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
W/System.err(29348): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
W/System.err(29348): at dalvik.system.NativeStart.main(Native Method)
W/System.err(29348): Caused by: java.lang.UnsatisfiedLinkError: Native method not found: org.qtproject.qt5.android.QtNative.handleOrientationChanged:(II)V
W/System.err(29348): at org.qtproject.qt5.android.QtNative.handleOrientationChanged(Native Method)
W/System.err(29348): at org.qtproject.qt5.android.QtActivityDelegate.onCreate(QtActivityDelegate.java:678)
W/System.err(29348): at org.qtproject.qt5.android.QtActivityDelegate.startApplication(QtActivityDelegate.java:633)
W/System.err(29348): ... 20 more
@The error happens when run onCreate:
@ /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);this.contentResolver = getContentResolver(); Log.d(QtApplication.QtTAG, "Create ContactActivity"); }@
Why since Qt 5.3 my application crash and works well with Qt 5.2 ?
I don't undestand this : Caused by: java.lang.UnsatisfiedLinkError: Native method not found: org.qtproject.qt5.android.QtNative.handleOrientationChanged.
A file is missing in my installation ?Thank you for your help.
-
But did you changed the QtActivity.java source code ?
If yes, that's your problem. You should never change that code, because it may changes from one release to another. -
I have not changed the QtActivity.java source code and I never change the Qt source code.
What modifications in QtActivity between Qt 5.2 and 5.3 ?
-
I don't know what are the changes between 5.2 and 5.3, but it's irrelevant.
What I checked is that neither in Qt 5.2 QtActivity.java and in 5.3 QtActivity.java there is the code you posted above.
And from log you posted, it seems that you didn't create your custom activity.
So, my guessing was that you changed the source code of QtActivity.java.But if you didn't change the code... please, tell us where the java code on the onCreate you posted above come from.
-
The onCreate code come from my java code in my ContactActivity class which inherits of QtActivity and this Activity is declared in my custom AndroidManifest.xml.
The error message says :
No implementation found for native Lorg/qtproject/qt5/android/QtNative;.handleOrientationChanged:(II)VI must implement this method in my java code ?
-
Oh, I'm sorry. I didn't notice that :-( My fault.
No, you don't have to implement that method.
I have my custom activity too with onCreate overridden and the app works fine.So, there is should something weird in your installation and/or in your project configuration.
Try to file a bug report. -
I find my error.
I had modified the generated AndroidManifest.xml file to add several parameters, but this file contains file paths from Qt 5.2 in <meta-data>. I replace this values by this :
@<meta-data android:value="-- %%INSERT_APP_LIB_NAME%% --" android:name="android.app.lib_name"/>
<meta-data android:resource="@array/qt_sources" android:name="android.app.qt_sources_resource_id"/>
<meta-data android:value="default" android:name="android.app.repository"/>
<meta-data android:resource="@array/qt_libs" android:name="android.app.qt_libs_resource_id"/>
<meta-data android:resource="@array/bundled_libs" android:name="android.app.bundled_libs_resource_id"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --" android:name="android.app.bundle_local_qt_libs"/>
<meta-data android:resource="@array/bundled_in_lib" android:name="android.app.bundled_in_lib_resource_id"/>
<meta-data android:resource="@array/bundled_in_assets" android:name="android.app.bundled_in_assets_resource_id"/>
<!-- Run with local libs -->
<meta-data android:value="-- %%USE_LOCAL_QT_LIBS%% --" android:name="android.app.use_local_qt_libs"/>
<meta-data android:value="/data/local/tmp/qt/" android:name="android.app.libs_prefix"/>
<meta-data android:value="-- %%INSERT_LOCAL_LIBS%% --" android:name="android.app.load_local_libs"/>
<meta-data android:value="-- %%INSERT_LOCAL_JARS%% --" android:name="android.app.load_local_jars"/>
<meta-data android:value="-- %%INSERT_INIT_CLASSES%% --" android:name="android.app.static_init_classes"/>
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<!-- Messages maps -->
<!-- Splash screen -->
<meta-data android:name="android.app.splash_screen" android:resource="@layout/splash"/>
<!-- Splash screen -->@Now, I compile with Qt 5.3 and 5.2.
-
I'm facing exactly the same issue: my app crashes on start-up, and the logcat points to handleOrientationChanged, althouth the root cause may be somewhere else.
It appears that upgrading from using Qt 5.2.1 to using Qt 5.3.0 in a Qt on Android project is not automatic. Some code has to be changed, such as the AndroidManifest.xml file.
By contrast, no extra code changes in my Qt on Android project were needed when I upgraded from Qt 5.2.0 to Qt 5.2.1.
Is there some kind of guide on how to port Qt on Android projects from using Qt 5.2.1 to using Qt 5.3.0? Thanks!
-
The following procedure works for me when porting an existing Qt on Android project from Qt 5.2.1 to Qt 5.3.0:
-
Create a simple Qt on Android project in Qt 5.2.1, using Qt Creator for example.
-
Create the same simple Qt on Android project in Qt 5.3.0, using Qt Creator again.
-
Compare the files generated in step 1 and step 2. Get the differences.
-
Implement the differences into the existing Qt on Android project.
Differences have been found especially in file "AndroidManifest.xml" and file "res/values/libs.xml".
-
-