我正在尝试运行Phone为Consumer的示例项目。
http://developer.samsung.com/sample-app/view.do?v=S000000069nCT030000
应用程序使用我的HTC Desire 820(4.4.4)完美运行。
然而,当我在三星Galaxy S4(5.0.1)上运行它时,在onCreate()
ConsumerService
时会崩溃
这是我的堆栈跟踪:
FATAL EXCEPTION: main
Process: com.samsung.android.sdk.accessory.example.helloaccessory.consumer, PID: 29617
java.lang.RuntimeException: Unable to create service com.samsung.android.sdk.accessory.example.helloaccessory.consumer.ConsumerService: java.lang.SecurityException: com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY permission is required.
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3167)
at android.app.ActivityThread.access$1900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1532)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: java.lang.SecurityException: com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY permission is required.
at com.samsung.android.sdk.accessory.SA.initialize(Unknown Source)
at com.samsung.android.sdk.accessory.SAAgent.onCreate(Unknown Source)
at com.samsung.android.sdk.accessory.example.helloaccessory.consumer.ConsumerService.onCreate(ConsumerService.java:52)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3157)
at android.app.ActivityThread.access$1900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1532)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
所以基本上我错过了一个许可,我用这个证实了这个:
String permission = "com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY";
int res = getContext().checkCallingOrSelfPermission(permission);
return (res == PackageManager.PERMISSION_GRANTED);
返回了false
但是,我在AndroidManifest.xml中包含了此权限:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.samsung.android.sdk.accessory.example.helloaccessory.consumer"
android:versionCode="4"
android:versionName="2.0.2" >
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="com.samsung.accessory.permission.ACCESSORY_FRAMEWORK" />
<uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION" />
<uses-permission android:name="com.samsung.WATCH_APP_TYPE.Companion"/>
<application...
我正在使用gradle构建这些版本:
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.samsung.android.sdk.accessory.example.helloaccessory.consumer"
minSdkVersion 15
targetSdkVersion 23
versionCode 4
versionName '2.0.2'
}
我也在使用
compile 'com.android.support:appcompat-v7:23.1.1'
手机没有扎根。
有没有人知道为什么会发生这种情况以及如何解决这个问题?
谢谢!
答案 0 :(得分:1)
尝试将Samsung Pass SDK更新为1.2.2
http://developer.samsung.com/galaxy/pass
我不知道发生了什么,但1.2.1在Androidmanifest中添加权限也不起作用。