Java Question NoSuchMethodError: no Direct Method

barx

Well-Known Member
Licensed User
Longtime User
Pulling my hair out here:

Updating NotificationBuilder Lib.

Existing lib code was like this

B4X:
        setObject(new NotificationCompat.Builder(ba.context));
When I run this version on Oreo (26) I get the error of not having a channel ID

Latest version of support lib deprecates NotificationCompat.Builder(Context) and now uses NotificationCompat.Builder(Context, String) to allow you to pass a channel ID as a string.

So, following the docs I simply change my code to

B4X:
private static String CHANNEL_ID = "Default";
...
...
...
setObject(new NotificationCompat.Builder(ba.context, CHANNEL_ID));

When I run this in b4a I get the following error


NotificationBuilder.java: Line 91 is the changed line.

Been at it a while now, cannot figure it out.

Using:

b4a - 7.80
support repo - 47

Any Ideas?
 

DonManfred

Expert
Licensed User
Longtime User
The Builder itself does not have a second parameter.
Create the builder and set the Channel with the responsive method.

Something like
B4X:
setObject(new NotificationCompat.Builder(ba.context));
getObject().setChannel(my_channel);

You can make this configureable by the developer. Use the one the Developer prefer.
 

barx

Well-Known Member
Licensed User
Longtime User

barx

Well-Known Member
Licensed User
Longtime User
It's strange. I would also guess the useof out of date dependancies but as far as I can tell all is newest.

Android Studio Project is set to

compileSdkVersion 27
buildToolsVersion '27.0.1'

defaultConfig {
minSdkVersion 16
targetSdkVersion 27
compile 'com.android.support:support-v4:27.0.2'

Library code states

@DependsOn(values = {"com.android.support:support-v4", "NotificationBuilder.aar"})
Does a version need stating here, only ever seen it done like this.
 

DonManfred

Expert
Licensed User
Longtime User

barx

Well-Known Member
Licensed User
Longtime User

I am using b4a 7.8, installed today. Using built in manager.

path set to 'D:\Current\Android\sdk\platforms\android-27\android.jar'

Check additional and b4a libs folders for old support lib files.

Project cleaned scrubbed and polished both in AS and b4a. Maybe I will uninstall everything and try again.
 

barx

Well-Known Member
Licensed User
Longtime User
No idea what I have done but it appears to be working.......

for now.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…