itinance / itinance/react-native-fs

[Android] can not access res file with readFileRes

Open
#1,020 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

ReactNative version: 0.64.2 react-native-cli project

I had try to access with code:
```javascript
const RNFS = require('react-native-fs');
RNFS.readFileRes('abc_btn_borderless_material.xml','base64').then(console.log).catch(console.log)
```

It shows in logcat( both debug & release):

> [Error: Resource ID #0x0]

I had read the code seems nothing wrong:
https://github.com/itinance/react-native-fs/blob/master/android/src/main/java/com/rnfs/RNFSManager.java#L306

and build cache shows that the apk contains the resource:

> android/app/build/intermediates/runtime_symbol_list/debug/R.txt
> android/app/build/intermediates/runtime_symbol_list/release/R.txt

both relative path contains:

> int drawable abc_btn_borderless_material 0x7f070008

besides:
getResIdentifier will not work when access `ic_launcher.png` for it is a mipmap:

> int mipmap ic_launcher 0x7f0c0001

I will use readFileAssets to access package file instead, before this issue had solved

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.