android.renderscript.RSRuntimeException Fatal error 4097 - android

I'm getting the following crash from renderscript on android:
100% of the crashes are on android 11 and 96% of the crashes are on Samsung devices. I removed all instances of renderscript, but this crash is still happening so maybe it's in one of my dependencies.
I found this got android.renderscript.RSRuntimeException on note4 which says that 4097 means a fatal driver error, but doesn't give any details on how to fix it.
Does anyone know how I can fix this crash?
UPDATE: when I search for "renderscript" in my app nothing comes up unless I put it on scope and then there's a bunch of references to it. I don't understand where they're coming from though
UPDATE: To be clear, I have removed all references to renderscript from my app but it seems like one or multiple of my dependencies are still using it. I need help isolating these dependencies. Something called android-30 is using renderscript. Is this the api 30 library or something? And then something called support/v8 is using renderscript. Is this the support library? (I do have support library enabled)

Migrate from RenderScript
RenderScript APIs are deprecated starting in Android 12. They will
continue to function, but we expect that device and component
manufacturers will stop providing hardware acceleration support over
time.
It seems to be a vendors issue (Driver issue)
Fatal error 4097: RS_ERROR_FATAL_UNKNOWN = 0x1000
static class MessageThread extends Thread {
RenderScript mRS;
boolean mRun = true;
int[] mAuxData = new int[2];
static final int RS_MESSAGE_TO_CLIENT_NONE = 0;
static final int RS_MESSAGE_TO_CLIENT_EXCEPTION = 1;
static final int RS_MESSAGE_TO_CLIENT_RESIZE = 2;
static final int RS_MESSAGE_TO_CLIENT_ERROR = 3;
static final int RS_MESSAGE_TO_CLIENT_USER = 4;
static final int RS_MESSAGE_TO_CLIENT_NEW_BUFFER = 5;
static final int RS_ERROR_FATAL_DEBUG = 0x0800;
static final int RS_ERROR_FATAL_UNKNOWN = 0x1000;
MessageThread(RenderScript rs) {
super("RSMessageThread");
mRS = rs;
}
public void run() {
// This function is a temporary solution. The final solution will
// used typed allocations where the message id is the type indicator.
int[] rbuf = new int[16];
mRS.nContextInitToClient(mRS.mContext);
while(mRun) {
rbuf[0] = 0;
int msg = mRS.nContextPeekMessage(mRS.mContext, mAuxData);
int size = mAuxData[1];
int subID = mAuxData[0];
if (msg == RS_MESSAGE_TO_CLIENT_USER) {
if ((size>>2) >= rbuf.length) {
rbuf = new int[(size + 3) >> 2];
}
if (mRS.nContextGetUserMessage(mRS.mContext, rbuf) !=
RS_MESSAGE_TO_CLIENT_USER) {
throw new RSDriverException("Error processing message from RenderScript.");
}
if(mRS.mMessageCallback != null) {
mRS.mMessageCallback.mData = rbuf;
mRS.mMessageCallback.mID = subID;
mRS.mMessageCallback.mLength = size;
mRS.mMessageCallback.run();
} else {
throw new RSInvalidStateException("Received a message from the script with no message handler installed.");
}
continue;
}
if (msg == RS_MESSAGE_TO_CLIENT_ERROR) {
String e = mRS.nContextGetErrorMessage(mRS.mContext);
// Throw RSRuntimeException under the following conditions:
//
// 1) It is an unknown fatal error.
// 2) It is a debug fatal error, and we are not in a
// debug context.
// 3) It is a debug fatal error, and we do not have an
// error callback.
if (subID >= RS_ERROR_FATAL_UNKNOWN ||
(subID >= RS_ERROR_FATAL_DEBUG &&
(mRS.mContextType != ContextType.DEBUG ||
mRS.mErrorCallback == null))) {
throw new RSRuntimeException("Fatal error " + subID + ", details: " + e);
}
if(mRS.mErrorCallback != null) {
mRS.mErrorCallback.mErrorMessage = e;
mRS.mErrorCallback.mErrorNum = subID;
mRS.mErrorCallback.run();
} else {
android.util.Log.e(LOG_TAG, "non fatal RS error, " + e);
// Do not throw here. In these cases, we do not have
// a fatal error.
}
continue;
}
if (msg == RS_MESSAGE_TO_CLIENT_NEW_BUFFER) {
if (mRS.nContextGetUserMessage(mRS.mContext, rbuf) !=
RS_MESSAGE_TO_CLIENT_NEW_BUFFER) {
throw new RSDriverException("Error processing message from RenderScript.");
}
long bufferID = ((long)rbuf[1] << 32L) + ((long)rbuf[0] & 0xffffffffL);
Allocation.sendBufferNotification(bufferID);
continue;
}
// 2: teardown.
// But we want to avoid starving other threads during
// teardown by yielding until the next line in the destructor
// can execute to set mRun = false
try {
sleep(1, 0);
} catch(InterruptedException e) {
}
}
//Log.d(LOG_TAG, "MessageThread exiting.");
}
}

Related

How can I use libusb to send/receive data from ubuntu to Android?

The goal I'm looking to achieve is to send/receive data to/from an Android device from a Linux server. I feel like I've tried all the examples I could find on the Internet as well as reading the libusb APIs, which don't talk at my level of a total noob. Here's what I've got so far:
I've written a program that runs on a Ubuntu server (ARMx64), from examples, I have the following code:
//Error handling removed for brevity
#define BULK_EP_IN 0x08
main(int argc, char* argv) {
libusb_context* libusb_ctxt;
int status;
bool libusb_err = false;
libusb_device** libusb_dvcs = NULL;
bool error = false;
unsigned vid = 0, pid = 0;
unsigned busnum = 0, devaddr = 0, _busnum, _devaddr;
struct libusb_device_descriptor desc;
status = libusb_init(&libusb_ctxt);
if (status < 0) {
libusb_err = true;
}
if (libusb_get_device_list(NULL, &libusb_dvcs) < 0) {
error = true;
} else {
libusb_device *dev = NULL;
for (uint16_t idx = 0; (dev = libusb_dvcs[idx]) != NULL; idx++) {
_busnum = libusb_get_bus_number(dev);
_devaddr = libusb_get_device_address(dev);
status = libusb_get_device_descriptor(dev, &desc);
if (status >= 0) {
if (desc.idVendor == vid_arg && desc.idProduct == pid_arg) {
vid = desc.idVendor;
pid = desc.idProduct;
busnum = _busnum;
devaddr = _devaddr;
fnd_dev = dev;
break;
}
}
}
if (fnd_dev == NULL) {
error = true;
} else {
libusb_device_handle* dev_hnd = NULL;
//Connect to device and write data to it.
dev_hnd = libusb_open_device_with_vid_pid(NULL, vid, pid);
if (dev_hnd) {
char str1[64], str2[64];
int e = 0,config2;
char my_string[64];
int length = 0;
int transferred = 0;
e = libusb_get_string_descriptor_ascii(dev_hnd, desc.iManufacturer, (unsigned char*)str1, sizeof(str1));
if (e < 0) {
break;
}
e = libusb_get_string_descriptor_ascii(dev_hnd, desc.iProduct, (unsigned char*)str2, sizeof(str2));
if(e < 0) {
break;
}
e = libusb_get_configuration(dev_hnd, &config2);
if (e == 0) {
if (config2 != 1)
{
libusb_set_configuration(dev_hnd, 1);
if (e!=0) {
libusb_err = true;
}
}
if (!libusb_err) {
if (libusb_kernel_driver_active(dev_hnd, 0) == 1) {
if (libusb_detach_kernel_driver(dev_hnd, 0) == 1) {
libusb_err = true;
}
}
if (!libusb_err) {
e = libusb_claim_interface(dev_hnd, 0);
if (e < 0) {
libusb_err = true;
}
if (!libusb_err) {
active_config(dev, dev_hnd);
memset(my_string, '\0', 64);
strcpy(my_string, "hello sally");
length = strlen(my_string);
e = libusb_bulk_transfer(dev_hnd, BULK_EP_IN | LIBUSB_ENDPOINT_IN, (unsigned char*)my_string, length, &transferred, 0);
if (e == 0 && transferred == length) {
child_log("Write successful!");
child_log("Sent %d bytes with string: %s", transferred, my_string);
}
else {
child_log("Error in write! e = %d and transferred = %d, error desc: %s", e, transferred, libusb_error_name(e));
}
}
}
}
}
e = libusb_release_interface(dev_hnd, 0);
libusb_close(dev_hnd);
}
}
if (libusb_dvcs != NULL) {
libusb_free_device_list(libusb_dvcs, 1);
}
}
if (!libusb_err) {
libusb_exit(libusb_ctxt);
}
}
Everything works, at least doesn't report an error, until I get to the libusb_bulk_transfer call, which it returns a -1, which translates to a LIBUSB_ERROR_IO.
The USB device I'm connecting to is a Samsung Z-Fold3 mobile phone. I'm using the phone as a test OS as I don't have access to the Android tablet that will be used in the final application.
Here's my questions:
How do I know which interface to connect to?
 a) I'll have an application running on the Android device that will be using the same library, hopefully, that will receive the data sent from the Ubuntu server.
How do I know which configuration to use?
Am I doing everything correctly?
Does anyone have any code that can run on the Android to read the data that I'm sending from this code? My goal was to write a program in C that pretty much runs like the one that runs on the Ubuntu server, but reads the data. Once I have that, my next step will be to write data from the Android device to the Ubuntu server using libusb again.
Any help, advice, alternative APIs is very much appreciated.
Thank you!

PackageManager getChangedPackages always return NULL

In my app I need to monitorize recently added or updated packages, but since Oreo this is a hard task.
To do it I have a service that runs every X time to detect the new installed/updated apps.
The main core of this service is to call the getChangedPackages function from the PackageManager, but this function always returns null, even if I install or update any app from or not from the Play Store in the interval between two consequtive calls to getChangedPackages.
https://developer.android.com/reference/android/content/pm/PackageManager.html#getChangedPackages(int)
I need to request any permission to call this function? Is the getChangedPackages buggy?
private void _doProcess()
{
try
{
PackageManager package_manager = getPackageManager();
int sequence_number = ApplicationPreferences.getInteger(this, GET_CHANGED_PACKAGES_SEQUENCE_NUMBER_KEY, 0);
ChangedPackages changed_packages = package_manager.getChangedPackages(sequence_number);
LogUtilities.show(this, String.format("Retrieve recently apps installs/updates using sequence number %d returns %s", sequence_number, changed_packages == null ? "null" : "a not null object"));
if (changed_packages == null) changed_packages = package_manager.getChangedPackages(0);
LogUtilities.show(this, String.format("Retrieve recently apps installs/updates using sequence number %d returns %s", sequence_number, changed_packages == null ? "null" : "a not null object"));
if (changed_packages != null)
{
List<String> packages_names = changed_packages.getPackageNames();
LogUtilities.show(this, String.format("%d recently installed/updated apps", packages_names == null ? 0 : packages_names.size()));
if (packages_names != null) for (String package_name : packages_names) PackagesUpdatedReceiver.doProcessPackageUpdate(this, new Intent(isNewInstall(package_manager, package_name) ? Intent.ACTION_PACKAGE_ADDED : Intent.ACTION_PACKAGE_REPLACED).setData(Uri.parse(String.format("package:%s", package_name))));
LogUtilities.show(this, String.format("Storing %s is the sequence number for next iteration", changed_packages.getSequenceNumber()));
ApplicationPreferences.putInteger(this, GET_CHANGED_PACKAGES_SEQUENCE_NUMBER_KEY, changed_packages.getSequenceNumber());
}
else
{
LogUtilities.show(this, String.format("Storing %s is the sequence number for next iteration", sequence_number + 1));
ApplicationPreferences.putInteger(this, GET_CHANGED_PACKAGES_SEQUENCE_NUMBER_KEY, sequence_number + 1);
}
}
catch (Exception e)
{
LogUtilities.show(this, e);
}
}
My experimental results so far have shown that this PackageManager API method getChangedPackages() is not reliable: quite often the returned ChangedPackages value contains many unchanged packages. So I’ve decided to implement a similar feature in a class called PackageUtils, as shown below. The idea is to poll for all the installed packages, as shown in method getInstalledPackageNames() below, and compare the string list with a previously saved one. This comparison boils down to comparing 2 string lists, as shown in method operate2StringLists() below. To get a set of removed packages, use GET_1_MINUS_2_OR_REMOVED as operation. To get a set of added packages, use GET_2_MINUS_1_OR_ADDED as operation.
public class PackageUtils {
public static final int GET_1_MINUS_2_OR_REMOVED = 0;
public static final int GET_2_MINUS_1_OR_ADDED = 1;
// Get all the installed package names
public static List<String> getInstalledPackageNames(Context context) {
List<String> installedPackageNames = new ArrayList<>();
try {
PackageManager packageManager = context.getPackageManager();
List<ApplicationInfo> appInfoList = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo appInfo : appInfoList) {
installedPackageNames.add(appInfo.packageName);
}
} catch (Exception e) {
e.printStackTrace();
}
return installedPackageNames;
}
// Compare 2 string lists and return differences.
public static Set<String> operate2StringLists(List<String> pkgList1, List<String> pkgList2, int operation) {
Set<String> result = null;
Set<String> pkgSet1 = new HashSet<String>(pkgList1);
Set<String> pkgSet2 = new HashSet<String>(pkgList2);
switch (operation) {
case GET_1_MINUS_2_OR_REMOVED:
pkgSet1.removeAll(pkgSet2);
result = pkgSet1;
break;
case GET_2_MINUS_1_OR_ADDED:
pkgSet2.removeAll(pkgSet1);
result = pkgSet2;
break;
default:
break;
}
return result;
}
}
The code has been tested on an Android Oreo device. It can reliably detect all added and removed packages between 2 time instances. However, it can’t detect updated packages in-between.
Finally got it. You have to create a variable called sequenceNumber, and update it every time you query changed packages.
private static int sequenceNumber = 0;
...
PackageManager pm = getContext().getPackageManager();
ChangedPackages changedPackages = pm.getChangedPackages(sequenceNumber);
if(changedPackages != null)
sequenceNumber = changedPackages.getSequenceNumber();

Android. Error Invalid capture present 4 for AudioAttributes in 6.0

Hello friends I am working on a Incoming call recorder. Audio recording successfully in below version(I have tried in samsung galaxy s3)but when I try it in 6.0 version it gives me error E/AudioAttributes: Invalid capture preset 4 for AudioAttributes.
I have search a lot but didn't find the exact answer.Is there is a bug in android which is giving me error when i used to record the AudioSource.Voice_call.
Thanks in advance .Please i am stuck if there is any solution to record incoming call in 6.0 Please let me know any help will be appreciated.
After long time I got the answer. This is due to manufacture issue.In many countries call recording is banned.So manufactures don't allow to record uplink and downlink. There is a way you can open the mic and record it.It's the easiest way.
You need to use ndk. Here are examples of the functions that need to be done.
Load libmedia.so and libutils.so
int load(JNIEnv *env, jobject thiz) {
void *handleLibMedia;
void *handleLibUtils;
int result = -1;
lspr func = NULL;
pthread_t newthread = (pthread_t) thiz;
handleLibMedia = dlopen("libmedia.so", RTLD_NOW | RTLD_GLOBAL);
if (handleLibMedia != NULL) {
func = dlsym(handleLibMedia, "_ZN7android11AudioSystem13setParametersEiRKNS_7String8E");
if (func != NULL) {
result = 0;
}
audioSetParameters = (lasp) func;
} else {
result = -1;
}
handleLibUtils = dlopen("libutils.so", RTLD_NOW | RTLD_GLOBAL);
if (handleLibUtils != NULL) {
fstr = dlsym(handleLibUtils, "_ZN7android7String8C2EPKc");
if (fstr == NULL) {
result = -1;
}
} else {
result = -1;
}
cmd = CM_D;
int resultTh = pthread_create(&newthread, NULL, taskAudioSetParam, NULL);
return result;}
Function setParameters
int setParam(jint i, jint as) {
pthread_mutex_lock(&mt);
audioSession = (int) (as + 1);
kvp = "input_source=4";
kvps = toString8(kvp);
cmd = (int) i;
pthread_cond_signal(&cnd);
pthread_mutex_unlock(&mt);
return 0;}
Task AudioSetParameters
void *taskAudioSetParam(void *threadid) {
while (1) {
pthread_mutex_lock(&mt);
if (cmd == CM_D) {
pthread_cond_wait(&cnd, &mt);
} else if (audioSetParameters != NULL) {
audioSetParameters(audioSession, kvps);
}
pthread_mutex_unlock(&mt);
}
}
There is a library and an example of use https://github.com/ViktorDegtyarev/CallRecLib

How can I detect the Android runtime (Dalvik or ART)?

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

Error loading dictionary when modifying android LatinIME in Eclipse

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?

Categories

Resources