How to fix a “bad primaryPhy 2” error when “LE 2M PHY” is supported on my android phone?

I am building a bluetooth low energy advertiser just to explore and learn more about BLE technology and I have this error when I launch the app “FATAL EXCEPTION: main
Process: com.example.bleapp, java.lang.RuntimeException: Unable to start activity: java.lang.IllegalArgumentException: bad primaryPhy 2”.

I am pretty sure this is the section that is causing problems

val advertisingSetParametersUltraLowPower = AdvertisingSetParameters.Builder().apply {
                setInterval(AdvertisingSetParameters.INTERVAL_HIGH)
                setTxPowerLevel(AdvertisingSetParameters.TX_POWER_ULTRA_LOW)
                setConnectable(false)
                setScannable(true)
                setIncludeTxPower(true)
                setLegacyMode(false)
                if (bluetoothAdapter?.isLe2MPhySupported() == true) {
                     setPrimaryPhy(PHY_LE_2M)
                } else {
                     setPrimaryPhy(PHY_LE_1M) }
                }
                .build()

if (bluetoothAdapter!!.isLe2MPhySupported()) {
                Text(text = "BLueTooth version = 5")
                Button(onClick = {
                if (bluetoothAdapter?.bluetoothLeAdvertiser != null) {
                      bluetoothAdapter!!.bluetoothLeAdvertiser!!.startAdvertisingSet(
                              advertisingSetParametersUltraLowPower,
                              advertiseExtendedData,
                              advertiseScanResponseData,
                              periodicAdvertisingParameters,
                              periodicData,
                              advertisingSetCallback)
                              }
                       }) {
                           Text(text = "Ultra Low Pow")
                       }

I have been told that maybe my phone doesn’t have all the Le2MPhy capabilities but I have checked and from my understanding i shouldn’t have a problem because I have if statement to check the different Le2MPHY characteristics of my phone and they are all supported. Here is the code that I use to check for Le2MPHY

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                val isLe2MPhySupported = bluetoothAdapter!!.isLe2MPhySupported()
                val isLeCodedPhySupported = bluetoothAdapter!!.isLeCodedPhySupported()
                val isLeExtendedAdvertisingSupported = bluetoothAdapter!!.isLeExtendedAdvertisingSupported()
                val isLePeriodicAdvertisingSupported = bluetoothAdapter!!.isLePeriodicAdvertisingSupported()

                if (isLe2MPhySupported) {
                    Log.i("tag", "LE 2M PHY is supported.")
                } else {
                    Log.i("tag", "LE 2M PHY is not supported on this device.")
                }
                if (isLeCodedPhySupported) {
                    Log.i("tag", "Le Coded Phy is supported.")
                } else {
                    Log.i("tag", "Le Coded Phy is not supported on this device.")
                }
                if (isLeExtendedAdvertisingSupported) {
                    Log.i("tag", "Le Extended Advertising is supported.")
                } else {
                    Log.i("tag", "Le Extended Advertising is not supported on this device.")
                }
                if (isLePeriodicAdvertisingSupported) {
                    Log.i("tag", "Le Periodic Advertising is supported.")
                } else {
                    Log.i("tag", "Le Periodic Advertising is not supported on this device.")
                }
            } else {
                Log.i("tag", "LE 2M PHY is not available on this device (API level below 26).")
            }```
And here are the results of my Log statement:

LE 2M PHY is supported.
Le Coded Phy is supported.
Le Extended Advertising is supported.
Le Periodic Advertising is supported. 

I'm simply expecting that the app starts advertising because the advertisement works fine with this code 

Button(onClick = {
if (bluetoothAdapter?.bluetoothLeAdvertiser != null) {
bluetoothAdapter!!.bluetoothLeAdvertiser!!.startAdvertising(
advertiserSettingsLowPower,
advertiseData,
bleAdvertiserCallback)
}
}) {
Text(text = “Low Power”)
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật