Sunday, December 31, 2017

FAILURE: Build failed with an exception. on existing react native app

Leave a Comment

I am facing a issue with React Native existing app code during installation in my linux OS.

Everything is setup (React Native and Android Studio )

I am facing when i am running a command

here is the error message,

:app:processDebugResources /home/akaruilabs/ReactNative/teletask/android/app/build/intermediates/res/merged/debug/values-v24/values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.  /home/akaruilabs/ReactNative/teletask/android/app/build/intermediates/res/merged/debug/values-v24/values-v24.xml:4: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.  /home/akaruilabs/ReactNative/teletask/android/app/build/intermediates/res/merged/debug/values-v24/values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.  /home/akaruilabs/ReactNative/teletask/android/app/build/intermediates/res/merged/debug/values-v24/values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.   :app:processDebugResources FAILED  FAILURE: Build failed with an exception.  * What went wrong: Execution failed for task ':app:processDebugResources'. > com.android.ide.common.process.ProcessException: Failed to execute aapt  * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.  BUILD FAILED  Total time: 16.116 secs Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/android-setup.html [bg] Exited with code 0 

Here is my build.gradle file

apply plugin: "com.android.application"  import com.android.build.OutputFile  /**  * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets  * and bundleReleaseJsAndAssets).  * These basically call `react-native bundle` with the correct arguments during the Android build  * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the  * bundle directly from the development server. Below you can see all the possible configurations  * and their defaults. If you decide to add a configuration block, make sure to add it before the  * `apply from: "../../node_modules/react-native/react.gradle"` line.  *  * project.ext.react = [  *   // the name of the generated asset file containing your JS bundle  *   bundleAssetName: "index.android.bundle",  *  *   // the entry file for bundle generation  *   entryFile: "index.android.js",  *  *   // whether to bundle JS and assets in debug mode  *   bundleInDebug: false,  *  *   // whether to bundle JS and assets in release mode  *   bundleInRelease: true,  *  *   // whether to bundle JS and assets in another build variant (if configured).  *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants  *   // The configuration property can be in the following formats  *   //         'bundleIn${productFlavor}${buildType}'  *   //         'bundleIn${buildType}'  *   // bundleInFreeDebug: true,  *   // bundleInPaidRelease: true,  *   // bundleInBeta: true,  *  *   // the root of your project, i.e. where "package.json" lives  *   root: "../../",  *  *   // where to put the JS bundle asset in debug mode  *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",  *  *   // where to put the JS bundle asset in release mode  *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",  *  *   // where to put drawable resources / React Native assets, e.g. the ones you use via  *   // require('./image.png')), in debug mode  *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",  *  *   // where to put drawable resources / React Native assets, e.g. the ones you use via  *   // require('./image.png')), in release mode  *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",  *  *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means  *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to  *   // date; if you have any other folders that you want to ignore for performance reasons (gradle  *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/  *   // for example, you might want to remove it from here.  *   inputExcludes: ["android/**", "ios/**"],  *  *   // override which node gets called and with what additional arguments  *   nodeExecutableAndArgs: ["node"]  *  *   // supply additional arguments to the packager  *   extraPackagerArgs: []  * ]  */  apply from: "../../node_modules/react-native/react.gradle"  /**  * Set this to true to create two separate APKs instead of one:  *   - An APK that only works on ARM devices  *   - An APK that only works on x86 devices  * The advantage is the size of the APK is reduced by about 4MB.  * Upload all the APKs to the Play Store and people will download  * the correct one based on the CPU architecture of their device.  */ def enableSeparateBuildPerCPUArchitecture = false  /**  * Run Proguard to shrink the Java bytecode in release builds.  */ def enableProguardInReleaseBuilds = false  android {     compileSdkVersion 23     buildToolsVersion "23.0.1"      defaultConfig {         applicationId "com.mynativeapp"         minSdkVersion 16         targetSdkVersion 22         versionCode 1         versionName "1.0"         ndk {             abiFilters "armeabi-v7a", "x86"         }     }     splits {         abi {             reset()             enable enableSeparateBuildPerCPUArchitecture             universalApk false  // If true, also generate a universal APK             include "armeabi-v7a", "x86"         }     }     buildTypes {         release {             minifyEnabled enableProguardInReleaseBuilds             proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"         }     }     // applicationVariants are e.g. debug, release     applicationVariants.all { variant ->         variant.outputs.each { output ->             // For each separate APK per architecture, set a unique version code as described here:             // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits             def versionCodes = ["armeabi-v7a":1, "x86":2]             def abi = output.getFilter(OutputFile.ABI)             if (abi != null) {  // null for the universal-debug, universal-release variants                 output.versionCodeOverride =                         versionCodes.get(abi) * 1048576 + defaultConfig.versionCode             }         }     } }  dependencies {     compile project(':react-native-splash-screen')     compile project(':react-native-navigation')     compile project(':react-native-vector-icons')     compile fileTree(dir: "libs", include: ["*.jar"])     compile "com.android.support:appcompat-v7:23.0.1"     compile "com.facebook.react:react-native:+"  // From node_modules }  // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) {     from configurations.compile     into 'libs' } 

And settings.gradle

rootProject.name = 'mynativeapp'  include ':app' include ':react-native-splash-screen' project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android') include ':react-native-navigation' project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app') include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') 

Terminal Error Image

enter image description here

I am not able to get what exactly error occurring here. Let me know for a solution.

1 Answers

Answers 1

Here are my 2 cents.

Potential fix:

  • Update your buildToolsVersion to 24.0.3 or later.
  • Update your compileSdkVersion 24 or to a newer version greater than 24.
  • Also update your appcompat library based on that. i.e compile "com.android.support:appcompat-v7:24.0.3"

P.S: You might need to download that build tools version from SDK manager. It is possible that it might not be available for download. In that case you can use the latest buildToolsVersion.

What is the potential issue:

Pay heed to these messages:

/home/akaruilabs/ReactNative/teletask/android/app/build/intermediates/res/merged/debug/values-v24/values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

...

/home/akaruilabs/ReactNative/teletask/android/app/build/intermediates/res/merged/debug/values-v24/values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.

You are using buildToolsVersion "23.0.1" and your compileSdkVersion as 23. However you have a values-24 folder. It is a directory that contains resources that will be used when the device that is running your app is on API Level 24 or higher.

The compileSdkVersion is the version of the API the app is compiled against. This means you can use Android API features included in that version of the API (as well as all previous versions). If you try and use API 24 features but set compileSdkVersion to 23, you will get a compilation error. If you set compileSdkVersion to 24, you can still run the app on a API 23 device as long as your app's execution paths do not attempt to invoke any APIs specific to API 23.

The buildToolsVersion specifies the version of the SDK Build Tools to use when building your project. Just make sure it supports the compileSdkVersion that you are using. The newer versions of buildToolsVersion support the older compileSdkVersion versions.

Useful References:

Hope this helps.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment