EnterpriseDeviceManager无法应用于给定类型

时间:2018-03-06 22:11:00

标签: android

我遇到与此相同的问题:

https://seap.samsung.com/forum-topic/problem-arises-here-getsystemserviceenterprisedevicemanagerenterprisepolicyservice

我按照上面链接中的说明操作,显示“EnterpriseDeviceManager无法应用于给定类型”。

我是否需要更改我的gradle或者清单?

package com.test.myapplication;

import android.support.v7.app.AppCompatActivity; import android.os.Bundle;

import com.samsung.android.knox.EnterpriseDeviceManager;

公共类MainActivity扩展了AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

EnterpriseDeviceManager edm = new EnterpriseDeviceManager(this);

}

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.test.myapplication"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation files('libs/knoxsdk.jar')
implementation files('libs/supportlib.jar')
implementation files('libs/android-support-v13.jar')

}

2 个答案:

答案 0 :(得分:1)

我有同样的问题。

我的解决方案:

  1. 确保“ knoxsdk.jar”文件存在。 (samsung knox sdk)
  2. 依赖项上的文件“ build.gradle”添加此> compileOnly文件('libs / knoxsdk.jar')

希望这会有所帮助。

答案 1 :(得分:0)

使用此配置:

compileOnly files('libs/knoxsdk.jar')
runtimeOnly files('libs/supportlib.jar')