Android Question strange behavior in release mode

markcasio

Member
Licensed User
Longtime User
Hi, I have a question , what can cause a local variable in a sub to change it's value randomly.
The local var is not double used as a global var, and is only used in sub part1.

B4X:
sub part1
Dim k1,k2,k3,k6,k7,k8,k9,k10,k11,k12,k13 As Int '<=== local vars
k12 = 1234
 Log("k12 ="&k12) '<===== always gives 1234
anothersub '<== calling another sub
 Log("k12 ="&k12) '<===== always 1234 in debug but in release mode i somethimes get 357302632
end sub

What can cause a local variable to change it's value only in release mode.?
 

markcasio

Member
Licensed User
Longtime User
Results of test and result from Manufacturer.

We have tested the same application using android studio without problems on the same hardware.
There were no other issues the manufacturer knew of with other applications on their hardware.
The cpu and memory test are ok on all machines. (i received a hardware test and burnin application)
Maybe their is a format compatibility problem between b4a and their hardware.
The problem occurs when you convert a string to an integer value. (as shown before)
The problem is gone when you use long variables instead of integer.
The problem is gone when you first convert from a string to an integer value and then redefine the value to a numeric value using numberformat. (code below)
Could it be that , when you convert a string value to an integer value it is stored in an other format than a real numeric integer? (confusing a garbage collector?)
When i redefine the converted integer value from string to a 'real' integer value before the sub, it works, i think the format must be different.



B4X:
Sub problem
    Dim myvar  As Int
    Dim g As String
    g = "01"
     myvar  = g.SubString2(0,2)
    myvar = NumberFormat2(myvar,1,0,0,False)  '<=== redifining the integer value after string converting solves the problem
    Log("G string value = "&g)
    Log("Local int myvar = "&myvar )
.....
'_myvar = (int)(Double.parseDouble(_g.substring((int) (0),(int) (2))));
'_myvar = (int)(Double.parseDouble(anywheresoftware.b4a.keywords.Common.NumberFormat2(_myvar,(int) (1),(int) (0),(int) <== '(0),anywheresoftware.b4a.keywords.Common.False)));
 
Last edited:
Upvote 0

markcasio

Member
Licensed User
Longtime User
I compiled the b4a java code using android studio, the generated apk works without errors.
So there is a difference between android studio and b4a on how they generate the apk using Android SDK.
And this would be this dexer tool , is there something i can modify and try?
 
Upvote 0

markcasio

Member
Licensed User
Longtime User
Ok, thank you, If I can help to test something please let me know.
I'm now looking into a way to generate the apk using command line .
The manufacturer is also testing and trying to find the problem in the android build, to avoid this compatibility issue in the future.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…