Error Parsing tmx and JSON file in Android Studio - android-studio

I'm trying to load a simple map made by Tiled inside my Android studio project.
I'm using libGDX to made a simple platform game.
In Tiled I've just imported a tileset, created a platform and anything else.
Now I would like to understand in the witch part that I am failing my upload because I am not able to understand why I have this error:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.SerializationException: Error parsing file: mapassets.json
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:83)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.getDependencyFileHandles(TmxMapLoader.java:116)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:74)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:59)
at com.arcadan.push_the_player.TiledTest.create(TiledTest.java:28)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:150)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:127)
Caused by: com.badlogic.gdx.utils.SerializationException: Error parsing XML on line 1 near:
{ "columns":10,
"image":"..\/..
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:330)
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:61)
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:81)
... 6 more
Here the map .tmx :
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="20" height="20" tilewidth="12" tileheight="12" infinite="0" nextlayerid="2" nextobjectid="1">
<editorsettings>
<export target="../../android/assets/MyMap.tmx" format="tmx"/>
</editorsettings>
<tileset firstgid="1" source="../mapassets.json"/>
<layer id="1" name="Tile Layer 1" width="20" height="20">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,1,2,3,4,5,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,11,12,13,14,15,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,21,22,23,24,25,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,31,32,33,34,35,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,41,42,43,44,45,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
</map>
Here is my frustrating mapassets.json(this file is inside assets/mapAssets folder in my project):
{ "columns":10,
"image":"..\/..\/assets\/mapAssets\/mapassets.png",
"imageheight":128,
"imagewidth":128,
"margin":0,
"name":"mapassets",
"spacing":0,
"tilecount":100,
"tiledversion":"1.4.3",
"tileheight":12,
"tilewidth":12,
"type":"tileset",
"version":1.4
}
and here how I load .tmx file:
#Override
public void create () {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
camera = new OrthographicCamera();
camera.setToOrtho(false,w,h);
camera.update();
tiledMap = new TmxMapLoader().load("MyMap.tmx");
tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap);
Gdx.input.setInputProcessor(this);
}

You get the error because you've saved your tileset as a .json file but the libGDX implementation in TmxMapLoader assumes it's in XML.
You can see that in the source code for TmxMapLoader.
Save your tileset as a .tsx file instead and reference that from your .tmx file and it should work.

Related

Azure Media Service returns 0 duration with account filter

I am using Azure Media Service v3 to store and encode videos. As a trial, I'd want to show the initial 30 seconds to the User and they can see the rest if they sign up.
So to get the initial 30 seconds, I decided to use the manifest filter as described in the Azure website.
I created an account filter with the following settings and it got created successfully. However, whenever I try to play that video with the URL, I get the manifest file with duration equals to 0 and video fails to play.
Settings I used:
{
"properties": {
"presentationTimeRange": {
"startTimestamp": 0,
"endTimestamp": 300000000,
"presentationWindowDuration": 600000000,
"liveBackoffDuration": 0,
"timescale": 10000000,
"forceEndTimestamp": true
}
}
}
URL I am using to play video:
https://xxx-xxx.streaming.media.azure.net/resource-id/video-name.ism/manifest(filter=free-user)
This is how my original manifest looks:
<?xml version="1.0" encoding="UTF-8"?>
-<SmoothStreamingMedia TimeScale="10000000" Duration="4317653333" MinorVersion="2" MajorVersion="2">
-<StreamIndex Name="aac_und_2_127999_2_1" Language="und" QualityLevels="1" Url="QualityLevels({bitrate})/Fragments(aac_und_2_127999_2_1={start time})" Type="audio" Chunks="72">
<QualityLevel SamplingRate="48000" PacketSize="4" Channels="2" CodecPrivateData="1190" FourCC="AACL" Bitrate="127999" BitsPerSample="16" Index="0" AudioTag="255"/>
<c r="71" d="60160000" t="0"/>
<c d="46293333"/>
</StreamIndex>
-<StreamIndex QualityLevels="5" Url="QualityLevels({bitrate})/Fragments(video={start time})" Type="video" Chunks="72">
<QualityLevel CodecPrivateData="000000016764001FACD9405005BB011000000300100000030320F18319600000000168EBECB22C" FourCC="H264" Bitrate="762429" Index="0" MaxHeight="720" MaxWidth="1280"/>
<QualityLevel CodecPrivateData="000000016764001FACD940F0117EF011000003000100000300320F1831960000000168EBECB22C" FourCC="H264" Bitrate="456443" Index="1" MaxHeight="540" MaxWidth="960"/>
<QualityLevel CodecPrivateData="000000016764001EACD940A02FF97011000003000100000300320F162D960000000168EBECB22C" FourCC="H264" Bitrate="288193" Index="2" MaxHeight="360" MaxWidth="640"/>
<QualityLevel CodecPrivateData="0000000167640015ACD941E08FEB011000000300100000030320F162D9600000000168EBECB22C" FourCC="H264" Bitrate="157781" Index="3" MaxHeight="270" MaxWidth="480"/>
<QualityLevel CodecPrivateData="000000016764000CACD941419F9F011000000300100000030320F14299600000000168EBECB22C" FourCC="H264" Bitrate="99525" Index="4" MaxHeight="180" MaxWidth="320"/>
<c r="71" d="60000000" t="0"/>
<c d="54800000"/>
</StreamIndex>
</SmoothStreamingMedia>
Can anyone tell me what am I doing wrong here?
filter
Can you check if you actually have timestamp 0 in your manifest? The startTimestamp and endTimestamp settings select the range of actual timestamps in your manifest.
You can open the manifest here:
https://xxx-xxx.streaming.media.azure.net/resource-id/video-name.ism/manifest

Animated-selector causes crash on view initialization

My goal is to create a custom switch including animated transitions between checked and unchecked state.
I easily achieved a default state and my switch looks as expected in both states and it changes its look when its state is changed.
Problem arises when I attach animated-selector instead of regular one.
I'm gettting an error like this:
android.view.InflateException: Binary XML file line #10: Binary XML
file line #10: Error inflating class android.widget.Switch
Caused by: android.content.res.Resources$NotFoundException: File
res/drawable/switch_track_animation_unchecked_checked.xml from
drawable resource ID #0x7f060072
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2640)
Caused by: android.content.res.Resources$NotFoundException: File
res/drawable/switch_track_animated_selector.xml from drawable resource
ID #0x7f060070
I can assure that I'm properly accessing those drawables etc.
I went through invalidate caches and restart, clean build, rebuild etc. and it won't work.
View sample
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:thumb="#drawable/switch_thumb_selector"
android:track="#drawable/switch_track_animated_selector"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:checked="true"
android:id="#+id/switch2"/>
switch_track_animated_selector
<animated-selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/checked"
android:drawable="#drawable/switch_bckg_on"
android:state_checked="true"/>
<item android:id="#+id/unchecked"
android:drawable="#drawable/switch_bckg_off"
android:state_checked="false"/>
<transition
android:fromId="#+id/unchecked"
android:toId="#+id/checked"
android:drawable="#drawable/switch_track_animation_unchecked_checked"/>
<transition
android:fromId="#+id/checked"
android:toId="#+id/unchecked"
android:drawable="#drawable/switch_track_animation_checked_unchecked"/>
</animated-selector>
switch_bckg_on.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00B05A"/>
<stroke android:width="1dp" android:color="#00B05A" />
<corners android:radius="180dp"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
</shape>
switch_bckg_off.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#F1F1F1"/>
<stroke android:width="1dp" android:color="#E0E0E0" />
<corners android:radius="180dp"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
</shape>
switch_track_animation_checked_unchecked.xml
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:drawable="#drawable/switch_bckg_on">
<target android:name="android:drawable">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="#android:integer/config_shortAnimTime"
android:interpolator="#android:interpolator/accelerate_decelerate"
android:propertyName="strokeColor"
android:valueFrom="#A0A0A0"
android:valueTo="#1E9618"
android:valueType="intType" />
</aapt:attr>
</target>
</animated-vector>
switch_track_animation_unchecked_checked.xml
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:drawable="#drawable/switch_bckg_off">
<target android:name="android:drawable">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="#android:integer/config_shortAnimTime"
android:interpolator="#android:interpolator/accelerate_decelerate"
android:propertyName="strokeColor"
android:valueFrom="#A0A0A0"
android:valueTo="#1E9618"
android:valueType="intType"/>
</aapt:attr>
</target>
</animated-vector>
I also checked above approach using vector drawable instead of shape and I had the same result.
Example of vectors
ic_thumb_vector_off
<vector android:height="33dp" android:viewportHeight="300"
android:viewportWidth="300" android:width="33dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:name="background_off" android:fillColor="#FFFFFF" android:fillType="nonZero"
android:pathData="M149.926,149.926m-149.176,0a149.176,149.176 0,1 1,298.352 0a149.176,149.176 0,1 1,-298.352 0"
android:strokeAlpha="0.1" android:strokeColor="#000000" android:strokeWidth="0.5"/>
<path android:name="icon_off" android:fillColor="#9B9B9B" android:fillType="evenOdd"
android:pathData="M166.88,146.104C166.13,145.354 166.13,144.228 166.88,143.478L195.019,115.339C195.77,114.588 196.145,113.463 196.145,112.712C196.145,111.962 195.77,110.836 195.019,110.086L189.767,104.833C189.016,104.083 187.891,103.708 187.14,103.708C186.015,103.708 185.264,104.083 184.514,104.833L156.375,132.972C155.624,133.723 154.499,133.723 153.748,132.972L125.609,104.833C124.859,104.083 123.733,103.708 122.983,103.708C122.233,103.708 121.107,104.083 120.357,104.833L115.104,110.086C114.354,110.836 113.979,111.962 113.979,112.712C113.979,113.463 114.354,114.588 115.104,115.339L143.243,143.478C143.994,144.228 143.994,145.354 143.243,146.104L115.104,174.243C114.354,174.993 113.979,176.119 113.979,176.869C113.979,177.62 114.354,178.745 115.104,179.496L120.357,184.748C121.107,185.499 122.233,185.874 122.983,185.874C123.733,185.874 124.859,185.499 125.609,184.748L153.748,156.609C154.499,155.859 155.624,155.859 156.375,156.609L184.514,184.748C185.264,185.499 186.39,185.874 187.14,185.874C187.891,185.874 189.016,185.499 189.767,184.748L195.019,179.496C195.77,178.745 196.145,177.62 196.145,176.869C196.145,176.119 195.77,174.993 195.019,174.243L166.88,146.104Z"
android:strokeColor="#00000000" android:strokeWidth="1"/>
</vector>
ic_thumb_vector_on
<vector android:height="33dp" android:viewportHeight="302"
android:viewportWidth="302" android:width="33dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:name="background_on" android:fillColor="#FFFFFF" android:fillType="nonZero"
android:pathData="M151,151m-150.25,0a150.25,150.25 0,1 1,300.5 0a150.25,150.25 0,1 1,-300.5 0"
android:strokeAlpha="0.1" android:strokeColor="#000000" android:strokeWidth="0.5"/>
<path android:name="icon_on" android:fillColor="#00B05A" android:fillType="evenOdd"
android:pathData="M105.523,153.198C104.806,152.5 104.448,151.453 104.448,150.754C104.448,150.056 104.806,149.009 105.523,148.31L110.536,143.422C111.968,142.026 114.117,142.026 115.549,143.422L115.907,143.772L135.602,164.371C136.318,165.069 137.393,165.069 138.109,164.371L186.093,115.841L186.451,115.841C187.883,114.444 190.032,114.444 191.464,115.841L196.477,120.728C197.91,122.125 197.91,124.22 196.477,125.616L139.183,183.573C138.467,184.272 137.751,184.621 136.676,184.621C135.602,184.621 134.886,184.272 134.17,183.573L106.239,154.246L105.523,153.198Z"
android:strokeColor="#00000000" android:strokeWidth="1"/>
</vector>
Maybe I/m missing something in gradle file?
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "...customswitch"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
I expect this view to load and not to throw an error on view init.
Your issue is that switch_track_animation_unchecked_checked.xml and switch_track_animation_checked_unchecked.xml are animated VectorDrawables, and these animate static VectorDrawable states. You are trying to animate ShapeDrawable, and not VectorDrawable and that's what is causing the exception, I think.
You need to replace switch_bckg_on.xml and switch_bckg_off.xml with <vector>...</vector> implementations to animate them from within an <animated-vector>...</animated-vector> block.
Alternatively you could replace the AnimatedVectorDrawables with StateListAnimator, although I'm not sure that will actually be able to do what you're trying to achieve here.
It seems like your switch_track_animated_selector does not have some default state without any id. You may try to add this state. This helped me in a similar situation

Error processing / merging manifest

I get this error
W:\android-studio-projects\sharedid\app\build\intermediates\merged_manifests\flavor_customer1Debug\processFlavor_customer1DebugManifest\merged\AndroidManifest.xml:49:
error: resource string/MyAppName (aka
com.customer1.app:string/MyAppName) not found.
error: failed processing manifest.
...
My gradle contains this
flavor_customer1 {
java.srcDirs = ["W:/android-studio-projects/sharedid/app/src/main/java/"]
manifest.srcFile "W:/android-studio-projects/sharedid/app/src/customer1/AndroidManifest.xml"
assets.srcDirs = ["W:/android-studio-projects/sharedid/app/src/customer1/assets/"]
resources.srcDirs = ["W:/android-studio-projects/sharedid/app/src/main/res/", "W:/android-studio-projects/sharedid/app/src/customer1/res/"]
}
I have defined MyAppName in file
"W:/android-studio-projects/sharedid/app/src/customer1/res/values/strings_specific.xml"
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="MyAppName">Customer 1</string>
</resources>
In "W:/android-studio-projects/sharedid/app/src/customer1/AndroidManifest.xml" I use the string like this
<application
android:allowBackup="true"
android:icon="#drawable/app_logo__forlarge"
android:label="#string/MyAppName"
android:theme="#style/AppBaseTheme_Customer_One"
android:name="com.shared.app.MyApp"
>
...
What am I missing? I am trying to switch over to using product flavors
Apparentlt merge depends on "main" folder also containing strings.xml even though each flavor has their own

libxmljs: how to use xinclude?

I try to use libxmljs with nodejs.
In my sample I want to use the xi:include.
<ord:order xmlns:ord="http://example.org/ord"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.org/ord chapter04ord1.xsd"
xmlns:xi="http://www.w3.org/2001/XInclude">
<number>123ABBCC123</number>
<customer>
<name>Priscilla Walmsley</name>
<number>15466</number>
</customer>
<items>
<xi:include href="/Users/mar/ws_e/libxml/test/resources/chapter5prod.xml" />
</items>
</ord:order>
include File:
<ord:product xmlns:ord="http://example.org/ord"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.org/ord chapter04ord1.xsd">
<number>557</number>
<name>Short-Sleeved Linen Blouse</name>
<size system="US-DRESS">10</size>
<color value="blue"/>
</ord:product>
This is my code:
var xsdDoc = libxml.parseXml(schemaSource);
var xmlDocValid = libxml.parseXml(docSource);
var xmlDocInvalid = libxml.parseXml(xml_invalid);
xmlDocValid.validate(xsdDoc);
console.dir(xmlDocValid);
console.dir(xmlDocValid.validationErrors);
Then I get the error:
Document {
errors: [],
validationErrors:
[ { Error: Element '{http://www.w3.org/2001/XInclude}include': This element is not expected. Expected is ( product ).
So my question is how to use the x:include right at libxmljs?
Kind regards
Markus

Read TLV encoded data on JavaCard Classic

I'd like to read TLV encoded certificates on a Java Card (NXP JCOP J3D081, JCOP version 2.4.2, Java Card version 3.0.1 Classic).
The cap file is created successfully, but when I try to install it on the card I get an gpshell error:
load() returns 0x80206A80 (6A80: Wrong data / Incorrect values in command data.)
I use the jars from JCDK 3.0.3 and this usually works with stuff like elliptic curves etc. What could be different with the TLV stuff?
The applet code used (installs fine when not using the BERTLV stuff):
package org.thomas;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.Util;
import javacardx.framework.tlv.BERTLV;
import javacardx.framework.tlv.ConstructedBERTLV;
public class TlvApplet extends Applet {
private ConstructedBERTLV certificate;
byte[] certificateLength = new byte[2];
/**
* TlvApplet constructor
*
* #constructor
*/
private TlvApplet() {
// Register with the JCRE
register();
}
/**
* Installs applet
*
* #param bArray
* the array containing installation parameters
* #param bOffset
* the starting offset in bArray
* #param bLength
* the length in bytes of the parameter data in bArray
*/
public static void install(byte[] bArray, short bOffset, byte bLength) {
new TlvApplet();
}
public void process(APDU apdu) throws ISOException {
byte buffer[] = apdu.getBuffer();
short incomingLength = apdu.setIncomingAndReceive();
certificate = (ConstructedBERTLV) BERTLV.getInstance(buffer,
ISO7816.OFFSET_CDATA, incomingLength);
certificateLength[0] = (byte) (certificate.size() & 0xff);
certificateLength[1] = (byte) ((certificate.size() >> 8) & 0xff);
Util.arrayCopyNonAtomic(certificateLength, (short) 0, buffer,
ISO7816.OFFSET_CDATA, (short) 2);
}
}
I create the cap file by using the following ant build.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<project default="convert" name="Create JC 3 applet" basedir=".">
<property environment="env" />
<!-- Include properties in the build.properties file -->
<property file="build.properties" />
<!-- Build specific properties -->
<property name="source.path" location="${basedir}/${source.folder}" />
<property name="jcdk.libs" location="${basedir}/${jcdk.basefolder}/${jcdk.subfolder.libs}" />
<property name="jcdk.apiexports" location="${basedir}/${jcdk.basefolder}/${jcdk.subfolder.apiexportfiles}" />
<property name="target.path.classes"
location="${basedir}/${target.basefolder}/${target.subfolder.classes}" />
<property name="target.path.cap"
location="${basedir}/${target.basefolder}/${target.subfolder.applet}" />
<!-- set the classpath for the tasks and the API, include all jar files -->
<path id="classpath" description="Sets the classpath to Java Card API and tools">
<fileset dir="${jcdk.libs}">
<include name="*.jar" />
</fileset>
</path>
<!-- set the export path to the Java Card export files -->
<path id="export" description="set the export file path">
<fileset dir="${jcdk.apiexports}">
<include name="**/*.exp" />
</fileset>
<pathelement path="${jcdk.apiexports}" />
<pathelement path="${target.path.classes}" />
</path>
<path id="capexport" description="set the export file for the cap path">
<fileset dir="${jcdk.apiexports}">
<include name="**/*.exp" />
</fileset>
<pathelement path="${jcdk.apiexports}" />
</path>
<!-- Definitions for tasks for Java Card tools -->
<taskdef name="apdu" classname="com.sun.javacard.ant.tasks.APDUToolTask" classpathref="classpath" />
<taskdef name="capgen" classname="com.sun.javacard.ant.tasks.CapgenTask" classpathref="classpath" />
<taskdef name="convert" classname="com.sun.javacard.ant.tasks.ConverterTask" classpathref="classpath" />
<taskdef name="verifyexport" classname="com.sun.javacard.ant.tasks.VerifyExpTask" classpathref="classpath" />
<taskdef name="verifycap" classname="com.sun.javacard.ant.tasks.VerifyCapTask" classpathref="classpath" />
<taskdef name="verifyrevision" classname="com.sun.javacard.ant.tasks.VerifyRevTask" classpathref="classpath" />
<typedef name="appletnameaid" classname="com.sun.javacard.ant.types.AppletNameAID" classpathref="classpath" />
<typedef name="jcainputfile" classname="com.sun.javacard.ant.types.JCAInputFile" classpathref="classpath" />
<typedef name="scriptgen" classname="com.sun.javacard.ant.tasks.ScriptgenTask" classpathref="classpath" />
<target name="init">
<mkdir dir="${target.path.classes}" />
</target>
<target name="clean">
<delete dir="${target.path.classes}" />
</target>
<target name="compile" depends="init" description="Compile source code to class files">
<javac debug="${javac.debug}"
optimize="${javac.optimize}"
srcdir="${source.path}"
destdir="${target.path.classes}"
source="${javac.version.source}"
target="${javac.version.target}">
<classpath refid="classpath" />
</javac>
</target>
<target name="convert" depends="compile" description="Convert class files to cap files">
<convert packagename="${package.name}"
packageaid="${package.aid}"
majorminorversion="${applet.version}"
classdir="${target.path.classes}"
outputdirectory="${target.path.cap}"
jca="${cap.creation.jca}"
exp="${cap.creation.exp}"
cap="true"
debug="${cap.creation.debug}" verbose="${cap.creation.verbose}"
noverify="${cap.creation.noverify}">
<appletnameaid aid="${applet.aid}" appletname="${applet.name}" />
<exportpath refid="capexport" />
<classpath refid="classpath" />
</convert>
</target>
<target name="all" depends="clean, convert" />
</project>
The build.properties used:
# Source folder
source.folder = src/org/thomas
# Java Card Development Kit folders
jcdk.basefolder = lib/javaCardKit303
jcdk.subfolder.apiexportfiles = api_export_files
jcdk.subfolder.libs = lib
# Target folders (will be created, no need to adapt)
target.basefolder = target
target.subfolder.classes = classes
target.subfolder.applet = applet
# Applet properties
package.aid = 0x41:0x41:0x41:0x41:0x41:0x41:0x41:0x41:0x41:0x42
package.name = org.thomas
applet.aid = 0x41:0x41:0x41:0x41:0x41:0x41:0x41:0x41:0x41:0x42:0x42
applet.name = TlvApplet
applet.version = 1.0
# Java class compiler options
javac.debug = no
javac.optimize = no
javac.version.source = 1.5
javac.version.target = 1.5
# CAP file creation options
cap.creation.verbose = false
cap.creation.noverify = false
cap.creation.debug = false
cap.creation.jca = false
cap.creation.exp = false
So suspected the cap to be compiled with the api_connected.jar, but removing the file from kit, didn't change anything.
Any help would be appreciated. Thanks in advance, Thomas
The card simply does not support the TLV classes of the java card API. The JC API is just a recommendation but the card manufacturer may choose to implement a subset of it.
In general anything in javacardx is optional (hence the x at the end). The API methods in javacard must be implemented though. Even for javacard packages and classes not all functionality may be available at runtime. For instance, cryptographic algorithms may not be present.

Resources