I'm trying to add a English dictionary to the keyboard. So far I have:
Checked-out the source from google
Imported the java folder into eclipse as an existing code
Added support libraries
I'm able to run and build the code, but when I select the keyboard it crashes (I have not yet added the English or other dictionary). The error message is as follows:
FATAL EXCEPTION: InitializeBinaryDictionary
android.content.res.Resources$NotFoundException: File res/raw/main_en.dict from drawable resource ID #0x7f070003
at android.content.res.Resources.openRawResourceFd(Resources.java:1082)
at com.android.inputmethod.latin.BinaryDictionaryGetter.loadFallbackResource(BinaryDictionaryGetter.java:92)
at com.android.inputmethod.latin.BinaryDictionaryGetter.getDictionaryFiles(BinaryDictionaryGetter.java:328)
at com.android.inputmethod.latin.DictionaryFactory.createMainDictionaryFromManager(DictionaryFactory.java:55)
at com.android.inputmethod.latin.DictionaryFactory.createMainDictionaryFromManager(DictionaryFactory.java:83)
at com.android.inputmethod.latin.Suggest$1.run(Suggest.java:115)
Caused by: java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
at android.content.res.AssetManager.openNonAssetFdNative(Native Method)
at android.content.res.AssetManager.openNonAssetFd(AssetManager.java:429)
at android.content.res.Resources.openRawResourceFd(Resources.java:1079)
... 5 more
The relevant methods in the callstack are below:
public static ArrayList<AssetFileAddress> getDictionaryFiles(final Locale locale,
final Context context) {
final boolean hasDefaultWordList = DictionaryFactory.isDictionaryAvailable(context, locale);
BinaryDictionaryFileDumper.cacheWordListsFromContentProvider(locale, context,
hasDefaultWordList);
final File[] cachedWordLists = getCachedWordLists(locale.toString(), context);
final String mainDictId = DictionaryInfoUtils.getMainDictId(locale);
final DictPackSettings dictPackSettings = new DictPackSettings(context);
boolean foundMainDict = false;
final ArrayList<AssetFileAddress> fileList = CollectionUtils.newArrayList();
// cachedWordLists may not be null, see doc for getCachedDictionaryList
for (final File f : cachedWordLists) {
final String wordListId = DictionaryInfoUtils.getWordListIdFromFileName(f.getName());
final boolean canUse = f.canRead() && hackCanUseDictionaryFile(locale, f);
if (canUse && DictionaryInfoUtils.isMainWordListId(wordListId)) {
foundMainDict = true;
}
if (!dictPackSettings.isWordListActive(wordListId)) continue;
if (canUse) {
final AssetFileAddress afa = AssetFileAddress.makeFromFileName(f.getPath());
if (null != afa) fileList.add(afa);
} else {
Log.e(TAG, "Found a cached dictionary file but cannot read or use it");
}
}
if (!foundMainDict && dictPackSettings.isWordListActive(mainDictId)) {
final int fallbackResId =
DictionaryInfoUtils.getMainDictionaryResourceId(context.getResources(), locale);
final AssetFileAddress fallbackAsset = loadFallbackResource(context, fallbackResId);
if (null != fallbackAsset) {
fileList.add(fallbackAsset);
}
}
return fileList;
}
public static AssetFileAddress loadFallbackResource(final Context context,
final int fallbackResId) {
String str = context.getApplicationInfo().sourceDir;
AssetFileDescriptor afd = context.getResources().openRawResourceFd(fallbackResId);
if (afd == null) {
Log.e(TAG, "Found the resource but cannot read it. Is it compressed? resId="
+ fallbackResId);
return null;
}
try {
return AssetFileAddress.makeFromFileNameAndOffset(str, afd.getStartOffset(),
afd.getLength());
} finally {
try {
afd.close();
} catch (IOException e) {
// Ignored
}
}
}
I am using ADT 22 download from developer.goole.com
The problem is that there is no dictionary (not even the EN), so the swipe is not working. When I open the Add-on dictionaries there is "No dictionaries available" message in the list.
I'm testing on Samsung Galaxy Nexus with stock 4.3 rom and Nexus One Rom cook 4.0.4
I'm developing on Ubuntu 12.04.3 LTS
Any idea what could be the problem?
Related
I'm working with osmdroid map in offline mode. I have downloaded tiles using Global mapper and zip tiles are keep in download folder(/sdcard/Download). But on Accessing it getting below error in ArchiveFileFactory of osmdroid. It is Occurring in Android 10 and above.. Given storage access permission also.
ArchiveFileFactory class. Getting Error on highlighted line,
Getting Error On Access Zip File:
Method threw 'java.lang.NullPointerException' exception. Cannot evaluate org.osmdroid.tileprovider.modules.ZipFileArchive.toString()
Below is the code:
Permissions using
and build.gradle config is as below
Osm Library:
Tried Both Permissions :
1.Intent.ACTION_OPEN_DOCUMENT_TREE
2.Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
Fetching Offline Map
File f = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS) + "/map_file.zip");
if (f.exists()) {
String name = f.getName().toLowerCase();
name = name.substring(name.lastIndexOf(".") + 1);
if (ArchiveFileFactory.isFileExtensionRegistered(name)) {
try {
OfflineTileProvider tileProvider = new OfflineTileProvider(new SimpleRegisterReceiver(getActivity()),
new File[]{f});
mMap.setTileProvider(tileProvider);
String source;
IArchiveFile[] archives = tileProvider.getArchives();
if (archives.length > 0) {
String mapSrc = Preference.getMapSrc(getContext());
if (TextUtils.isEmpty(mapSrc)) {
Set<String> tileSources = archives[0].getTileSources();
if (!tileSources.isEmpty()) {
source = tileSources.iterator().next();
Preference.setMapSrc(getContext(), source);
mMap.setTileSource(FileBasedTileSource.getSource(source));
} else {
mMap.setUseDataConnection(true);
mMap.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
}
} else {
mMap.setTileSource(FileBasedTileSource.getSource(mapSrc));
}
} else {
mMap.setUseDataConnection(true);
mMap.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
return Constant.MAP_ASSETS_KML;
}
clearData();
return Constant.MAP_ASSETS_KML;
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
return Constant.MAP_ASSETS_KML;
}
Im investigating the use of citeproc in my current Android application
api 'de.undercouch:citeproc-java:2.0.0'
implementation 'org.citationstyles:styles:20.11'
implementation 'org.citationstyles:locales:20.11'
Its working fine using
// https://repo1.maven.org/maven2/com/eclipsesource/j2v8/j2v8/6.2.0/
implementation(name: 'j2v8-6.2.0', ext: 'aar')
However as Im running on Android OS the CSL static method
CSL.getSupportedStyles()
returns an empty list.
the underlying code in this method is as follows:-
private static Set<String> getAvailableFiles(String prefix,
String knownName, String extension) throws IOException {
Set<String> result = new LinkedHashSet<>();
// first load a file that is known to exist
String name = prefix + knownName + "." + extension;
URL knownUrl = CSL.class.getResource("/" + name);
if (knownUrl != null) {
String path = knownUrl.getPath();
// get the jar file containing the file
if (path.endsWith(".jar!/" + name)) {
String jarPath = path.substring(0, path.length() - name.length() - 2);
URI jarUri;
try {
jarUri = new URI(jarPath);
} catch (URISyntaxException e) {
// ignore
return result;
}
try (ZipFile zip = new ZipFile(new File(jarUri))) {
Enumeration<? extends ZipEntry> entries = zip.entries();
while (entries.hasMoreElements()) {
ZipEntry e = entries.nextElement();
if (e.getName().endsWith("." + extension) &&
(prefix.isEmpty() || e.getName().startsWith(prefix))) {
result.add(e.getName().substring(
prefix.length(), e.getName().length() - 4));
}
}
}
}
}
return result;
}
Is it possible to list get getAvailableFiles method to work on Android OS?
The following aproach does not work
val name: String = "$prefix$knownName.$extension"
val knownUrl: URL? = CSL::class.java.classLoader.getResource("$name")
All I require is the list of ".csl" files that in an Eclipse java project show as residing in styles-20.11.jar file
When I extract my Application APK file the ".csl" files are all listed seperately
Where am I going wrong?
How can I get a list of all ".csl" files available to CSL?
Your provided detail guides me to find the solution. That's enough to define apk in the checker condition.
class CLSHelper {
public static Set<String> getSupportedStyles() throws IOException {
return getAvailableFiles("", "ieee", "csl");
}
/**
* Customizing this function to able run in Android environment
*/
private static Set<String> getAvailableFiles(String prefix,
String knownName, String extension) throws IOException {
Set<String> result = new LinkedHashSet<>();
// first load a file that is known to exist
String name = prefix + knownName + "." + extension;
URL knownUrl = CSL.class.getResource("/" + name);
if (knownUrl != null) {
String path = knownUrl.getPath();
// get the jar or apk file containing the file
if (path.endsWith(".jar!/" + name) || path.endsWith(".apk!/" + name)) { // changing this line
String jarPath = path.substring(0, path.length() - name.length() - 2);
URI jarUri;
try {
jarUri = new URI(jarPath);
} catch (URISyntaxException e) {
// ignore
return result;
}
try (ZipFile zip = new ZipFile(new File(jarUri))) {
Enumeration<? extends ZipEntry> entries = zip.entries();
while (entries.hasMoreElements()) {
ZipEntry e = entries.nextElement();
if (e.getName().endsWith("." + extension) &&
(prefix.isEmpty() || e.getName().startsWith(prefix))) {
result.add(e.getName().substring(
prefix.length(), e.getName().length() - 4));
}
}
}
}
}
return result;
}
}
Output:
CSL.getSupportedStyles() // []
CLSHelper.getSupportedStyles() // [dependent/annals-of-occupational-and-environmental-medicine, dependent/photoacoustics, dependent/statistical-science, twentieth-century-music, dependent/aims-medical-science, dependent/cell-systems, dependent/nursingplus-open, dependent/computer-science-review,...]
P.S: To running on AndroidStudio I had to add these lines in build.gradle
android{
...
packagingOptions {
exclude 'META-INF/truffle/language'
}
}
I have been using "Environment.getExternalStorage()" to store and manage files. And there is no warning message from logcat with that method and works greatly fine.
But, My project needs to use method "Context.getExternalFilesDir(String type)" and there is a warning message
ContextImpl:Failed to ensure directory: /storage/external_SD/Android/data/(package name)/files
Fortunately that File object works fine(reading or write or making folder works, too).
But I want to know how to resolve that warning message. Do I miss something?
You should know how the warning message comes up.
The getExternalFilesDir(String type) will call getExternalFilesDirs(String type) (notice the 's' at the final of the second method name).
The getExternalFilesDirs(String type) will find all dirs of the type, and calls ensureDirsExistOrFilter() at the end to ensure the directories exist.
If the dir can't be reached, it will print a warning!
Log.w(TAG, "Failed to ensure directory: " + dir);
dir = null;
So, if your device has two sdcard paths, it will produce two dirs. If one is not available, the warning will come up.
The conclusion is the warning does not need to be fixed.
If you have code that is iterating files, calling this API many times, this warning can cause log pollution. To solve this (since the warning is actually benign) you can create a wrapper class that stores the result of calling getExternalFilesDir / getExternalCacheDir and subsequently returns the stored value instead of calling the API. In this way, at least you will only ever see this message once.
I follow the getExternalFilesDir() source
/**
* Ensure that given directories exist, trying to create them if missing. If
* unable to create, they are filtered by replacing with {#code null}.
*/
private File[] ensureExternalDirsExistOrFilter(File[] dirs) {
File[] result = new File[dirs.length];
for (int i = 0; i < dirs.length; i++) {
File dir = dirs[i];
if (!dir.exists()) {
if (!dir.mkdirs()) {
// recheck existence in case of cross-process race
if (!dir.exists()) {
// Failing to mkdir() may be okay, since we might not have
// enough permissions; ask vold to create on our behalf.
final IMountService mount = IMountService.Stub.asInterface(
ServiceManager.getService("mount"));
try {
final int res = mount.mkdirs(getPackageName(), dir.getAbsolutePath());
if (res != 0) {
Log.w(TAG, "Failed to ensure " + dir + ": " + res);
dir = null;
}
} catch (Exception e) {
Log.w(TAG, "Failed to ensure " + dir + ": " + e);
dir = null;
}
}
}
}
result[i] = dir;
}
return result;
}
immediate use Environment.getExternalStorageDirectory() get ExternalDirs
public final class StorageUtil {
public static final String DIR_ANDROID = "Android";
private static final String DIR_DATA = "data";
private static final String DIR_FILES = "files";
private static final String DIR_CACHE = "cache";
#Nullable
public static synchronized File getExternalStorageAppFilesFile(Context context, String fileName) {
if (context == null) return null;
if (fileName == null) return null;
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
File dirs = buildExternalStorageAppFilesDirs(Environment.getExternalStorageDirectory().getAbsolutePath(), context.getPackageName());
return new File(dirs, fileName);
}
return null;
}
public synchronized static File buildExternalStorageAppFilesDirs(String externalStoragePath, String packageName) {
return buildPath(externalStoragePath, DIR_ANDROID, DIR_DATA, packageName, DIR_FILES);
}
public synchronized static File buildPath(String base, String... segments) {
File cur = new File(base);
for (String segment : segments) {
cur = new File(cur, segment);
}
return cur;
}
}
Google added a new ART runtime with Android 4.4. How can I determine whether ART or Dalvik is the current runtime?
Update
At least, as early as June 2014 Google has released an official documentation on how to correctly verify the current runtime in use:
You can verify which runtime is in use by calling System.getProperty("java.vm.version"). If ART is in use, the property's value is "2.0.0" or higher.
With that, now there is no need to go through reflection and simply check the corresponding system property:
private boolean getIsArtInUse() {
final String vmVersion = System.getProperty("java.vm.version");
return vmVersion != null && vmVersion.startsWith("2");
}
One possible way is to read the respective SystemProperty through reflection.
Sample:
package com.example.getcurrentruntimevalue;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class MainActivity extends Activity {
private static final String SELECT_RUNTIME_PROPERTY = "persist.sys.dalvik.vm.lib";
private static final String LIB_DALVIK = "libdvm.so";
private static final String LIB_ART = "libart.so";
private static final String LIB_ART_D = "libartd.so";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView)findViewById(R.id.current_runtime_value);
tv.setText(getCurrentRuntimeValue());
}
private CharSequence getCurrentRuntimeValue() {
try {
Class<?> systemProperties = Class.forName("android.os.SystemProperties");
try {
Method get = systemProperties.getMethod("get",
String.class, String.class);
if (get == null) {
return "WTF?!";
}
try {
final String value = (String)get.invoke(
systemProperties, SELECT_RUNTIME_PROPERTY,
/* Assuming default is */"Dalvik");
if (LIB_DALVIK.equals(value)) {
return "Dalvik";
} else if (LIB_ART.equals(value)) {
return "ART";
} else if (LIB_ART_D.equals(value)) {
return "ART debug build";
}
return value;
} catch (IllegalAccessException e) {
return "IllegalAccessException";
} catch (IllegalArgumentException e) {
return "IllegalArgumentException";
} catch (InvocationTargetException e) {
return "InvocationTargetException";
}
} catch (NoSuchMethodException e) {
return "SystemProperties.get(String key, String def) method is not found";
}
} catch (ClassNotFoundException e) {
return "SystemProperties class is not found";
}
}
}
Hope this helps.
For anyone needing a JNI version:
#include <sys/system_properties.h>
static bool isArtEnabled() {
char buf[PROP_VALUE_MAX] = {};
__system_property_get("persist.sys.dalvik.vm.lib.2", buf);
// This allows libartd.so to be detected as well.
return strncmp("libart", buf, 6) == 0;
}
Or if you want to follow a code path closer to what shoe rat posted,
static bool isArtEnabled(JNIEnv *env)
{
// Per https://developer.android.com/guide/practices/verifying-apps-art.html
// if the result of System.getProperty("java.vm.version") starts with 2,
// ART is enabled.
jclass systemClass = env->FindClass("java/lang/System");
if (systemClass == NULL) {
LOGD("Could not find java.lang.System.");
return false;
}
jmethodID getProperty = env->GetStaticMethodID(systemClass,
"getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
if (getProperty == NULL) {
LOGD("Could not find java.lang.System.getProperty(String).");
return false;
}
jstring propertyName = env->NewStringUTF("java.vm.version");
jstring jversion = (jstring)env->CallStaticObjectMethod(
systemClass, getProperty, propertyName);
if (jversion == NULL) {
LOGD("java.lang.System.getProperty('java.vm.version') did not return a value.");
return false;
}
const char *version = env->GetStringUTFChars(jversion, JNI_FALSE);
// Lets flip that check around to better bullet proof us.
// Consider any version which starts with "1." to be Dalvik,
// and all others to be ART.
bool isArtEnabled = !(strlen(version) < 2 ||
strncmp("1.", version, 2) == 0);
LOGD("Is ART enabled? %d (%s)", isArtEnabled, version);
env->ReleaseStringUTFChars(jversion, version);
return isArtEnabled;
}
The Android docs actually give the following suggestion:
You can verify which runtime is in use by calling System.getProperty("java.vm.version"). If ART is in use, the property's value is "2.0.0" or higher.
This seems accurate on my Nexus 4 w/ ART enabled (running Android 4.4.4). Nexus 5 on Dalvik returned 1.6.0.
A simple solution :
String vm = System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version");
On my Android 8.0 (API 26) phone, it returns Dalvik 2.1.0 .
I think you should be able to use System.getProperty with java.vm.name as the key.
In the JavaDoc its value is Dalvik, which let's hope it is Art or ART when using that runtime. It's worth a try...
final String vm = VMRuntime.getRuntime().vmLibrary();
and then compare vm with "libdvm.so" or "libart.so" to check if it is Dalvik or ART.
Reference: https://gitorious.org/cyandreamproject/android_frameworks_base/commit/4c3f1e9e30948113b47068152027676172743eb1
I've wrote android app with native shared library ( libnativeext.so ).
Inside java class in app I load libnativeext.so with
System.loadLibrary("nativeext").
All works great.
Native code compiles, and libnativeext.so places in /libs/armeabi/ folder.
So final first.apk file contains /lib/armeabi/libnativeext.so, installs on device and all work ok.
Then I export project in javaext.jar.
At this point javaext.jar contains libnativeext.so in /libs/armeabi/.
In the new project (second-proj) I include javaext.jar and add path to javaext.jar in java build path.
Project builds with only warning about native library in javaext.jar.
I disable warning in eclipse preferences.
But on device I got: java.lang.UnsatisfiedLinkError: Couldn't load nativeext: findLibrary returned null
Strange, because second.apk have /libs/armeabi/libnativeext.so inside. I go to phone and figure out than folder on phone /data/data/myapp/lib/ is EMPTY! And ofcourse System.loadLibrary can't find libnativeext.so.
I find solution for myself, but it looks very ugly, and I want to find better way.
I create inside existing second-proj/libs/ folder armeabi and place libnativeext.so inside.
second-proj:
/libs/armeabi/libnativeext.so
/libs/javaext.jar
When I build project, I look inside second.apk:
/lib/armeabi/libnativeext.so <--- new one
/libs/armeabi/libnativeext.so
And this version work perfect on the phone.
So I assume, that during installation libraries from /libs/armeabi/ is ignored, and only libraries from /lib/armeabi/ is installed on the phone.
So question is: How to force apk bulder to copy *.so from *.jar to right *.apk folder?
In case there are no way to pack *.so library from included *.jar into final *.apk I solve this problem for myself.
I write LibraryLoader, which:
Tries to load library with System.loadLibrary().
If it fails, loader search library in application storage, and if find loads it with System.load().
If no library was found in the app storage, it find .apk file, serch there, and if loader find library - copies it to app storage, then loads it with System.load().
Post code here - may be it helps somebody.
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import android.content.Context;
import android.util.Log;
public class SharedLibraryLoader
{
private static Context context;
private static String libDir = "lib";
private static String shortLibName;
private static String fullLibName;
static public boolean loadLibrary(String libName, Context ctx)
{
context = ctx;
shortLibName = libName;
fullLibName = "lib" + libName + ".so";
try
{
Log.d("SharedLibraryLoader", "Trying to load library");
System.loadLibrary(shortLibName);
Log.d("SharedLibraryLoader", "Library was loaded from default location");
return true;
}
catch(UnsatisfiedLinkError e)
{
Log.d("SharedLibraryLoader","Lib wasn't found at default location. Trying to find in application private storage");
String path = null;
path = findInAppStorage(fullLibName);
if(path != null)
{
Log.d("SharedLibraryLoader","Lib was found in application private storage. Loading lib...");
System.load(path);
return true;
}
else
{
Log.d("SharedLibraryLoader","Lib was not found in application private storage. Trying to find in apk...");
path = findInApkAndCopyToAppStorage(fullLibName);
if(path != null)
{
Log.d("SharedLibraryLoader","Lib was found in apk and copied to application private storage. Loading lib...");
System.load(path);
return true;
}
else
{
Log.d("SharedLibraryLoader", "FAILED TO LOAD LIBRARY");
return false;
}
}
}
}
static private String findInAppStorage(String libName)
{
Log.d("SharedLibraryLoader","enter findInAppStorage()");
String basePath = context.getApplicationInfo().dataDir;
File dataDir = new File(basePath);
String[] listFiles;
String lib = null;
listFiles = dataDir.list();
for(int i=0; i < listFiles.length; i++)
{
lib = findInStorage(basePath + "/" +listFiles[i], libName);
if(lib != null)
{
return lib;
}
}
Log.d("SharedLibraryLoader", "Lib wasn't found.");
return null;
}
static private String findInStorage(String path, String nameOfLib)
{
File file = new File(path);
if(file.isDirectory())
{
Log.d("SharedLibraryLoader","Strorage__dir: " + path + "/");
String[] list = file.list();
String target = null;
for(int i = 0; i < list.length; i++)
{
target = findInStorage(path + "/" + list[i], nameOfLib);
if(target != null)
{
return target;
}
}
}
else
{
Log.d("SharedLibraryLoader","Strorage_file: " + path);
if(path.contains(nameOfLib))
{
Log.d("SharedLibraryLoader","Lib was found in: " + path);
return path;
}
}
return null;
}
static private String findInApkAndCopyToAppStorage(String libName)
{
Log.d("SharedLibraryLoader", "Enter findInApkAndCopyToStorage()");
// ---------------- ZIP - find path to .so inside .apk ------------------
String apkPath = context.getPackageResourcePath();
Log.d("SharedLibraryLoader", String.format("Path to Package resource is: %s", apkPath));
try
{
ZipFile zf = new ZipFile(apkPath);
Enumeration<ZipEntry> zipFiles = (Enumeration<ZipEntry>) zf.entries();
ZipEntry soZipEntry = null;
ZipEntry tempZipEntry;
String tmpString;
for ( ; zipFiles.hasMoreElements();)
{
tempZipEntry = zipFiles.nextElement();
tmpString = tempZipEntry.getName();
if(tmpString.contains(libName))
{
Log.d("SharedLibraryLoader", "Library " + fullLibName + " was found in: " + tmpString);
soZipEntry = tempZipEntry;
}
}
//----------now copy library---------------
Log.d("SharedLibraryLoader", "soZipEntry = " + soZipEntry.toString());
if(soZipEntry != null)
{
InputStream soInputStream = zf.getInputStream(soZipEntry);
File fileDir;
File soFile;
OutputStream outStream;
fileDir = context.getApplicationContext().getDir(libDir, Context.MODE_PRIVATE); // but "app_lib" was created!
String fullSoFilePath = fileDir.getAbsolutePath() + "/" + libName;
Log.d("SharedLibraryLoader", "New libpath is "+ fullSoFilePath);
soFile = new File(fullSoFilePath);
Log.d("SharedLibraryLoader", "Is file already exists? - " + soFile.exists());
outStream = new BufferedOutputStream(new FileOutputStream(soFile));
Log.d("SharedLibraryLoader", "Start copying library...");
byte[] byteArray = new byte[256];
int copiedBytes = 0;
while((copiedBytes = soInputStream.read(byteArray)) != -1)
{
outStream.write(byteArray, 0, copiedBytes);
}
Log.d("SharedLibraryLoader", "Finish copying library");
outStream.close();
soInputStream.close();
return fullSoFilePath;
}
else
{
Log.d("SharedLibraryLoader", "Library not Found in APK");
return null;
}
}
catch (IOException e)
{
e.printStackTrace();
return null;
}
}
}