2

I am trying to build a mobile app using reactnative and testing on android emulator but when i run the app using npm run android it fails . I tried modifyiing the gradle.build file (upgrading sdk version to 31 ..) but nothing works. npm install works perfectly with no vulnerabilities.
This is the output of the command :

>react-native run-android
    
    warn Package react-native-vector-icons has been ignored because it contains invalid configuration. Reason: "dependency.assets" is not allowed
    info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
    (node:16364) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
    (Use `node --trace-warnings ...` to show where the warning was created)
    Jetifier found 1186 file(s) to forward-jetify. Using 12 workers...
    info Starting JS server...
    info Installing the app...
    > Task :app:mergeDebugAssets FAILED
    
    Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
    Use '--warning-mode all' to show the individual deprecation warnings.
    See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
    23 actionable tasks: 23 executed
    Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01      
    Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01    
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Warning: �l�ment inattendu (URI : "", local : "base-extension"). Les �l�ments attendus sont <{}codename>,<{}layoutlib>,<{}api-level>
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:mergeDebugAssets'.
    > Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
       > Failed to transform react-native-reanimated-69-jsc.aar (project :react-native-reanimated) to match attributes {artifactType=android-assets}.
          > Execution failed for JetifyTransform: C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\react-native-reanimated\android\react-native-reanimated-69-jsc.aar.
             > Transform's input file does not exist: C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\react-native-reanimated\android\react-native-reanimated-69-jsc.aar. (See https://issuetracker.google.com/issues/158753935)
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 8s
    
    error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
    Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
    Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Warning: �l�ment inattendu (URI : "", local : "base-extension"). Les �l�ments attendus sont <{}codename>,<{}layoutlib>,<{}api-level>
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:mergeDebugAssets'.
    > Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
       > Failed to transform react-native-reanimated-69-jsc.aar (project :react-native-reanimated) to match attributes {artifactType=android-assets}.
          > Execution failed for JetifyTransform: C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\react-native-reanimated\android\react-native-reanimated-69-jsc.aar.
             > Transform's input file does not exist: C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\react-native-reanimated\android\react-native-reanimated-69-jsc.aar. (See https://issuetracker.google.com/issues/158753935)
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 8s
    
        at makeError (C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\execa\index.js:174:9)
        at C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\execa\index.js:278:16
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at async runOnAllDevices (C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
        at async Command.handleAction (C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\@react-native-community\cli\build\index.js:192:9)
    info Run CLI with --verbose flag for more details.

3 Answers3

0

Go to your babel.config and adding "plugins: ['react-native-reanimated/plugin']".

Your babel.config.js file should look like this

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: ['react-native-reanimated/plugin'],
};

check in your android/app/build.gradle if you have the correct configuration in order to apply react-native-vector-icons. that config should look like this:

project.ext.vectoricons = [
    iconFontNames: [ 'Ionicons.ttf' ] // Name of the font files you want to copy
]

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

Try cleaning your project: using the following commands. Run one by one (note if you are using yarn you can change npm install and instead use yarn install)

watchman watch-del-all
rm -rf yarn.lock package-lock.json node_modules
rm -rf android/app/build
rm ios/Pods ios/Podfile.lock 
rm -rf ~/Library/Developer/Xcode/DerivedData
npm install && cd ios && pod update && cd ..
npm start -- --reset-cache

Use the following command in your terminal to run your project:

npx react-native run-android ... for android 

npx react-native run-ios ... for ios
Jun De Leon
  • 331
  • 3
  • 11
  • It didn't work, here's the output: error Failed to install the app. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * Where: Build file 'C:\Users\*****\react-navigation-v6-mix\node_modules\react-native-reanimated\android\build.gradle' line: 152 * What went wrong: A problem occurred evaluating project ':react-native-reanimated'. > Could not get unknown property 'rnMinorVersion' for project ':react-native-reanimated' of type org.gradle.api.Project. – Emna Gharsalli Jun 23 '22 at 02:11
  • Go to your babel.config and Just adding "plugins: ['react-native-reanimated/plugin']", your babel.config.js file should look like this: module.exports = { presets: ['module:metro-react-native-babel-preset'], plugins: ['react-native-reanimated/plugin'], }; – Jun De Leon Jun 23 '22 at 19:05
  • I edited my answer in order to you see it better. You have to clean your project again. – Jun De Leon Jun 23 '22 at 19:08
0

step 1. Create a folder 'fonts' in following path 'android\app\src\main\assets'. make sure 'f' of 'fonts' is small.

step 2. Copy all files from 'node_modules\react-native-vector-icons\Fonts' and past it in 'android\app\src\main\assets\fonts'.

step 3. Delete your existing app from emulator and run again.

vicky
  • 1,546
  • 1
  • 18
  • 35
0
npm install react-native-vector-icons@9.2.0 --save
or
yarn add react-native-vector-icons@9.2.0 --save
naveed ahmed
  • 161
  • 1
  • 6