Android Open Mobile API发布困难 [英] Android Open Mobile API Release Difficulties

查看:954
本文介绍了Android Open Mobile API发布困难的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SDK中的"org.simalliance.openmobileapi.jar"文件.我将其复制到我的libs文件夹中,并添加了这样的依赖项

I am using the "org.simalliance.openmobileapi.jar" file from SDK. I copied it to my libs folder and added the dependency like this

在应用程序Gradle文件中,我有:

In app Gradle file I have:

provided files('libs/org.simalliance.openmobileapi.jar')

案例2:不起作用(在发布模式下-没有minifyEnabled)

在应用程序Gradle文件中,我有:

Case #2: not working (in release mode - without minifyEnabled)

In app Gradle file I have:

compile files('libs/org.simalliance.openmobileapi.jar')

在#2的情况下,出现以下异常:

In case #2 I get the following exception:

(java.lang.SecurityException:访问控制强制:不允许APDU访问!)

(java.lang.SecurityException: Access Control Enforcer: no APDU access allowed!)

什么原因可能导致问题?

What could cause the problem?

推荐答案

首先,您需要在build.gradle文件中使用提供的"范围进行调试和发布:

First of all, you need to use the "provided" scope in your build.gradle file for both your debug and your release build:

dependencies {
    [...]
    provided files('libs/org.simalliance.openmobileapi.jar')
}

更新

提供"已过时,并已替换为"compileOnly",因此对于当前的gradle版本,您需要使用(如

"provided" is obsolete and has been replaced with "compileOnly", so for current gradle versions, you need to use (as commented by TT):

dependencies {
    [...]
    compileOnly files('libs/org.simalliance.openmobileapi.jar')
}

此外,您需要在AndroidManifest.xml中有一个uses-library条目:

Moreover, you need to have a uses-library entry in your AndroidManifest.xml:

<uses-library android:name="org.simalliance.openmobileapi"
              android:required="true" />

但是,由于得到SecurityException的原因是"Access Control Enforcer:不允许APDU访问!",因此这清楚地表明,链接并使用系统提供的Open Mobile API库可以按预期进行,并且您已成功连接到设备上的SmartcardService系统服务.因此,您似乎可以使构建工作按预期进行.

However, since you got a SecurityException with the reason "Access Control Enforcer: no APDU access allowed!", this is a clear indication that linking to and using the system-provided Open Mobile API library worked as expected and that you successfully connected to the SmartcardService system service on your device. Consequently, you seem to have your build working as expected.

因此,SecurityException已经清楚地告诉您问题出在哪里:

Therefore, the SecurityException already clearly tells you what the problem is:

Access Control Enforcer:不允许APDU访问!

Access Control Enforcer: no APDU access allowed!

这意味着未正确配置安全元素上的访问控制列表.由于调试构建有效,因此您可能确实在安全元素上的ARA小程序(和/或ARF文件)中注册了用于调试环境的证书.但是,发行版本未使用相同的调试密钥(证书)签名.而是使用在Android Studio中选择生成签名的APK ..."时选择的发布密钥(证书)对它们进行签名.因此,您有两个选择:

This means that the access control list on the secure element is not properly configured. Since your debug build works, you probably did register the certificate for your debug environment with the ARA applet (and/or the ARF file) on the secure element. However, release builds are not signed with that same debug keys (certificate). Instead, they are signed with the release keys (certificate) that you chose when selecting "Generate Signed APK..." in Android Studio. Therefore, you have two options:

  1. 在安全元素上的Applet允许的应用程序列表中添加发布证书.

  1. Add the release certificate to the list of allowed applications for your applet on the secure element.

将安全元素上的访问条件更改为ALLOW ALL,以允许从任何设备应用程序访问任何applet.

Change access conditions on the secure element to ALLOW ALL in order to allow access to any applet from any device app.

根据您的安全元素,通常需要更新ARA(全局平台访问控制)小程序(AID A00000015141434C00)或位于PKCS#15应用程序(AID A000000063504B43532D3135)中的访问规则文件(ARF).或具有新访问条件的SIM文件系统中.

Depending on your secure element, you would typically need to update the ARA (GlobalPlatform Access Control) applet (AID A00000015141434C00) or the access rules file (ARF) located in a PKCS#15 application (AID A000000063504B43532D3135) or in the SIM file system with the new access conditions.

这篇关于Android Open Mobile API发布困难的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆