React-Native Android Build Failure: Execution failed for task ':app:processDebugResources'. Failed to process resources - android-gradle-plugin

I cannot figure out what is wrong with the build. I tried the common solutions of running ./gradlew clean as well as adding the android.enableAapt2=false to the gradle.properties.
The google-services.json folder is at the /android/app level.
Im at a loss right now as to how to get past this one.
If I forgot to include something useful please lmk and I will update.
Cheers
Error Output
Configure project :app
WARNING: The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.3.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Configure project :react-native-google-analytics-bridge
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Configure project :react-native-radar
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Task :app:processDebugGoogleServices
Parsing json file: /Users/kyletreman/18F/courier_test_app/android/app/google-services.json
/Users/kyletreman/.gradle/caches/transforms-1/files-1.1/appcompat-v7-23.0.1.aar/64df69838d7c555de168bdcf18f3be5c/res/values/values.xml:113:5-69: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/kyletreman/.gradle/caches/transforms-1/files-1.1/appcompat-v7-23.0.1.aar/64df69838d7c555de168bdcf18f3be5c/res/values/values.xml:113:5-69: AAPT: error: resource android:attr/ttcIndex not found.
error: failed linking references.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
Failed to process resources, see aapt output above for details.
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 2s
50 actionable tasks: 3 executed, 47 up-to-date
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/getting-started.html
/android/app/build.gradle
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.courier_test_app.app"
minSdkVersion 16
targetSdkVersion 27
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 {
implementation(project(':react-native-firebase')) {
transitive = false
}
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.android.support:support-v13:27.1.1'
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-radar')
implementation project(':react-native-google-analytics-bridge')
}
// 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'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
/android/build.gradle
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.google.gms:google-services:4.0.0'
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}

From the error log I can see that appcompat-v7-23.0.1 is still being used. So, it would probably help to update resolutionStrategy:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
force 'com.android.support:appcompat-v7-23.0.1'
}
}
Also you need to place that resolution strategy block in your app/build.gradle

Fixed
I was able to get help from someone familiar with the native side and he helped me sort out quite a few errors.
implementation order matters, this was the order that worked for me
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.android.support:support-v4:27.1.1"
implementation 'com.android.support:support-v13:27.1.1'
implementation "com.android.support:appcompat-v7:27.1.1"
implementation(project(':react-native-firebase'))
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(':react-native-radar')
implementation project(':react-native-google-analytics-bridge')
I need to move the configuration resolution strategies to the android/app/build.gradle file, mine were at the wrong level. I also had to alter versions of the support and appcompat packages. You can find dependencies via
./gradlew app:dependencies
from the android folder. The issue was one of the dependencies was pulling a older version, which was fixed by using the following in the resolutionStrategies.
force 'com.android.support:appcompat-v7:27.1.1'
The next change that needed to be made was the following line in the MainApplication.java
return BuildConfig.DEBUG;
to this
return <app_name>.BuildConfig.DEBUG;
I also removed the enableaapt2=false
The last tip I can give is that naming matters, don't rename your app unless its absolutely necessary and make sure it changes across the Main java files and AndroidMainfest.xml.
UPDATED
I realized my debugger was not connecting, it was because I removed some implementation packages that supported firebase, adding them back fixed the issue. Add the following below the firebase implementation.
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.firebase:firebase-core:16.0.1"

put this code at the end of android/build.gradle
use your own numbers for the compileSdkVersion and buildToolsVersion
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
}
}
}
}

Related

Execution failed for task ':app:mergeDebugNativeLibs' while running react-native app

While running react native app I am getting following error:
`
Task :app:mergeDebugNativeLibs 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.2/userguide/command_line_interface.html#sec:command_line_warnings
574 actionable tasks: 2 executed, 572 up-to-date
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
2 files found with path 'lib/armeabi-v7a/libfbjni.so' from inputs:
- C:\Users\nouman.gradle\caches\transforms-3\6ef14503de3c85fa1ab2aba364d580cc\transformed\jetified-react-native-0.71.0-rc.0-debug\jni
- C:\Users\nouman.gradle\caches\transforms-3\64faf76bb2f0142d731347d7bfff47d4\transformed\jetified-fbjni-0.3.0\jni
If you are using jniLibs and CMake IMPORTED targets, see
https://developer.android.com/r/tools/jniLibs-vs-imported-targets
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 32s
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
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
2 files found with path 'lib/armeabi-v7a/libfbjni.so' from inputs:
- C:\Users\nouman.gradle\caches\transforms-3\6ef14503de3c85fa1ab2aba364d580cc\transformed\jetified-react-native-0.71.0-rc.0-debug\jni
- C:\Users\nouman.gradle\caches\transforms-3\64faf76bb2f0142d731347d7bfff47d4\transformed\jetified-fbjni-0.3.0\jni
If you are using jniLibs and CMake IMPORTED targets, see
https://developer.android.com/r/tools/jniLibs-vs-imported-targets
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 32s
at makeError (D:\BayQi-Customer-Mobile-App\node_modules\execa\index.js:174:9)
at D:\BayQi-Customer-Mobile-App\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (D:\BayQi-Customer-Mobile-App\node_modules\react-native\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (D:\BayQi-Customer-Mobile-App\node_modules\#react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
`
I am trying to run my react native app in physical device but getting this error.
It was running okay but suddenly has stopped working
UPDATED ANSWER
📢 Patches for >= 0.63 We have prepared releases for all the main versions of react-native with an hotfix:
🛳 0.70.5: https://github.com/facebook/react-native/releases/tag/v0.70.5
🛳️ 0.69.7: https://github.com/facebook/react-native/releases/tag/v0.69.7
🛳 0.68.5: https://github.com/facebook/react-native/releases/tag/v0.68.5
🛳️ 0.67.5: https://github.com/facebook/react-native/releases/tag/v0.67.5
🛳️ 0.66.5: https://github.com/facebook/react-native/releases/tag/v0.66.5
🛳️ 0.65.3: https://github.com/facebook/react-native/releases/tag/v0.65.3
🛳️ 0.64.4: https://github.com/facebook/react-native/releases/tag/v0.64.4
🛳️ 0.63.5: https://github.com/facebook/react-native/releases/tag/v0.63.5
By updating to these patch versions, your Android build should start working again.
Source https://github.com/facebook/react-native/issues/35210
OLD ANSWER
Add this to your android/build.gradle,
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
If that does not work for you (with the dynamic version), then hard code your version in:
PLEASE BE CAREFUL TO MOVE THIS VERSION WHEN YOU UPDATE REACT-NATIVE
allprojects {
configurations.all {
resolutionStrategy {
force 'com.facebook.react:react-native:<your version>'
}
}
repositories {
// ...
}
}
Check this for more updates https://github.com/facebook/react-native/issues/35204
add this to your app/build.gradle
android {
// yout existing code
packagingOptions {
pickFirst '**/libc++_shared.so'
pickFirst '**/libfbjni.so'
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
// ...
}
allprojects {
repositories {
+ exclusiveContent {
+ // We get React Native's Android binaries exclusively through npm,
+ // from a local Maven repo inside node_modules/react-native/.
+ // (The use of exclusiveContent prevents looking elsewhere like Maven Central
+ // and potentially getting a wrong version.)
+ filter {
+ includeGroup "com.facebook.react"
+ }
+ forRepository {
+ maven {
+ url "$rootDir/../node_modules/react-native/android"
+ }
+ }
+ }
// ...
}
}
New patch release for react-native
https://github.com/facebook/react-native/issues/35210#:%7E:text=We%20have%20prepared%20releases%20for%20all%20the%20main%20versions%20of%20react%2Dnative%20with%20an%20hotfix%3A
just update your package.json with latest react-native version
This helped me to resolve the issue.
This is happening because all the templates reference the React Native dependency by range, like implementation com.facebook.react:react-native:+. Usually this dependency gets resolved from the local Maven repo in ./node_modules/react-native/android but, since it has been published to Maven Central, it's now grabbing the very latest RC.
You can resolve this problem by forcing the React Native dependency to the version you expect with something like this implementation com.facebook.react:react-native:0.68.2!! in your app's Gradle file. The !! is shorthand for restricting Gradle from upgrading if your project or its transitive dependencies depend on a newer version. AFAIK Maven Central is immutable and the published dependency can't removed so this might be the only solution.
File: android/app/build.gradle
dependencies {
implementation 'com.facebook.react:react-native:0.67.2!!'
}
Reference: https://github.com/facebook/react-native/issues/35204
Workaround: I have made the following changes & It is working:
In gradle-wrapper.properties file, change gradle version
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
In project level build.gradle file, add following lines:
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0")
}
allprojects {
repositories {
exclusiveContent {
// We get React Native's Android binaries exclusively through
npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like
Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
}
configurations.all {
resolutionStrategy {
force 'androidx.core:core:1.6.0'
force 'androidx.core:core-ktx:1.6.0'
}
}
In app level build.gradle, add these dependecies:
implementation 'androidx.core:core-ktx:1.6.0',
implementation 'androidx.core:core:1.6.0'
Add following lines inside the android>build.gradle file -
allprojects {
repositories {
...
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
}
This issue occurred from November 4th 2022. See the reference: https://github.com/facebook/react-native/issues/35210

Why am I getting this error in react native?

I am new to react native. When I run react-native run-android I get this error.
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\Stay Hungry\app developement\Aarogya\node_modules\react-native-share\android\build.gradle' line: 53
* What went wrong:
A problem occurred evaluating project ':react-native-share'.
> Could not find method compileOnly() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* 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: 7 mins 24.686 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/getting-started.html
I traced the path to the error location and my build.gradle is below:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
apply plugin: 'com.android.library'
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
android {
compileSdkVersion safeExtGet('compileSdkVersion', 27)
buildToolsVersion safeExtGet('buildToolsVersion', '27.0.3')
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 27)
versionCode 1
versionName "1.0.0"
}
lintOptions {
abortOnError false
warning 'InvalidPackage'
}
}
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
jcenter()
}
dependencies {
compileOnly "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
implementation "com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '27.1.0')}"
}
I have no idea what is wrong here. I have not even started writing code in app.js yet. I am using a physical device to run the code with an adb device.
The error you are getting is from the library react-native-share.
Did you follow the instructions to installing it right?

React-Native: Could not resolve all dependencies for configuration ':app:debugCompileClasspath'

I am kind of new to the react-native thing so please excuse me for maybe making stupid mistakes.
I basically tried everything I could find before posting here and by now am not sure if this is something on my end (aka me being stupid) or a bug due to recent updates somewhere.
So, my problem is the error message mentioned above which I am getting when trying to build the app (either by using react-native run-android or even with gradlew clean). I post the full error message below as well as my app/build.gradle, build.gradle and settings.gradle files.
I left all the files the way they were created by "react-native init" and "just" added the commands I had to add according to the respective libraries' installation guides.
Due to recent changes in the Firebase SDKs I had to change quite a bit when it comes to gradle version, etc. which is why I wonder if this issue has anything to do with that?!
Oh, and the version numbers:
"dependencies": {
"babel-core": "^6.26.3",
"eslint": "^4.19.1",
"fbjs": "^0.8.16",
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-firebase": "^4.1.0",
"react-native-navigation": "^1.1.458",
"react-native-vector-icons": "^4.6.0",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0"
}
I installed every package with yarn (yarn add react-native-vector-icons, etc.) and npm (npm install, as well as npm install react-native-vector-icons, etc.) to make sure it's not related to any of those. In between I removed the whole node_modules folder of course.
Neither did react-native link help.
It's also not limited to the mentioned react-native-vector-icons package: I removed it from my project completely and the same error just pops up for another package.
I appreciate any help and hints!
Thank you very much in advance!
Dustin
ERROR MESSAGE:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.
> More than one variant of project :react-native-vector-icons matches the consumer attributes:
- Configuration ':react-native-vector-icons:debugApiElements' variant android-aidl:
- Found artifactType 'android-aidl' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
- Configuration ':react-native-vector-icons:debugApiElements' variant android-classes:
- Found artifactType 'android-classes' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
- Configuration ':react-native-vector-icons:debugApiElements' variant android-manifest:
- Found artifactType 'android-manifest' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
- Configuration ':react-native-vector-icons:debugApiElements' variant android-renderscript:
- Found artifactType 'android-renderscript' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
- Configuration ':react-native-vector-icons:debugApiElements' variant jar:
- Found artifactType 'jar' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
APP/BUILD.GRADLE:
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,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // 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: []
* ]
*/
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.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 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.seroleashed.budgetmanager"
minSdkVersion 19
targetSdkVersion 25
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-vector-icons')
compile project(':react-native-navigation')
compile(project(':react-native-firebase')) {
transitive = false
}
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(':react-native-vector-icons')
implementation project(':react-native-navigation')
implementation "com.android.support:appcompat-v7:27.0.1"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-firebase')
// RNFirebase required dependencies
implementation "com.google.android.gms:play-services-base:15.0.0"
implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-auth:15.1.0"
implementation "com.google.firebase:firebase-database:15.0.0"
implementation "com.google.firebase:firebase-messaging:15.0.2"
}
// 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'
}
apply plugin: 'com.google.gms.google-services'
BUILD.GRADLE:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
google()
}
}
SETTINGS.GRADLE:
rootProject.name = 'BudgetManager'
include ':app'
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app')
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native
Moving the google() to the top can sometimes solve issues like this.
an example fix from your code
buildscript {
google()
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
You can run the following command at your project's root folder
1. You need to delete both ios,android and node module folder. Run the following commands
2. > npm install //to get the node module folder
3. > react-native upgrade //to get android and ios folder
4. > react-native link // for linking the libraries
5. > react-native run android/ios
Why do I always find the answer to questions I have shortly after asking for it in a forum or on Stackoverflow? xD
Just found the solution in this post:
Apparently there is a bug in the "google-services" version that I was using.
Downgrading from
classpath 'com.google.gms:google-services:3.3.0'
to
classpath 'com.google.gms:google-services:3.2.1'
in my "build.gradle" file made the deal.
I began as #Prahbu but changed in the middle so I thought I'd post what I did as a different answer :
here is what I did (in the project's root folder as well) :
1. You need to delete both ios,android and node module folder. Afterwards, you can run the following commands
2. > npm install //to get the node module folder
3. > react-native-git-upgrade
You'll eventually stumble upon this error. In this case, delete your .babelrc (after you saved its content), you may for example rename it to .babelrc2, and replace the generated .babelrc with yours when you're done.
If the react-native-git-upgrade didn't generate the ios and android folder, run
react-native eject
And all that is left is, as per the original answer,
4. > react-native link // for linking the libraries
5. > react-native run android/ios
run cd android && ./gradlew clean
I just had this issue. For me, the fix was simply running the run command again.
react-native run-android

Could not resolve com.android.support:design:26.1.0

I have been having this problem for quite a while, that my com.android.support:design:26.1.0 fails me and I have no clue what to change anymore.
These are my files for module gradle.
Build.gradle (app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.xxx.yyy"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.google.android.gms:play-services-vision:9.4.0'
// compile 'com.android.support:design:26.1.0'
}
//apply plugin: 'com.google.gms.google-services'
The project gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter({ url "http://jcenter.bintray.com/" })
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter({ url "http://jcenter.bintray.com/" })
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Error:Unable to resolve dependency for
':app#releaseUnitTest/compileClasspath': Could not resolve
com.android.support:design:26.1.0.
Error:Unable to resolve dependency
for ':app#release/compileClasspath': Could not resolve
com.android.support:design:26.1.0.
Error:Unable to resolve dependency
for ':app#debugUnitTest/compileClasspath': Could not resolve
com.android.support:design:26.1.0.
Error:Unable to resolve dependency
for ':app#debugAndroidTest/compileClasspath': Could not resolve
com.android.support:design:26.1.0.
Error:Unable to resolve dependency
for ':app#debug/compileClasspath': Could not resolve
com.android.support:design:26.1.0.
And only the 'Snackbar' function does not work but rest of it seems fine.
When I change the design to 25.1.0 version instead, it works but it clashes with other 26.1.0 ones so it's not recommended by the Android Studio. Anyone..?
I have tried putting the
compile 'com.android.support:design:26.1.0'
instead of implement, it does not work. When I tried to change the whole thing to either 25.4.0 or any other 25 version, a lot of other things doesnt compile as well. I have unchecked the Offline work, tried removing / adding maven directory, un-commenting a few more of dependencies, changing all to compile instead of implement but just gives me more errors.
Yes I have updated all my SDKs to the newest but I have a feeling that Gradle just cannot download certain dependencies from the websites that's why I cannot download any more of the other dependencies. (Although my off-line work is unchecked)
Also, whatever that are uncommented in the code above, it means I have tried inputting those lines but it did not solve the issue or rather created more issues.
Here is the way i found it please try the below
Go to File->Settings->Build, Execution, Deployment->Gradle->Uncheck Offline work option.
Try this once ,instead of implementing compile the design support gradle code
compile 'com.android.support:design:26.1.0'
and remove this
implementation 'com.android.support:design:26.1.0'
Problem that I realized in the end was that when I was setting up the android proxy, I have only set up 1 proxy which was for HTTP and did not realize that HTTPS proxy was not set up.
So after fixing that issue by setting HTTPS proxy, there was no more problems.

Getting errors while integrating VISA checkout

I am integrating VISA checkout payment using the following link: Visa Checkout Integration in Android Studio.
My project is quite heavy. I had imported it from Eclipse which already contained many libraries. While integrating the VISA checkout, I added the the following in the gradle file, and its associated libraries:
compile(name:'VisaCheckout-Android-SDK-4.3', ext:'aar')
When I executed this code without any previous libraries, I didn't get any errors.
However when I run the code in my existing app in Lollipop, I get a blank screen which does not respond even on clicking the hardware back button.
I'm getting some unusual errors such as:
No subscribers registered for event class com.visa.internal.ˌ
No subscribers registered for event class de.greenrobot.event.NoSubscriberEvent
Rejecting re-init on previously-failed class java.lang.Class
In Kitkat, the app crashes showing java.lang.NoClassDefFoundError: com.google.android.gms.analytics.GoogleAnalytics, (since Google Analytics is integrated in my project).
Here's my gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.fitcompany.fitness_enthusiasts"
minSdkVersion 11
targetSdkVersion 20
}
buildTypes {
release {
multiDexEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories {
flatDir { dirs 'libs'}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile project(':slidingMenu')
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.paypal.sdk:paypal-android-sdk:2.14.2'
compile(name:'VisaCheckout-Android-SDK-4.3', ext:'aar')
compile files('libs/volley.jar')
compile files('libs/gson-2.3.1.jar')
compile files('libs/HockeySDK-3.5.0.jar')
compile files('libs/httpclient-android-4.3.3.jar')
compile files('libs/ksoap2-android-assembly-3.1.0-jar-with-dependencies.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.5.6#aar') {
transitive = true;
}
}
My libs folder contains the following:
eventbus-2.4.0.jar
gson-2.3.1.jar
HockeySDK-3.5.0.jar
ksoap2-android-assembly-3.1.0-jar-with-dependencies.jar
libGoogleAnalyticsServices.jar
okhttp-2.5.0.jar
retrofit-1.9.0.jar
volley.jar
YouTubeAndroidPlayerApi.jar
VisaCheckout-Android-SDK-4.3.aar
I was using the wrong file in the libs folder. I replaced this line:
VisaCheckout-Android-SDK-4.3.aar
with this one and the error was gone.
VisaCheckout-Android-SDK-2.9.aar
Its because the name of SDK-AAR file in libs folder is in lowercase contrary to one declared in app-gradle.
e.g., 'visacheckout-android-sdk-4.3' instead 'VisaCheckout-Android-SDK-4.3'