The method getStartOffset()
does not work correctly after I upgraded assembly conditions.
Following fragment of code worked fine to build app with api 19 (Android Plugin 1.5.0 + Gradle version 2.2.1), but when I try do same with api 25 and other building conditions (Android Plugin 2.2.0 + Gradle version 2.14.1), getStartOffset()
returns value bigger length of file. Returned length is true.
In fact, the reading "png"-file isn't a image, I gave it extension PNG according to the requirements of aapt.
AssetFileDescriptor in = null;
FileInputStream fin = null;
FileChannel channel = null;
try {
in = context.getAssets().openFd(file); // .png
fin = in.createInputStream();
channel = fin.getChannel();
int length = (int) in.getLength(); // channel.size();
int offSet = (int) in.getStartOffset();
MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY,
0, length + offSet);
...
...
}
What is the problem? Thnks