Unable to start the app with Accessory service

I used the sample app and the documentation file (ProgrammingGuide_Accessory_v2.6.4.pdf) to create my Android app. The big difference is that in my case it is a Xamarin application but it should be a little difference. I don’t understand why Galaxy Accessory gets into endless loop with a fatal error. The log shows it:

01-31 18:20:23.166 I/[SA_SDK]SASdkConfig(27195): Accessory Framework:3.1.94.10805 Accessory SDK:2.6.0 r6
01-31 18:20:23.167 D/[SA_SDK]SAAgentV2(27195): SAAgentV2 - initialize:DataProviderService
01-31 18:20:23.170 D/[SA_SDK]SAGSIMLog(27195): init()
01-31 18:20:23.170 D/[SA_SDK]SAGSIMLog(27195): [SecFloating] feature is not supported (non-samsung device)
01-31 18:20:23.170 D/[SA_SDK]SAGSIMLog(27195): [SecFloating] floating feature : true
01-31 18:20:23.171 D/[SA_SDK]SAGSIMLog(27195): Could not find ContextProvider
01-31 18:20:23.171 I/[SA_SDK]SASdkConfig(27195): Accessory Framework:3.1.94.10805 Accessory SDK:2.6.0 r6
01-31 18:20:23.172 D/[SA_SDK]SA(27195): Initializing SA
01-31 18:20:23.177 D/[SA_SDK]SAAdapter(27195): Agent callback added. Current size - 1
01-31 18:20:23.177 I/[SA_SDK]c(27195): Parse Accssory Service profile xml file
01-31 18:20:23.178 I/[SA_SDK]ServiceXmlReader(27195): Service description(s) file Location:/res/xml/accessory_services.xml
01-31 18:20:23.178 D/[SA_SDK]ServiceXmlReader(27195): Fetching xml from /res/xml
01-31 18:20:23.178 V/[SA_SDK]ServiceXmlReader(27195): Start document
01-31 18:20:23.179 V/[SA_SDK]ServiceXmlReader(27195): Start document
01-31 18:20:23.181 D/[SA_SDK]SAGSIMLog(27195): Could not find ContextProvider
01-31 18:20:23.181 V/[SA_SDK]c(27195): Start document
01-31 18:20:23.182 I/[SA_SDK]c(27195): End document
01-31 18:20:23.182 E/[SA_SDK]c(27195): fetchServicesDescription: Class not found in registered listcrc646826f8d756ce5e4a.DataProviderService
01-31 18:20:23.182 E/[SA_SDK]SAAgentV2(27195): fetch service profile description failed !!
01-31 18:20:23.182 D/[SA_SDK]SAGSIMLog(27195): Could not find ContextProvider
01-31 18:20:23.192 I/[SA_SDK]SAAdapter(27195): getDefaultAdapter: About start waiting
01-31 18:20:33.237 I/[SA_SDK]SAAdapter(27195): getDefaultAdapter: About start waiting
01-31 18:20:40.691 D/[SA_SDK]SAGSIMLog(27195): Could not find ContextProvider
01-31 18:20:40.695 I/[SA_SDK]SASdkConfig(27195): Accessory Framework:3.1.94.10805 Accessory SDK:2.6.0 r6
01-31 18:20:40.697 D/[SA_SDK]SA(27195): Initializing SA
01-31 18:20:43.257 I/[SA_SDK]SAAdapter(27195): getDefaultAdapter: About start waiting
01-31 18:20:49.632 D/[SA_SDK]SAAdapter(27195): Accessory service connected
01-31 18:20:49.645 I/[SA_SDK]SAAdapter(27195): Received Client ID:1526113636
01-31 18:20:49.645 I/[SA_SDK]SAAdapter(27195): Application is now connected to Accessory Framework!
01-31 18:20:49.646 W/[SA_SDK]SAAgentV2(27195): Service record was not found in Accessory Framework.Registering service again!
01-31 18:20:49.648 I/[SA_SDK]ServiceXmlReader(27195): Service description(s) file Location:/res/xml/accessory_services.xml
01-31 18:20:49.654 I/[SA_SDK]SARegistrationTask(27195): Services Registered successfully!
01-31 18:20:49.655 I/[SA_SDK]SAAgentV2(27195): Trying to fetch agent ID after re-registration
01-31 18:20:49.656 E/[SA_SDK]SAAgentV2(27195): Failed to retrieve service record after re-registration
01-31 18:20:49.656 E/[SA_SDK]SAAgentV2(27195): com.samsung.android.sdk.accessory.d: Failed to fetch localAgent ID
01-31 18:20:49.656 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAdapter.a(Unknown Source:65)
01-31 18:20:49.656 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAgentV2.i(Unknown Source:12)
01-31 18:20:49.656 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAgentV2.f(Unknown Source:0)
01-31 18:20:49.656 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAgentV2.a(Unknown Source:12)
01-31 18:20:49.656 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAgentV2$b.handleMessage(Unknown Source:296)
01-31 18:20:49.656 E/[SA_SDK]SAAgentV2(27195): at android.os.Handler.dispatchMessage(Handler.java:107)
01-31 18:20:49.656 E/[SA_SDK]SAAgentV2(27195): at android.os.Looper.loop(Looper.java:237)
01-31 18:20:49.656 E/[SA_SDK]SAAgentV2(27195): at android.os.HandlerThread.run(HandlerThread.java:67)
01-31 18:20:49.768 E/[SA_SDK]SAAgentV2(27195): ACCEPT_STATE_ERROR: 2048: Samsung Accessory Framework has died!! PeerAgent: null
01-31 18:20:49.768 I/[SA_SDK]SAAgentV2(27195): onError() → ERROR_FATAL
01-31 18:20:49.769 W/[SA_SDK]SAAgentV2(27195): Service record was not found in Accessory Framework.Registering service again!
01-31 18:20:49.775 I/[SA_SDK]ServiceXmlReader(27195): Service description(s) file Location:/res/xml/accessory_services.xml
01-31 18:20:49.780 I/[SA_SDK]SARegistrationTask(27195): Services Registered successfully!
01-31 18:20:49.781 I/[SA_SDK]SAAgentV2(27195): Trying to fetch agent ID after re-registration
01-31 18:20:49.782 E/[SA_SDK]SAAgentV2(27195): Failed to retrieve service record after re-registration
01-31 18:20:49.782 E/[SA_SDK]SAAgentV2(27195): com.samsung.android.sdk.accessory.d: Failed to fetch localAgent ID
01-31 18:20:49.782 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAdapter.a(Unknown Source:65)
01-31 18:20:49.782 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAgentV2.i(Unknown Source:12)
01-31 18:20:49.782 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAgentV2.f(Unknown Source:0)
01-31 18:20:49.782 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAgentV2.e(Unknown Source:0)
01-31 18:20:49.782 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAgentV2$b.handleMessage(Unknown Source:35)
01-31 18:20:49.782 E/[SA_SDK]SAAgentV2(27195): at android.os.Handler.dispatchMessage(Handler.java:107)
01-31 18:20:49.782 E/[SA_SDK]SAAgentV2(27195): at android.os.Looper.loop(Looper.java:237)
01-31 18:20:49.782 E/[SA_SDK]SAAgentV2(27195): at android.os.HandlerThread.run(HandlerThread.java:67)
01-31 18:20:49.783 E/[SA_SDK]SAAgentV2(27195): ACCEPT_STATE_ERROR: 2048: Samsung Accessory Framework has died!! PeerAgent: null
01-31 18:20:49.783 I/[SA_SDK]SAAgentV2(27195): onError() → ERROR_FATAL
01-31 18:20:49.786 W/[SA_SDK]SAAgentV2(27195): Service record was not found in Accessory Framework.Registering service again!
01-31 18:20:49.789 I/[SA_SDK]ServiceXmlReader(27195): Service description(s) file Location:/res/xml/accessory_services.xml
01-31 18:20:49.794 I/[SA_SDK]SARegistrationTask(27195): Services Registered successfully!
01-31 18:20:49.794 I/[SA_SDK]SAAgentV2(27195): Trying to fetch agent ID after re-registration
01-31 18:20:49.796 E/[SA_SDK]SAAgentV2(27195): Failed to retrieve service record after re-registration
01-31 18:20:49.796 E/[SA_SDK]SAAgentV2(27195): com.samsung.android.sdk.accessory.d: Failed to fetch localAgent ID
01-31 18:20:49.796 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAdapter.a(Unknown Source:65)
01-31 18:20:49.796 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAgentV2.i(Unknown Source:12)
01-31 18:20:49.796 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAgentV2.f(Unknown Source:0)
01-31 18:20:49.796 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAgentV2.e(Unknown Source:0)
01-31 18:20:49.796 E/[SA_SDK]SAAgentV2(27195): at com.samsung.android.sdk.accessory.SAAgentV2$b.handleMessage(Unknown Source:35)
01-31 18:20:49.796 E/[SA_SDK]SAAgentV2(27195): at android.os.Handler.dispatchMessage(Handler.java:107)
01-31 18:20:49.796 E/[SA_SDK]SAAgentV2(27195): at android.os.Looper.loop(Looper.java:237)
01-31 18:20:49.796 E/[SA_SDK]SAAgentV2(27195): at android.os.HandlerThread.run(HandlerThread.java:67)
01-31 18:20:49.796 E/[SA_SDK]SAAgentV2(27195): ACCEPT_STATE_ERROR: 2048: Samsung Accessory Framework has died!! PeerAgent: null
01-31 18:20:49.796 I/[SA_SDK]SAAgentV2(27195): onError() → ERROR_FATAL
01-31 18:20:49.797 W/[SA_SDK]SAAgentV2(27195): Service record was not found in Accessory Framework.Registering service again!

What all that means? What am I missing? What is “Service record was not found in Accessory Framework”?

Hello @kuc1597989013 ,
We are very sorry to hear about your inconvenience. Samsung Accessory Protocol (SAP) SDK only works on supported Samsung Galaxy devices. Based on the 4th line of the log shared:

it seems like you are trying to run your SAP SDK powered application on a non-Samsung phone. We would like to request you to run your app on a Samsung Device and share the following if you are still facing issues:

  1. Device Model Number
  2. SAP SDK version
  3. Software Version
  4. Error logs

Best Regards,
Shuvo
Samsung Developer Program

I, actually, figured out what was the problem. The line you mentioned has nothing to do with that. The main problem is stated on this line

01-31 18:20:23.182 E/[SA_SDK]c(27195): fetchServicesDescription: Class not found in registered listcrc646826f8d756ce5e4a.DataProviderService

The class name registered in the /res/xml/accessory_services.xml didn’t match the class name in the code.

There is one thing that surprised me in your response. Do you mean that SAP will not work on other phones but Samsung? I thought that the Samsung Watch can work, can connect to any Android phone and I assumed that SAP should work on any Android phone allowing the watch to communicate to the provider running on the phone. If it is not true how can I create the communication channel lets say between LG Android phone and the Samsung Watch (Gear S3)?