Android Question Version 2.02 to 2.71 will not run program...

Everest

Member
Licensed User
Longtime User
Hello,

Late last year I started on a program. It was executing without error and I was adding the needed code to meet the design goal.

I had to work on some other stuff so it was set to the side. I am now back on it.

I updated the IDE to 2.71 and the latest Android SDK 4.4. I did not make any changes to the code. I selected compile and run, it complied without error, downloaded and failed.

java.lang.NullPointerException on the first line of code in the Activity_Create for the main activity.

I commented out that line and it failed on the next line.
Seems as if some required setup is missing that was not need in 2.0.2 and is needed in 2.71.

Anyone have any ideas?

Thanks,

Mark
 

Everest

Member
Licensed User
Longtime User
Hello,

I updated to version 3.0 and now the error is reported as:

java.lang.NullPointerException: expected receiver of type anywheresoftware.b4a.audio.Beeper, but got null

Ideas?

Mark
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Some of the error checking was tightened up in the newer versions of B4A, so it might just be that it is a fault that wasn't apparent is now being reported.
 
Upvote 0

Everest

Member
Licensed User
Longtime User
Hello,

I have this in a class:

Sub
Class_Globals
Dim regularBeeper As Beeper
End Sub

I call this as a setup:

regularBeeper.Initialize(100,900)

and it gives the error in the above post.

The value is indeed null but, I do not know why.

Ideas?

Thanks,

Mark
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
Where are you initializing the beeper? , the class? the activity? where? you have to post the code of the whole procedure

So far the code looks ok and should work, if is not working for you, then you are doing something wrong.
 
Upvote 0

Everest

Member
Licensed User
Longtime User
Hello,

>Where are you initializing the beeper? the class?

Right.

Public Sub Initialize
regularBeeper.Initialize(100,900)
End Sub

> you have to post the code of the whole procedure

The program is large so posting the whole thing is not pratical.

The program is crashing in the first lines.

Sub Activity_Create(FirstTime As Boolean)

has as the first line, the call to the class Initialize (above sub).

Mark
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
If you are creating the beeper in the Class you have to initialize it when you initialize the class (which I thing you are doing) BUT, you won't be able to use it UNLESS you call <your_class>.Initialize
 
Upvote 0

Everest

Member
Licensed User
Longtime User
Hello,

NJDude, thanks for the responses. Yes I call the class initialize and it calls the beeper initialize.

I found the problem, well I found a solution.

In Sub Activity_Create(FirstTime As Boolean)

I now have:

If FirstTime Then
CF.Initialize

(CF.Initialize is the class that has the beeper.)

And it does not crash.

Not sure why. It has been a year since I have been in this language/IDE.

I have this line in my code:

Dim CF As CommonFunctions 'I had to make this a class because version 2.0.2 has a bug that does not allow code modules.

I remember verfiying it was a bug with Erel a year ago in these forums. Is it still a bug?

Mark
 
Upvote 0

Everest

Member
Licensed User
Longtime User
Hello,

Right. I understand what the FirstTime flag is and the code. What I do not understand is why it fixed the issue?

I put a breakpoint in the first line of main Activity_Create, CF.Initialize, and stepped through the code. Unless Activity_Create was called outside the debuggers scope then the if statement should not have made any difference.

Mark
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…