kraffslol / react-native-braintree-xplat

Cross-platform Braintree module for React Native
MIT License
81 stars 121 forks source link

Failed to build on android (resource not found) #114

Closed asifalikhokhar closed 5 years ago

asifalikhokhar commented 5 years ago

It works fine when I do react-native run-android.

But when I'm doing assembleRelease, build fails with following error:

Execution failed for task ':react-native-braintree-xplat:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  Output:  error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
  error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
  /Users/asifali/Documents/AppManic/BeachBandits/BeachBandits/node_modules/react-native-braintree-xplat/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:7: error: resource android:attr/colorError not found.
  /Users/asifali/Documents/AppManic/BeachBandits/BeachBandits/node_modules/react-native-braintree-xplat/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:11: error: resource android:attr/colorError not found.
  /Users/asifali/Documents/AppManic/BeachBandits/BeachBandits/node_modules/react-native-braintree-xplat/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
  /Users/asifali/Documents/AppManic/BeachBandits/BeachBandits/node_modules/react-native-braintree-xplat/android/build/intermediates/res/merged/release/values/values.xml:254: error: resource android:attr/fontStyle not found.
  /Users/asifali/Documents/AppManic/BeachBandits/BeachBandits/node_modules/react-native-braintree-xplat/android/build/intermediates/res/merged/release/values/values.xml:254: error: resource android:attr/font not found.
  /Users/asifali/Documents/AppManic/BeachBandits/BeachBandits/node_modules/react-native-braintree-xplat/android/build/intermediates/res/merged/release/values/values.xml:254: error: resource android:attr/fontWeight not found.
  error: failed linking references.
asifalikhokhar commented 5 years ago

I must share this solution with whoever is facing the same:

Add this to root of your project level build.gradle (android/build.gradle)

subprojects {
    afterEvaluate {project ->
    // force libs to use recent buildtools
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion = 27  // change to match your desired version
                buildToolsVersion = "27.0.3" // ....
            }
        }
    }
}