Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 5 Jahren, 3 Monaten
Letzter Beitrag:
vor 5 Jahren, 3 Monaten
Beteiligte Autoren:
Danny Lauwers, Arie, Fabrice Harari, DerekT

Random Android Error

Startbeitrag von DerekT am 25.04.2013 19:06

Application developed in WM17 by a fellow developer.

Mostly app runs fine but occasionally the following fatal error occurs...

Error in initializing WIN_Main process.
Access to an undeclared variable.
In the Java and Android applications, a variable should not be used before its declaration.

I appreciate what the error is saying but this is purely random with some phones being more prone that others.
Debugging the code did not show any errors and thorough testing on a device could not replicate the problem.

Anyone experienced similar or have any ideas


Hi Derek

there is a long thread in the french forum (look for "Accès à une variable non déclarée") but it doesn't seem that there is a definite solution... A few leads are available, though... If google translate is not enough, let me know

Best regards

von Fabrice Harari - am 25.04.2013 19:29
I have the same issue every noww and then.
And cannot get my hands on it either, but did not put much time into it. (my users don't complain ....)

I get the feeling it happens when the user switches between different apps and is trying to get back to ours.
At that time some user click the app in the "most recent list", which is there on some tablets.

Others tap the app-icon again on the desktop (?? is it called desktop, I'm lost because it's getting late here)
Afaik it only happens then, but I;m not sure.

Maybe this helps? If you have some more info, please share.

von Arie - am 25.04.2013 21:24

I have the same problem with my android application. (In WM18)
When testing this I cannot reproduce the problem, but when switching from front to background and back, or like Arie said use the most recent list. The app now and then crashes with this error.

It is in different windows, I guess depending what window was open at the time when the app went to background (??)

I'm beta testing my app at the moment and currently the this error is not a major issue, but I cannot release my app if this error pops-up once in a while because the users only use the application for short periods of time, and they mix applications a-lot.

Hope someone or PC-SOFT can help in fixing this !


von Danny Lauwers - am 26.04.2013 07:59

Re: Random Android Error [Possible workarround?]


I first tried to use a different approach on making a class and using this class only in my small program. Variable is defined in Initializing of the project. This did not help.

I did some crazy thinking and I put in the Project code event

"Move to the foreground"

The following code:


[attachment 319 screen.png]

and guess what !! It seems to work, no more error !!!

Previously I got the error when I pressed the HOME button and then picked the application back from the background application list.

I have tried the same with the InitWindow code in place, switched to other apps, left the phone for a while, unlocked the phone, got the app back from background and everything seems to work OK now ?!

Maybe someone else could try the same, to see if this is a good workaround or if I am just lucky that it works in my app ?


von Danny Lauwers - am 26.04.2013 09:55

Re: Random Android Error [Possible workarround?]

you are using WM18?
I don;t see these events in WM17 :sneg:

von Arie - am 26.04.2013 10:10

Re: Random Android Error [Possible workarround?]


Yes I am using the WM18 (US Beta) !


von Danny Lauwers - am 26.04.2013 10:43

Re: Random Android Error [Possible workarround NOT]


Initial test where positive, and I could not get it to crash. But if your application is at the background for a longer period, in my case more that 30 minutes (It would probably depend on the Phone and memory and what you do in the meantime with your Phone etc...). I got the same error again...

So :mad: and :sneg: and :hot: and :confused:

Anybody an other solutions .... :( please ?


von Danny Lauwers - am 26.04.2013 19:06

Re: Random Android Error [Possible workarround NOT]

Hi everybody

not from personal experience... From the french wm forum.

It looks like replacing project global variable by variable global to each window (and of course passing values as parameters) solves the problem in some case...

This would mean that the context of the CURRENT window is preserved but not the gloal context of the application...

If some of you can confirm that, that would mean that the development philosophy would have to be very "awp like", with each window begin able to function alone.

Let us know

von Fabrice Harari - am 02.05.2013 12:22

Re: Random Android Error [Possible workarround]

Hi All,

I have created a workarround. The problem seems to be that the application is removed from memory or is set in a sleep mode, I don't know how it is correctly called in the Android world.

So I created a dummy persistent Thread (WinDev Mobile 18 Only !) to keep the application alive, always. And sinds I have done this, I can put my application to the background, work on other things all day, get my application back to the front and no error is displayed and the application works correctly.

Of course there is a drawback that the application will consume memory even if not used. But its a workarround to get rid of the error.

In INITIALIZING Project code

gbExitProgam is boolean = False

// Start Presistent Thread
gNotif is Notification
gNotif..Title = "My Title"

When CLOSING Project code


And the Global Procedure "DummyFunction"

PROCEDURE DummyFunction()
bAlive is boolean = True
WHILE bAlive
IF gbExitProgam THEN bAlive = False

Maybe the code is not optimal, I am still a newbie in WXDev so If you have remarks, just let them know !

If you use this code, and its a good workarround for you, let us know in this forum so others can benefit from it also.

Happy Coding

von Danny Lauwers - am 22.05.2013 07:53
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.