Languages

Menu
Sites
Language
Invalid implemetation of SASocket. Provider a public default constructor

Hi there,

I made a Gear2 integrated App (Service APK on Android phone, Widget on Tizen watch).
I have no watch device, so I tested on Emulator + Phone. It works fine.

I uploaded to Samsung store, and during their test it crashed. I have the dump.log (12mb) . What I see there, it tries to start the service after installation on the phone, but fails:

10-27 09:04:11.066   778  1240 W ActivityManager: Permission Denial: getCurrentUser() from pid=12997, uid=10236 requires android.permission.INTERACT_ACROSS_USERS
10-27 09:04:11.076 12997 12997 E AndroidRuntime: FATAL EXCEPTION: main
10-27 09:04:11.076 12997 12997 E AndroidRuntime: Process: MY_APP.NAME, PID: 12997
10-27 09:04:11.076 12997 12997 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate service MY_APP.NAME.service.NAMEProviderService: java.lang.RuntimeException: Invalid implemetation of SASocket. Provider a public default constructor.
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at android.app.ActivityThread.handleCreateService(ActivityThread.java:2723)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at android.app.ActivityThread.access$1900(ActivityThread.java:169)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at android.os.Looper.loop(Looper.java:136)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5479)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:515)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
10-27 09:04:11.076 12997 12997 E AndroidRuntime: Caused by: java.lang.RuntimeException: Invalid implemetation of SASocket. Provider a public default constructor.
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at com.samsung.android.sdk.accessory.SAAgent.<init>(Unknown Source)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at MY_APP.NAME.service.NAMEProviderService.<init>(Unknown Source)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at java.lang.Class.newInstanceImpl(Native Method)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at java.lang.Class.newInstance(Class.java:1208)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     at android.app.ActivityThread.handleCreateService(ActivityThread.java:2720)
10-27 09:04:11.076 12997 12997 E AndroidRuntime:     ... 10 more

 

What could be the problem?
The device they tested:  Gear BT only - Tablet Galaxy (WXGA)

I also see a missing permission (INTERACT_ACROSS_USERS), however, I don't use getCurrentUser() in my code - but I don't think that causes the problem.

Edited by: Zoltan Puski on 30 Oct, 2014
View Selected Answer

Responses

3 Replies
Zoltan Puski
Zoltan Puski

In ProgrammingGuide_Accessory.pdf, I found this:

Add the lines below to proguard-project.txt to exclude Accessory SDK for the proguard.
- keepclassmembers class com.samsung.** { *; }
- keep class com.samsung.** { *; }
- dontwarn com.samsung.**

So far ok, I had all of these in my proguard-project.txt
Then:

If you extend SASocket, create a new java file for creating class to extend SASocket. Do not use inner class to extend SASocket.
- To avoid modifications in the inner class, ProGaurd option must be used by application developers following:
 - keepattributes InnerClasses

Now this is confusing, must I create a new java file, or can I use inner class, but have to use - keepattributes InnerClasses ?
As I have -keepattributes InnerClasses in my proguard-project.txt.

My proguard-project.txt:

-forceprocessing

-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
}

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

 

Mark as answer
Zoltan Puski

Yes, this solved my problem, I had to move the SASocket inner class to a new java file.