unimonkiez / react-native-asset

Linking and unlinking of assets 🔥
302 stars 52 forks source link

It works on iOS, but not on Android #60

Closed fershibli closed 11 months ago

fershibli commented 12 months ago

Description

The project was already running on both iOS and Android without errors. I followed the steps of a Youtube tutorial and checked on many different sources, including this repository’s README.md. One of the steps, for making it run on both systems (Android and iOS), consisted in naming the font files with their fullnames (for example: "GT Walsheim Bold.otf") Then it worked on iOS, through Xcode Simulator. But it didn't work on Android Studio's Device. Am I missing some kind of configuration on Android side?

Environment

react-native.config.js

module.exports = {
  assets: ['./assets/fonts/'],
  dependencies: {
    'react-native-vector-icons': {
      platforms: {
        ios: null,
      },
    },
  },
};

link-assets-manifest.json

{
  "migIndex": 1,
  "data": [
    {
      "path": "assets/fonts/GT Walsheim Bold.otf",
      "sha1": "cc9e24e3705080cfc84a5875408670c4c6f6274e"
    },
    {
      "path": "assets/fonts/Inter Bold.otf",
      "sha1": "889ba4eaa4088d73f33cc98ae4ef907b4072c6a5"
    },
    {
      "path": "assets/fonts/Inter Light BETA.otf",
      "sha1": "b888e437c703a2efea8f39ed36512fe964891f53"
    },
    {
      "path": "assets/fonts/Inter Medium.otf",
      "sha1": "ca1fd951ca585d18be345331da8055e027072511"
    },
    {
      "path": "assets/fonts/Inter Regular.otf",
      "sha1": "d32253389158b0e08276b7a4e1401a5e779a1d0f"
    },
    {
      "path": "assets/fonts/Inter Semi Bold.otf",
      "sha1": "3cb26a799cf631657608fd2a2dd60b2502537bde"
    }
  ]
}

Attempts

Observations

Android Studio presents TWO different assets/fonts folders on the same hierarchy: one with my custom fonts, the other with other fonts that I didn't knew I had, but when I select it the top bar says "ReactNativeVectorIcons>fonts" (as shown bellow). Is it possible that they are conflicting?

Screenshot 2023-11-14 at 15 26 53

If there's any other information that you need from my part, please ask away and I'll provide it asap.

fershibli commented 12 months ago

Just to highlight something that may get behind during the reading of my previous text: I tried to replace all the fonts with ttf, but it still didn't work on Android, but it worked on iOS. My guesses:

fershibli commented 12 months ago

Another update: I did try to rename all the fonts without spaces or dashes, as described on this video tutorial. It didn't work, but I might try it on Linux once I get home. This looks like something really tricky...

fershibli commented 11 months ago

I tried on Linux, but it didn't work neither... I'm convinced that this must be a conflict with react-native-vector-icons. (OR I'm missing a step)

fershibli commented 11 months ago

Fixed by removing react-native-splash-screen from the project and making the whole process again for adding fonts from scratch, but using a different name scheme for each platform using const FONTS = { ..., Platform.select({ ios: ""., android: "" }) as described on the previous video tutorial that I mentioned.

Good luck for you that are reading, I hope this helps you with your own issue.

fershibli commented 11 months ago

Just to address that I added back react-ntive-splash-screen to my project, since the issue that I had with TextInput was solved and it also solved the conflict with fonts. TYSM @sunjaaa