[Android] Check accessability before dynamically setting resource ids

When not used as Android Library, the resource ids in R.java will
be final. To avoid a lot of warning messages in such case, check
accessability before trying to set values.
Merge pull request #1650 from wang16/core_library_refine

[Android] Check accessability before dynamically setting resource ids