摩托罗拉 EMDK 3.1 错误 (app\build\intermediates\exploded-aar\com.android.support\appcompat-v7.2.1\res\values-v21\values-v21.xml)

Motorola EMDK 3.1 error (app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\22.2.1\res\values-v21\values-v21.xml)

我正在使用 Motorola EMDK 3.1 在 Android Studio 中编写一个小型扫描应用程序。此应用程序应 运行 在 Android 4.1.

上的 TC55

当我尝试 运行 我的应用程序时出现此错误:

 C:\Users\herold.IDENTWERK\Desktop\EmdkTest\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7.2.1\res\values-v17\values-v17.xml
    Error:(6, 21) No resource found that matches the given name: attr 'android:textAlignment'.
    Error:(10, 21) No resource found that matches the given name: attr 'android:paddingEnd'.
    Error:(10, 21) No resource found that matches the given name: attr 'android:paddingEnd'.
    Error:(13, 21) No resource found that matches the given name: attr 'android:paddingStart'.
    Error:(17, 21) No resource found that matches the given name: attr 'android:layout_marginEnd'.
    Error:(10, 21) No resource found that matches the given name: attr 'android:paddingEnd'.
    Error:(23, 21) No resource found that matches the given name: attr 'android:layout_marginStart'.
    Error:(26, 21) No resource found that matches the given name: attr 'android:layout_alignParentStart'.
    Error:(6, 21) No resource found that matches the given name: attr 'android:textAlignment'.
    Error:(10, 21) No resource found that matches the given name: attr 'android:paddingEnd'.
    Error:(13, 21) No resource found that matches the given name: attr 'android:paddingStart'.
    Error:(26, 21) No resource found that matches the given name: attr 'android:layout_alignParentStart'.
    Error:(37, 21) No resource found that matches the given name: attr 'android:layout_toStartOf'.
    Error:(40, 21) No resource found that matches the given name: attr 'android:layout_alignParentEnd'.
    Error:(44, 21) No resource found that matches the given name: attr 'android:layout_toEndOf'.
    Error:(37, 21) No resource found that matches the given name: attr 'android:layout_toStartOf'.
    Error:(23, 21) No resource found that matches the given name: attr 'android:layout_marginStart'.
    Error:(13, 21) No resource found that matches the given name: attr 'android:paddingStart'.

这是我的 Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'Symbol Technologies, Inc.:EMDK 3.1 (API 16):16'
    buildToolsVersion '21.1.1'

    defaultConfig {
        applicationId "com.example.herold.emdktest"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:22.2.1'

用这个代替你的。我希望它能起作用。

compileSdkVersion 21
buildToolsVersion '21.1.2'

compile 'com.android.support:appcompat-v7:21.0.3'

确保您添加了 Motorola EMDK 3.1 jar 。

现在,你应该使用

 compileSdkVersion 24
 buildToolsVersion "24.0.2"

 compile 'com.android.support:appcompat-v7:24.2.0'

您收到错误是因为最新的 AndroidStudio 模板生成的应用程序无法使用 API 级别 16 进行编译。就像您在此处针对 EMDK 进行编译一样。

您可以在 EMDK download for the Mac 中找到最新版本的 jar 库(它以 zip 存档的形式提供,而不是像 Windows 那样只有安装包)。

您最好的选择是在项目的 libs 文件夹中手动包含 com.symbol.emdk.jar 并使用最新的可用 SDK 编译应用程序。

android {
  compileSdkVersion 23
   buildToolsVersion "23.0.1"

最后的操作是指示gradle不要编译最终apk中的emdk jar:

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'], exclude: ['com.symbol.emdk.jar'])
  compile 'com.android.support:appcompat-v7:23.0.1'
   provided fileTree(dir: 'libs', include: ['com.symbol.emdk.jar'])
}