drawable/rn_edit_text_material (aka com.listnbuy:drawable/rn_edit_text_material) not found in react-native

Viewed 352

Hy, I'm creating an application in react-native but while building the app I'm getting this error.

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 app:installDebug -PreactNativeDevServerPort=8081
Note: /Users/apple/Desktop/home-work/listNBuy/node_modules/@react-native-community/checkbox/android/src/main/java/com/reactnativecommunity/checkbox/ReactCheckBoxEvent.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: [2] Wrote GeneratedAppGlideModule with: [com.bumptech.glide.integration.okhttp3.OkHttpLibraryGlideModule, com.dylanvann.fastimage.FastImageOkHttpProgressGlideModule]
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/apple/Desktop/home-work/listNBuy/node_modules/react-native-localization/android/src/main/java/com/babisoft/ReactNativeLocalization/ReactNativeLocalization.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/apple/Desktop/home-work/listNBuy/node_modules/rn-android-keyboard-adjust/android/src/main/java/com/tclado/androidkeyboardadjust/AndroidKeyboardAdjustModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking failed
     ERROR:/Users/apple/Desktop/home-work/listNBuy/android/app/src/main/res/values/styles.xml:4:5-7:13: AAPT: error: resource drawable/rn_edit_text_material (aka com.listnbuy:drawable/rn_edit_text_material) not found.
         

* 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 1m 16s

    at makeError (/Users/apple/Desktop/home-work/listNBuy/node_modules/execa/index.js:174:9)
    at /Users/apple/Desktop/home-work/listNBuy/node_modules/execa/index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (/Users/apple/Desktop/home-work/listNBuy/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
    at async Command.handleAction (/Users/apple/Desktop/home-work/listNBuy/node_modules/@react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I tried reinstalling the node modules, gradlew clean and some more things that I find on the internet to solve but was unable to resolve. Can anyone what is this error and how we can fix it in react-native.

2 Answers

error: resource drawable/rn_edit_text_material (aka com.listnbuy:drawable/rn_edit_text_material) not found

Does drawable really exist?

If not, I found rn_edit_text_material.xml source code. Put it, for example, in the <your-project-name>/android/<your-module-name>/src/main/res/drawable folder

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
          http://www.apache.org/licenses/LICENSE-2.0
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
       android:insetLeft="@dimen/abc_edit_text_inset_horizontal_material"
       android:insetRight="@dimen/abc_edit_text_inset_horizontal_material"
       android:insetTop="@dimen/abc_edit_text_inset_top_material"
       android:insetBottom="@dimen/abc_edit_text_inset_bottom_material">

    <selector>
        <!-- 
          This file is a copy of abc_edit_text_material (<shortened link, forbidden by stackoverflow>).
          The item below with state_pressed="false" and state_focused="false" causes a NullPointerException.
          NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)'
          <item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
          For more info, see <shortened link, forbidden by stackoverflow> (react-native/pull/29452) and <shortened link, forbidden by stackoverflow>.
        -->
        <item android:state_enabled="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
        <item android:drawable="@drawable/abc_textfield_activated_mtrl_alpha"/>
    </selector>

</inset>

make sure your emulator has enough space to accommodate the build. Had similar issue, got it fixed by uninstalling some other app on the Emulator and it works fine

Related