Android Question [SOLVED] B4A 8.0 broke all of my apps

techknight

Well-Known Member
Licensed User
Longtime User
Not sure what exact change happened, but now all of my Apps are broken. None of my apps are for the play store, they are meant to be installed directly on the device because they are highly proprietary to the environment at which they are used.

But now, I keep getting this error:

java.lang.RuntimeException: Cannot change properties after call to SetInfo. Initialize the notification again.

Here is my code which has always worked in the past:

B4X:
    sNotif.Initialize
    sNotif.Icon = "icon"
    ClockTimer.Initialize("ClockTimer", 99)
    ClockStopped = True
    ClockTimer.Enabled = False
    HornTimer.Initialize("HornTimer", 100)
    HornTimer.Enabled = False
    sNotif.SetInfo("","",Main)
    sNotif.Sound = False
    sNotif.Notify(1)
    Service.StartForeground(1,sNotif)

How do I fix this? or is there a workaround? I have 80+ apps I now have to go through 1 by 1.

I am not using notifications at all, but I remember reading in the past about Sticky services and this was required to make a service stick. I have had android kill my services in the past with the app still open, causing the app to crash. Doing this fixed it.
 

JordiCP

Expert
Licensed User
Longtime User
From Erel's post regarding B4A 8.0
  • Notification object rewritten to work with targetSdkVersion 26. In most cases you don't need to change anything. Notification.SetInfo or Notification.SetInfo2 should be the last calls before you show the notification.
So it seems (not tested) that this ought to work?
B4X:
    sNotif.Initialize
    sNotif.Icon = "icon"
    ClockTimer.Initialize("ClockTimer", 99)
    ClockStopped = True
    ClockTimer.Enabled = False
    HornTimer.Initialize("HornTimer", 100)
    HornTimer.Enabled = False
    sNotif.Sound = False
    sNotif.SetInfo("","",Main)   '(to be tested) Only needed to move this line here?  
    sNotif.Notify(1)
    Service.StartForeground(1,sNotif)
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Try reading here:
https://www.b4x.com/android/forum/threads/b4a-v8-0-has-been-released.90828/

There is a note about notifications:
Backward compatibility notes
  • Notification.SetInfo or SetInfo2 should be the last calls before you use the notification. Note that standard notifications created with previous versions of B4A will not work at all on Android 8+ when targetSdkVersion is 26+.
Hope it can help.


JordiCP was faster and better. ;)
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
I fully understand Erel to rewrite some methods to work in the future. Of course some of the used code has to be changed by all of us like using runtime permissions.

But this is how a good support works. And to be honest: The "sticky service thing" was always "under attack" by Google. Now Oreo does it again. Android 9 will for sure bring new "features" which needs some code updating. Not a big thing. Just change it.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
As a side note, You are/were not forced to update to V8. You could have gone the "Keep both v7.80 and V8" route, and separately manage OLD vs new projects...

So complaining about a new feature that will help everyone in a very near future, is like when the firsts security belts for cars showed up... many didn't like to use them, some still do, but they have become mandatory! because they can save your life! same goes with B4A v8
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
As explained here: [B4X] Backward Compatibility
Source code backward compatibility has the top priority. However the case here with notification is special:

1. You will soon be forced by Google to set the targetSdkVersion to 26+
2. Once you do it your current code, compiled with any version prior to B4A v8.0 will cause the app to crash on Android 8+ devices.

So the notification implementation was rewritten completely with best efforts to maintain backward compatibility. The only limitation is that the call to SetInfo should be the last call.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
I have my apps running on my phone which is Android 8.1 and none of my apps are crashing when compiled with earlier versions of B4A so I am not quite sure I understand that statement, unless you mean once the source code is opened with 8.0, it cant be recompiled again with an older B4A?
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
As a side note, You are/were not forced to update to V8. You could have gone the "Keep both v7.80 and V8" route, and separately manage OLD vs new projects...

When an update comes out, I am going to update. its just the nature of the beast, right? Its just painful that one piece of the puzzle is broken so I have to go through and spend hours reworking code and fixing it. BUT thats my problem and nobody elses, and I guess its just the nature of the game if you wanna play. Right? I am lazy, I admit it. But again thats not yalls problem.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
As written in my signature, all Android developers should read this tutorial:
android.jar / targetSdkVersion / minSdkVersion

The question or issue raised in this thread is explained in the release notes: B4A v8.0 has been released!

The reasoning behind it is explained in post #7.
And as I wrote in that post:

1. You will soon be forced by Google to set the targetSdkVersion to 26+
2. Once you do it your current code, compiled with any version prior to B4A v8.0 will cause the app to crash on Android 8+ devices.

If you have any other question then please start a new thread. However make sure to first read the above tutorial and release notes.
 
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
When an update comes out, I am going to update. its just the nature of the beast, right? Its just painful that one piece of the puzzle is broken so I have to go through and spend hours reworking code and fixing it. BUT thats my problem and nobody elses, and I guess its just the nature of the game if you wanna play. Right? I am lazy, I admit it. But again thats not yalls problem.

Google will force you to update ALL your apps any way. Now with B4A 8 you can start updating them instead of doing all at once when the deadline arrives.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
Yea possibly. But I dont use the play store. Only way they can force that is if they change the rules in the android runtime itself.
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
Google will force you to update ALL your apps any way. Now with B4A 8 you can start updating them instead of doing all at once when the deadline arrives.

I continue to see seemingly conflicting information about the requirements for existing apps after November 2018.

This is a quote from Erel's tutorial thread in December 2017:
No. Quoting Google's blog:
This will be required for new apps in August 2018, and for updates to existing apps in November 2018.

At this point it only affects updates to existing apps. So as long as an existing app is not updated it will continue to run without this restriction.

Has this information changed?

I plan to do any upgrades to existing apps well before November 2018 – they will never be updated after that. They will all have TargetSDKVersion below 26 (probably around 19)

I am hoping these apps will continue to work in all current and future versions of Android (including 8+) without restriction.

Is this true?

Barry.
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
When an update comes out, I am going to update. its just the nature of the beast, right? Its just painful that one piece of the puzzle is broken so I have to go through and spend hours reworking code and fixing it. BUT thats my problem and nobody elses, and I guess its just the nature of the game if you wanna play. Right? I am lazy, I admit it. But again thats not yalls problem.

Not sure about this. You should check compatibility issues before doing an update. If you had a desktop PC with windows XP and Office 2010 and try to update to office 2013 when it came out, you won't be blaming microsoft for the new office version not running in your system.
 
Upvote 0
Top