Acceda a la clase R de Android generada desde el código nativo

I'm wondering if there is a way to access R class attribute from native code, I need it to read some generated ID that may change every time i do a clean build of my project and I would prefer not to pass them manually to the native part.

EDITAR As suggested from @trashkalmar here is the solution:

static const char* const strClassName = "your/app/package/R$string";
clazz = env->FindClass(strClassName);
if (clazz == NULL) {
    LOGE("Can't find class %s\n", strClassName);
    return result;
jfieldID field = env->GetStaticFieldID(clazz , "you_string_resource", "I");
jint value = env->GetStaticIntField(clazz, field);

preguntado el 08 de noviembre de 11 a las 17:11

Please provide more detail, what are you trying to implement actually? It would be easy to understand exactly if you share your problem exactly. -

It is a common problem: I would like to access to all R attribute without having to pass it manually to the native part, something like the way you can access to assets resources. -

1 Respuestas

Access your R class and read its fields as any other classes.

respondido 22 nov., 11:02

It was really so simple... Thanks for the hint! :) - dmarcato

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.