SDK initialization failed! Accessory Framework Not installed

Hi everyone,

I am running the sample companion android app to learn how the SAP SDK works:
AccessorySDK_v2.6.1 from Samsung. Sample: Provider(Tizen)_Consumer(Android).

Everything is working perfectly if I use a real Samsung smartphones to test like my Galaxy S7e, or Galaxy S10. But when I run the sample android app on a non-Samsung emulator, I get the following errors:

E/[SA_SDK]SAGSIMLog: GSIM logging is not enabled.
E/[SA_SDK]SASdkConfig: Accessory Framework Not installed
E/[SA_SDK]SAAgentV2: SDK initialization failed!

View full logs

E/[SA_SDK]SASdkConfig: Accessory Framework Not installed
W/System.err: com.samsung.android.sdk.accessory.d: Accessory Framework Not installed
at com.samsung.android.sdk.accessory.k.(Unknown Source:126)
at com.samsung.android.sdk.accessory.SAAgentV2.e(Unknown Source:6)
at com.samsung.android.sdk.accessory.SAAgentV2.(Unknown Source:101)
at com.samsung.android.sdk.accessory.example.helloaccessory.consumer.ConsumerService.(ConsumerService.java:48)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
W/System.err: at com.samsung.android.sdk.accessory.SAAgentV2$e.handleMessage(Unknown Source:157)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
D/[SA_SDK]SAAgentV2: SAAgentV2 - initialize:ConsumerService
D/[SA_SDK]SAGSIMLog: init()
D/[SA_SDK]SAGSIMLog: [SecFloating] feature is not supported (non-samsung device)
[SecFloating] feature is not supported this device (non-samsung device)
E/[SA_SDK]SAGSIMLog: GSIM logging is not enabled.
E/[SA_SDK]SASdkConfig: Accessory Framework Not installed
E/[SA_SDK]SAAgentV2: SDK initialization failed!
com.samsung.android.sdk.SsdkUnsupportedException: Accessory Framework Not installed
at com.samsung.android.sdk.accessory.SA.initialize(Unknown Source:63)
at com.samsung.android.sdk.accessory.SAAgentV2.e(Unknown Source:122)
at com.samsung.android.sdk.accessory.SAAgentV2.(Unknown Source:101)
at com.samsung.android.sdk.accessory.example.helloaccessory.consumer.ConsumerService.(ConsumerService.java:48)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at com.samsung.android.sdk.accessory.SAAgentV2$e.handleMessage(Unknown Source:157)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/[SA_SDK]SAAgentV2: Samsung Accessory SDK cannot be initialized
E/[SA_SDK]SAAgentV2: ACCEPT_STATE_ERROR: 2049: Samsung Accessory SDK cannot be initialized. Device or Build not compatible. PeerAgent: null
I/[SA_SDK]SAAgentV2: onError() → ERROR_SDK_NOT_INITIALIZED
D/[SA_SDK]SAAdapter: Agent callback added. Current size - 1
E/[SA_SDK]SAAdapter: getDefaultAdapter: Binding to Accessory service failed!
E/[SA_SDK]SAAgentV2: Binding to Accessory Framework failed
com.samsung.android.sdk.accessory.d: Is the Samsung Accessory Service Framework installed?!
at com.samsung.android.sdk.accessory.SAAdapter.a(Unknown Source:108)
at com.samsung.android.sdk.accessory.SAAgentV2.a(Unknown Source:9)
at com.samsung.android.sdk.accessory.SAAgentV2$b.handleMessage(Unknown Source:303)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:67)
ACCEPT_STATE_ERROR: 2048: Samsung Accessory Framework has died!! PeerAgent: null

I tried changing the android versions on the Android emulator but it resulted in the same errors. Because I run the sample app from Samsung, so I don’t think of any reasons from my side. The permissions are fully declared:

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="com.samsung.accessory.permission.ACCESSORY_FRAMEWORK" />
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
<uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION" />
<uses-permission android:name="com.samsung.WATCH_APP_TYPE.Companion"/>

I already checked these libraries: accessory-v2.6.1.jar and sdk-v1.0.0.jar. They are already included in the project:

The code works perfectly on all of my Samsung phones (real devices), it’s just not working on non-Samsung device like my emulator.

My question is: Will Samsung Accessory SDK work with non-Samsung devices? Can you please help me to figure out what’s the problem?

Thanks in advance.

I am stuck on it. Please help me!

Hi, I think you will get solution by using Tech support: https://developer.samsung.com/support

1 Like

You have to install Samsung Accessory Plugin https://play.google.com/store/apps/details?id=com.samsung.accessory

2 Likes

Hi,
Accessory Service Framework comes with normally when you install Samsung Wearable app on Samsung devices.
But non-Samsung devices need a separate app installation which is

As you are trying to install on a non-Samsung emulator, you may give it a try!

Please try after installing it and let us know the result.

Thanks,
Iqbal

2 Likes

Thank you for your replies. My emulator doesn’t have Google Play app. So I tried to install the .apk file of Samsung Accessory Service and I got this error:

Now I get it. Samsung phones have Samsung Accessory Service installed automatically when user connects to a watch from Galaxy warable android app.

So on non-samsung devices (android phones like Huawei, oppo,…), if user install Galaxy wearable and connects to galaxy watch, Samsung Accessory Service will be automatically installed too (by the galaxy wearable). And I don’t need to worry about compatibility on non-samsung devices anymore?
Is that correct?

I asked this because when I tried uninstalling Samsung Accessory Service from my galaxy phone, my watch was disconnected. Then I opened Galaxy wearable and press “connect” again, I found out that Samsung Accessory Service is silently installed.

Thanks in advance.

Yes on Samsung phones, it comes with Samsung Wearable (Gear Manager) app.

1 Like

Thank you! I understand now.

Hi. My popular app (com.wslava.discountwallet) with SAP (Android compainon app) doesn’t work on Android 11!
I have updated SDK to latest AccessorySDK_v2.6.4, but it didn’t help. The phone has a “SsdkUnsupportedException.LIBRARY_NOT_INSTALLED” exception when starting the application. I have tried to compile the latest examples Consumer(Android)_Provider(Tizen),
folder app_SAAgentV2 , but the same error occurs on activity FileTransferActivity

y.

The Samsung Accessory Service is installed.

At the moment I do not have a device with Android 11, but users write to me in support, for example, with the Galaxy S20 and a screenshot of the error “Cannot initialize, LIBRARY_NOT_INSTALLED”

What are the options for solving the problem?

After correspondence with Samsung developers, a solution was found.
If your App targets Android R(30) and interacts with other apps which is installed on the same device, you need to use the “queries” element in the Manifest file so that system knows which other apps to show to your app.
Kindly include the below piece of code (queries section) in the manifest file:
queries
Note that I had to update Android Gradle plugin to version 4.1 in order to compile application.
And now everything works!

1 Like

Wow, great job Samsung (not). How can you guys ignore that your whole accessory service is broken in Android 11? What about providing a hotfix in the SDK or if that’s not possible at least update your (incomplete and outdated) Docs and show how to fix it?? You know that Android 11 is out since MONTHS?! Come on, what the heck Samsung.

@wSlava Thank you for doing Samsungs Job by publishing the solution.

Just registered here to complain about it, if you feel offended by this post just do what you always do and delete my account.

1 Like

Is there any update on that issue? SAAgentV2 works with Android 10 but not with Android 11. Do Samsung developers check this forum?

1 Like

I think Samsung people are way too busy to help other developers with their faulty SDK :slight_smile:

Hey there! If you are a Samsung developer and reading this, please go ahead and try confuting this :slight_smile:

If you need more information see here: tizen - Testing companion application with Emulators? - Stack Overflow

So it turned out that there are not Samsung developers reading this forum :smiley:

I’m facing a similar issue.
When I build the mobile app with debug mode active, the watch can send and receive data from the mobile app. But, when I build the mobile app in release mode I receive the following error:

Is there someone here that faced the same issue? I’m strugling with this for months :’(

2021-08-11 17:21:44.273 1241-3153/? E/[SA_SDK]SARegistrationTask: Registration failed.Unable to connect to Accessory framework!
    com.samsung.android.sdk.accessory.g: Is the Samsung Accessory Service Framework installed?!
        at com.samsung.android.sdk.accessory.a.f(Unknown Source:106)
        at com.samsung.android.sdk.accessory.i$a.a(Unknown Source:10)
        at com.samsung.android.sdk.accessory.i$a.call(Unknown Source:0)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.lang.Thread.run(Thread.java:923)
2021-08-11 17:21:44.274 1241-3152/? E/[SA_SDK]RegisterUponInstallReceiver: Service Registration has failed!
    java.util.concurrent.ExecutionException: com.samsung.android.sdk.accessory.g: Is the Samsung Accessory Service Framework installed?!
        at java.util.concurrent.FutureTask.report(FutureTask.java:123)
        at java.util.concurrent.FutureTask.get(FutureTask.java:193)
        at com.samsung.android.sdk.accessory.RegisterUponInstallReceiver$a.run(Unknown Source:4)
     Caused by: com.samsung.android.sdk.accessory.g: Is the Samsung Accessory Service Framework installed?!
        at com.samsung.android.sdk.accessory.a.f(Unknown Source:106)
        at com.samsung.android.sdk.accessory.i$a.a(Unknown Source:10)
        at com.samsung.android.sdk.accessory.i$a.call(Unknown Source:0)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.lang.Thread.run(Thread.java:923)

Hi!

I’m not related to Samsung at all, but I have read somewhere about differences between debug and release builds: namely, when you build for release, ProGuard rules are coming into picture which obfuscates some required parts of the precompiled SAP libraries on the mobile app which then prevents them registering.

As far as I remember this was written somewhere in SAP documentation’s last chapter (like FAQ, or common problems, or something similar, but I’ve read this long time ago)

Hope this will help you,
Cheers,
Dan

Hi Dan!

Thank you so much for the reply. I found the text you commented. I didn’t tested yet, but at least it’s a little of hope :sweat_smile:.

For anyone else who have interest about this, to find this document, on this page there´s a link for the programming guide, on page 74 there’s a section about Obfuscating The Application Using ProGuard.

Wow, thank you so much! The documentation for Tizen development is the worst I’ve ever seen.

If you are using proguard and can’t get your Tizen companion app to connect properly to your Android app (it probably works for debug builds but not release builds since you’re only using proguard for release builds), and you don’t want to download that 112 page PDF, here’s what you need to add to your proguard-rules.pro file:

-keepclassmembers class com.samsung.** { *; }
-keep class com.samsung.** { *; }
-dontwarn com.samsung.**

#add the lines below if you have a class that extends SAAgentV2
-keepclassmembers class <package name for class that extends SAAgentv2>.** { *; }
-keep class <package name for class that extends SAAgentv2>.** { *; }

So happy that Samsung is adopting Wear OS. The day I get to delete the code repository for our Tizen app will be among the happiest days of my life.

1 Like

Really thanks for the resolution of this issue. It solved my problem once I update the targetSdkVersion 30

Hello everybody.

I’m just returning here to say that it worked for me.