2

I'm currently trying to use the OpenMobile API which is library built-in in the android. (and not available for every device).

I'm following this tutorial to add the library to my android sdk : https://github.com/seek-for-android/pool/wiki/UsingSmartCardAPI

I have added the OpenMobile API through the SDK Manager and I now have folders in the path-to-sdk/sdk/add-ons. I'm currently using the last version of android (25) in Android Studio, and the OpenMobileAPI files located in sdk/add-ons are available for the version 21. There is no library available above 21 (see http://seek-for-android.github.io/repository/21/addon.xml).

Manifest :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  <application android:label="@string/app_name">

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

    <activity android:name=".MainActivity">
      ...
    </activity>
  </application>
</manifest> 

MainActivity

import org.simalliance.openmobileapi.*;

public class MainActivity extends Activity implements SEService.CallBack {
  ...
  public void serviceConnected(SEService service) {
    Log.i(LOG_TAG, "seviceConnected()");
  }
}

It's written :

Build SDK: Open Mobile API (Giesecke & Devrient GmbH) (API 21)

org.simalliance is not recognised by Android Studio, so I can't use it.

How do I build the SDK so that the library class are available in Android Studio ?

Kakera
  • 131
  • 8

2 Answers2

3

Inside the Android app gradle :

compile fileTree(include: ['*.jar'], dir: 'libs', 'exclude': ['org.simalliance.openmobileapi.jar'])

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

Manifest : In application tag add :

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

The provided instead of compile allow the library to be recognized and used in the code but is not compiled in the apk during the build.

Kakera
  • 131
  • 8
0

Using Android Studio, this solution worked for me. First, in "File>Project Structure>SDKs" click on "+" icon and add new Android SDK by choosing "Android 5.0 Open Mobile API ...". Then go to "File>Project Structure>Modules", select your app module, in "dependencies" tab select "Android 5.0 Open Mobile API ..." for "Module SDK" option. Click OK and Android Studio resolves classes.

For gradle to work I have to copy "org.simalliance.openmobileapi.jar" from add-ons of android sdk to "libs" directory of my app module, then use Kel H. answer above, by replacing "provided" to "compile" to build the project. Hope it helps.

hadilq
  • 1,023
  • 11
  • 25