question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[android] need to update "build.gradle" file to avoid release build errors when compileSdkVersion is 27

See original GitHub issue

Issue

When making an android release build, with this config in my project:


// from myapp/android/build.gradle

classpath 'com.android.tools.build:gradle:3.1.3'

...

buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
implementationSdkVersion = 27
targetSdkVersion = 27
supportLibVersion = "27"

it fails with this errors:



> Task :app:bundleReleaseJsAndAssets 
warning: the transform cache was reset.
Loading dependency graph, done.
bundle: Writing bundle output to: /Users/user/...path.../android/app/build/generated/assets/react/release/index.android.bundle
bundle: Done writing bundle output
bundle: Copying 20 asset files
bundle: Done copying assets

error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
/Users/user/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/a2910aa9b026ed50223f50c36bfea612/res/values-v26/values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.
    
/Users/user/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/a2910aa9b026ed50223f50c36bfea612/res/values-v26/values-v26.xml:13:5-16:13: AAPT: error: resource android:attr/colorError not found.
    
/Users/user/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/a2910aa9b026ed50223f50c36bfea612/res/values-v26/values-v26.xml:17:5-93: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
    
/Users/user/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/a2910aa9b026ed50223f50c36bfea612/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/fontStyle not found.
    
/Users/user/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/a2910aa9b026ed50223f50c36bfea612/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/font not found.
    
/Users/user/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/a2910aa9b026ed50223f50c36bfea612/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/fontWeight not found.
    
error: failed linking references.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-youtube:verifyReleaseResources'.
> 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. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 13s
191 actionable tasks: 16 executed, 175 up-to-date
error Command failed with exit code 1.

Solution

I’ve done the same as mentioned in this react-native-audio’s PR named “Use sdk, buildTools and support lib versions from root project”.

Go to the node_modules/react-native-youtube/android/build.gradle file and:


buildscript {
    repositories {
        jcenter()
    }

   dependencies {
        classpath 'com.android.tools.build:gradle:1.1.3'
    }
}

apply plugin: 'com.android.library'

def DEFAULT_COMPILE_SDK_VERSION = 23
def DEFAULT_BUILD_TOOLS_VERSION = "23.0.1"
def DEFAULT_TARGET_SDK_VERSION = 22
def DEFAULT_SUPPORT_LIB_VERSION = "23.1.0"

android {
    compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
    buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
        versionCode 1
        versionName "1.0"
    }
    lintOptions {
        abortOnError false
    }
}

repositories {
    mavenCentral()
}

def supportVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.supportLibVersion : DEFAULT_SUPPORT_LIB_VERSION


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:${supportVersion}'
    compile 'com.facebook.react:react-native:+'
}



Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:15
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
cadesalaberrycommented, Jul 25, 2019
1reaction
webdevbyjosscommented, Dec 26, 2018

Definitely deserves to be merged!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix Gradle error when change SDK version 26 to 28
Error clearly mentioned that you are using two version of support library 28.0.0 and 26.1.0. Please make all 28.0.0.
Read more >
Build fails for android targetSdkVersion = 27 #48 - GitHub
I have created new empty app and have added Adjust SDK via npm repo. build.gradle file is set to reflect exact environment you...
Read more >
CompileSdkVersion and targetSdkVersion — what is the ...
In this article, we'll take a closer look at two values that are set in the build.gradle file: compileSdkVersion and targetSdkVersion.
Read more >
Android Gradle plugin release notes - Android Developers
If the specified plugin version has not been downloaded, Gradle downloads it the next time you build your project or click File >...
Read more >
Android Platform Guide - Apache Cordova
If you need to customize build.gradle , rather than edit it directly, you should create a sibling file named build-extras.gradle . This file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found