Problem
Hi, I'm creating an Android and iOS module for Titanium which has a sendLog method which sends some arbitrary JSON data to a server and returns an URL if it matches some predefined filters. The URL should be opened in a modal Dialog with a webview.
I've written native iOS and Android libraries and wrapped them as Titanium modules. On iOS everything works fine but on Android I can't open the Dialog (see error stack trace below). Right now there's one log message that always triggers the same webpage for testing purposes. On Android it just fails silently.
Test case
var mupets = require("be.iminds.mupets");
mupets.initialize("wappr", "http://tocker.iminds.be:3000/log/report.json", 1, 100, 3);
var esmLog = {
bar: "foo"
};
mupets.sendLog("es-test-01",JSON.stringify(esmLog));
After this piece of code (after about 10 seconds max), the module should show a native dialog with the following webpage inside:
http://tocker.iminds.be:3000/es/sheets/test-01/index.html
Instead, this is the error I get consistently:
Logs
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1411)
at android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1429)
at android.app.BackStackRecord.commitInternal(BackStackRecord.java:687)
at android.app.BackStackRecord.commit(BackStackRecord.java:663)
at android.app.DialogFragment.show(DialogFragment.java:256)
at be.iminds.mupets_client_android.logging.plugins.OutHttp.getEsm(OutHttp.java:122)
at be.iminds.mupets_client_android.logging.plugins.OutHttp$1.success(OutHttp.java:78)
at be.iminds.mupets_client_android.HttpClient$1$1.onResponse(HttpClient.java:76)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Here is the Android code that's causing the error:
Activity activity = (Activity) context;
EsmDialogFragment esmDialogFragment = EsmDialogFragment.newInstance(new EsmDialogListener() {
@Override
public void submit(String type, JsonObject result) {
Mupets.sendLog(type, result);
esmShown = false;
}
@Override
public void onCancel(JsonObject cancelled) {
super.onCancel(cancelled);
Mupets.sendLog("ESM_cancelled", cancelled);
esmShown = false;
}
}, url, true);
FragmentTransaction transaction = activity.getFragmentManager().beginTransaction();
Fragment prev = activity.getFragmentManager().findFragmentByTag(EsmDialogFragment.ESM_DIALOG_FRAGMENT);
if (prev != null) {
transaction.remove(prev);
}
transaction.addToBackStack(null);
Log.v(TAG, "Pre-show fragment");
esmDialogFragment.show(transaction, EsmDialogFragment.ESM_DIALOG_FRAGMENT);
Log.v(TAG, "Post-show fragment");
Does Titanium either not allow the use of Fragments/or require you to call Dialog.show() at a specific point? The error talks about "...after onSaveInstanceState" but I don't see how I would call it before onSaveInstanceState if I'm not creating an activity and why the code works when I use it in a native Android app. I added the Android module and iOS module I use to this ticket.
Hello [~Ventis], Thanks for reaching out. I did install the android module you provided but it is not recognized by accelerator studio although install was successful. Will you please make sure that you provide the right file and it works. Thanks in advance
Hi Nazmus Salahin, I'm using this module in my project and it's recognized fine. Can you tell me what the problem exactly is? Kind regards, David
Dear David, The module is not recognized by tiapp.xml. Plsease let me know min SDK version for using the module and which SDK version did you use for build ? Regards
Hi, the minSDK for the module is 5.2.0.GA and the SDK I used is 5.2.2.GA.
I have a test project with the module that I could give you but it's 11MB which is larger than the max file size on this ticket.
Here's a link to the test project I mentioned earlier: https://www.dropbox.com/s/0v77xd5gllv6kb3/testModule.zip?dl=1
Hello, The example project you have set it also not configuring your module, in our environment. Importing your project into our studio is not showing the module configured in our environment. We are using SDK 5.2.2.GA for test. It's necessary for us to test the issue. Regards, Sharif.
I created this example project specially for this ticket in a completely new environment and it works fine. I don't understand the problems you are having with it. I'm using 5.2.2.GA just like you... The module I provided is just the output of a normal Titanium module project. The example project is a Titanium mobile project I zipped myself. Please tell me the necessary steps I need to perform so it will work for you.
Hello, Here is what happening in my environment. The module is not recognised by tiapp.xml but the projects runs. [Screenshot Link](https://i.imgsafe.org/6e7b08d.png) When I run the given code portion the app crash with a different error log. *Code:*
*Error Log:*
*Environment*: *Device info:* Nexus7 (android 6.0.1) *Node.js Version:* 0.12.7 *npm Version:* 2.11.3 *Titanium SDKs:* 5.2.2.GA *Java Development Kit Version:* 1.8.0_73 *Titanium CLI Version:* 5.0.5 *Appcelerator CLI Version:* 5.2.2 *Appcelerator Studio:* 4.5.0
That seems to happen because my library has a dependency on com.android.support:appcompat-v7:23.3.0 but I can't add it as a dependency because then I get the following errors:
Any ideas what this error message means?
Any update?
Closing issue as “Cannot Reproduce”. We have tested the code provided, and found that it is out of date with our current release (8.2.0.GA as of the date of closure), and out of date with mobile OS versions. Updating the code may not reproduce the issue reported, or be a valid test case. If community members feel that the issue is still valid, please add a comment, and include code that demonstrates/reproduces the issue. Axway Appcelerator Studio, build: 5.1.4.201909061933 macOS : 10.15 Node.js Version : 8.9.1 npm Version : 5.5.1 Appcelerator CLI : 7.1.1 Titanium CLI CLI Version : 5.2.1 node-appc Version : 0.2.49 Titanium SDKs : 8.2.0.GA Pixel 3 Android API 29