Project not synced in android studio 22.0.1 buildversion tool ubuntu - android-gradle-plugin

i want to sync my project in build 22.0.1 but when i set my gradle file as below it taking process sync continuously
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.sphere65.myapplication2"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22+'
compile 'com.android.support:design:22+'
}

Related

Could not resolve all task dependencies for configuration React-navigation error

I am having a problem with react-native-navigation packages, so I have them installed like this npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context #react-native-community/masked-view. But for some reason when I run npm run android I am getting this error for every package. ```
Deprecated Gradle features were used in this build, making it incompatible with
Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and
determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:comm
and_line_warnings
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:collectReleaseDependencies'.
Could not resolve all task dependencies for configuration ':app:rele
aseRuntimeClasspath'.
Could not resolve project:#react-native-community_masked-view.
Required by:
project :app
No matching configuration of project :#react-native-commu
nity_masked-view was found. The consumer was configured to find a runti
me of a component, as well as attribute 'com.android.build.api.attributes.BuildT
ypeAttr' with value 'release' but:
None of the consumable configurations have attributes..```
This is my package json
{
"name": "AwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-community/cli-platform-android": "^3.0.3",
"#react-native-community/masked-view": "^0.1.11",
"#react-navigation/native": "^5.9.4",
"#react-navigation/stack": "^5.14.5",
"gradle": "^1.2.4",
"react": "17.0.1",
"react-native": "^0.64.2",
"react-native-elements": "^3.4.2",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^2.2.0",
"react-native-safe-area-context": "^3.2.0",
"react-native-screens": "^2.18.1",
"react-navigation": "^4.4.4",
"react-navigation-stack": "^2.10.4"
},
"devDependencies": {
"#babel/core": "7.14.6",
"#babel/runtime": "7.14.6",
"#react-native-community/eslint-config": "2.0.0",
"babel-jest": "26.6.3",
"eslint": "7.14.0",
"jest": "26.6.3",
"metro-react-native-babel-preset": "0.64.0",
"react-test-renderer": "17.0.1"
},
"jest": {
"preset": "react-native"
}
}
This is gradle.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
This is settings.gradle
rootProject.name = 'AwesomeProject'
apply from: file("../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
build gradle
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
app/build.gradle
android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.awesomeproject"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
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:
// https://developer.android.com/studio/build/configure-apk-splits.html
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
}
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// 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 from: file("../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
You are mixing different versions of react-navigation.
You can't have "react-navigation": "^4.4.4" and "#react-navigation/stack": "^5.14.5".
So install only the 5 version or the 4 as you need.

A problem occurred configuring project':react-native-audio-recorder-player' >compileSdkVersion is not specified,while running react-native run-android

Whenever I try running react-native run-android, I am getting the following error:
A problem occurred configuring project ':react-native-audio-recorder-player'.
> compileSdkVersion is not specified.
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
androidXAnnotation = "1.1.0"
androidXBrowser = "1.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
app/build.gradle
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
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. If none specified and
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
* // default. Can be overridden with ENTRY_FILE environment variable.
* entryFile: "index.android.js",
*
* // https://reactnative.dev/docs/performance#enable-the-ram-format
* bundleCommand: "ram-bundle",
*
* // 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 = [
enableHermes: false, // clean and rebuild if changing
]
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
/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", false);
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.sheolife"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// 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:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
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 fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation project(':react-native-android-open-settings')
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-audio')
implementation 'com.clevertap.android:clevertap-android-sdk:4.0.0'
implementation 'com.google.firebase:firebase-messaging:20.2.4'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation project(':react-native-audio-recorder-player')
compile 'com.facebook.fresco:animated-gif:1.+'
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// 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 from: file("../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
package.json
{
"name": "sheolife",
"version": "0.0.1",
"private": true,
"rnpm": {
"assets": [
"./src/assets/fonts/"
]
},
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
"start-web": "react-scripts start",
"build": "react-scripts build",
"test-web": "react-scripts test --env=jsdom",
"eject-web": "react-scripts eject",
"prettier": "prettier --write './src'",
"yarn-ios": "yarn ios --simulator `iPhone 6s` --verbose",
"clear-modules": "rm -rf node_modules; rm -f package-lock.json; rm -f yarn.lock"
},
"dependencies": {
"#react-native-community/art": "^1.2.0",
"#react-native-community/async-storage": "^1.12.0",
"#react-native-community/cameraroll": "^4.0.2",
"#react-native-community/cli": "^4.14.0",
"#react-native-community/clipboard": "^1.2.3",
"#react-native-community/hooks": "^2.6.0",
"#react-native-community/masked-view": "^0.1.10",
"#react-native-community/netinfo": "^6.0.0",
"#react-native-community/voice": "^1.1.9",
"#react-navigation/bottom-tabs": "^5.9.0",
"#react-navigation/drawer": "^5.11.4",
"#react-navigation/material-top-tabs": "^5.3.10",
"#react-navigation/native": "^5.7.3",
"#react-navigation/stack": "^5.9.0",
"#reduxjs/toolkit": "^1.4.0",
"#twotalltotems/react-native-otp-input": "^1.3.11",
"axios": "^0.20.0",
"clevertap": "^1.1.1",
"clevertap-react-native": "^0.5.0",
"i18n-js": "^3.8.0",
"loadash": "^1.0.0",
"lodash.memoize": "^4.1.2",
"materialize-css": "^1.0.0-rc.2",
"modal-react-native-web": "^0.2.0",
"moment": "^2.29.1",
"qs": "^6.9.4",
"react": "16.13.1",
"react-art": "^16.5.1",
"react-datepicker": "^3.3.0",
"react-dom": "^16.5.1",
"react-dropdown": "^1.9.0",
"react-materialize": "^3.9.3",
"react-native": "0.63.2",
"react-native-android-open-settings": "^1.3.0",
"react-native-animated-ellipsis": "^2.0.0",
"react-native-animated-loader": "^0.0.9",
"react-native-audio": "^4.3.0",
"react-native-audio-recorder-player": "^2.6.1",
"react-native-auto-height-image": "^3.2.4",
"react-native-calendars": "^1.1129.0",
"react-native-countdown-component": "^2.7.1",
"react-native-create-thumbnail": "^1.2.2",
"react-native-custom-datetimepicker": "^3.0.0",
"react-native-date-picker": "^3.2.8",
"react-native-datepicker": "^1.7.2",
"react-native-debugger": "^1.1.0",
"react-native-dialog": "^6.1.2",
"react-native-drawer": "^2.5.1",
"react-native-dropdown-picker": "^3.7.1",
"react-native-eject": "^0.1.2",
"react-native-gesture-handler": "^1.8.0",
"react-native-google-places-autocomplete": "^2.2.0",
"react-native-htmlview": "^0.16.0",
"react-native-image-base64": "^0.1.4",
"react-native-image-crop-picker": "^0.33.2",
"react-native-image-picker": "^3.1.4",
"react-native-indicators": "^0.17.0",
"react-native-linear-gradient": "^2.5.6",
"react-native-localize": "^2.0.1",
"react-native-modal": "^11.6.1",
"react-native-paper": "^4.5.0",
"react-native-picker-select": "^8.0.3",
"react-native-picker-view": "^1.0.9",
"react-native-pie": "^1.1.2",
"react-native-pie-chart": "^1.0.13",
"react-native-progress-bar-animated": "^1.0.6",
"react-native-progress-circle": "^2.1.0",
"react-native-pull-to-refresh": "^2.1.3",
"react-native-range-slider": "^0.1.2",
"react-native-raw-bottom-sheet": "^2.2.0",
"react-native-read-more-text": "^1.1.2",
"react-native-reanimated": "^1.13.2",
"react-native-safe-area-context": "^3.1.8",
"react-native-screens": "^2.11.0",
"react-native-searchable-dropdown": "^1.1.3",
"react-native-share": "^5.1.4",
"react-native-side-drawer": "^1.2.8",
"react-native-side-menu": "^1.1.3",
"react-native-simple-toast": "^1.1.3",
"react-native-snap-carousel": "^3.9.1",
"react-native-sound": "^0.11.0",
"react-native-speedometer-chart": "^0.7.5",
"react-native-splash-screen": "^3.0.6",
"react-native-svg": "^12.1.0",
"react-native-tab-view": "^2.15.2",
"react-native-textinput-effects": "^0.6.1",
"react-native-thumbnail-video": "^0.1.2",
"react-native-tts": "^3.2.0",
"react-native-vector-icons": "^7.1.0",
"react-native-video": "^5.1.1",
"react-native-video-player": "^0.10.1",
"react-native-view-shot": "^3.1.2",
"react-native-web": "^0.14.2",
"react-native-webview": "^11.3.2",
"react-otp-input": "^2.2.0",
"react-redux": "^7.2.2",
"react-render-html": "^0.6.0",
"react-router-dom": "^4.3.1",
"react-router-modal": "^2.0.0-rc3",
"react-router-native": "^5.2.0",
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"rn-fetch-blob": "^0.12.0",
"victory-native": "^35.3.1"
},
"devDependencies": {
"#babel/core": "^7.11.6",
"#babel/runtime": "^7.11.2",
"babel-preset-react-native": "^5.0.2",
"jest": "^26.4.2",
"jetifier": "^1.6.7",
"metro-react-native-babel-preset": "^0.63.0",
"react-scripts": "^1.1.5",
"react-test-renderer": "^16.3.1",
"redux-devtools": "^3.7.0"
},
"jest": {
"preset": "react-native"
},
"homepage": "."
}
Things I tried ->
removed android and ios folders
react-native eject
./gradlew clean
and
removed node_modules
npm install
react-native run-android
However nothing is working, kindly help me out here, been stuck since two days, any leads would be helpful.
I faced the same issue when I ejected my expo app, If you check out the documentation of react-native-audio-recorder-player they have mentioned that for version 3.0.0+ codebase has been re-written to kotlin for Android and swift for iOS,
So you need to add plugin for kotlin inside your build.gradle file,
after adding, your dependencies will look something like
hope this resolves your issue
dependencies {
classpath 'com.google.gms:google-services:4.3.3',
classpath("com.android.tools.build:gradle:3.5.3"),
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0") //kotlin plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Add this in your android gradle file
file path -> ProjectName/android/build.gradle
Add below code
buildscript {
ext {
minSdkVersion = 24
kotlinVersion = '1.5.0'
}
repositories {
google()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
Add this line in you android build.gradle file
Your Project - android/build.gradle
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 24
compileSdkVersion = 31
targetSdkVersion = 31
kotlinVersion = '1.5.0'
..............
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
........

Build.grad does not load the 'index.js' Bundle when emulated on Android 9

I created my app and there is a login feature for each user to have their own profile. When I test emulating the app in androids versions 6, 7.1, 8.1, it installs normally and when it arrives in the login part, the application recognizes the user / password and logs in.
But when I emulate on Android 9, something wrong happens. After typing user / password, it does not load the next page and I realize that my 'index.js' Bundle does not load when starting the react-native run-android command.
How can I solve?
Windows 10, React Native latest version, MongoDB.
Login Code:
loginUser() {
login(this.state)
.then(response => {
if (response) {
const aux = response.data;
aux.jwt = response.token;
this.props.updateALL(aux);
Actions.main();
}
})
.catch(error => {
this.setState({ alertMessage: error.message, showIcon: true });
}); }
Package.JSON
{
"name": "ifun",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"aws-sdk": "^2.395.0",
"axios": "^0.18.0",
"date-diff": "^0.2.1",
"fuctbase64": "^1.4.0",
"google-map-react": "^1.1.2",
"install": "^0.12.2",
"native-base": "^2.8.1",
"react": "^16.6.3",
"react-dom": "^16.8.1",
"react-native": "^0.55.4",
"react-native-aws3": "0.0.8",
"react-native-carousel-view": "^0.5.1",
"react-native-elements": "^1.1.0",
"react-native-geolocation-service": "^2.0.0",
"react-native-i18n": "^2.0.15",
"react-native-image-picker": "^0.27.2",
"react-native-lightbox": "^0.8.0",
"react-native-mime-types": "^2.2.1",
"react-native-modal": "^7.0.2",
"react-native-modal-datetime-picker": "^6.0.0",
"react-native-router-flux": "^3.45.0",
"react-redux": "^5.1.1",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"babel-jest": "23.4.0",
"babel-preset-react-native": "4.0.0",
"eslint-config-rallycoding": "^3.2.0",
"jest": "23.4.1",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}
Build.Gradle App
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.ifun"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
multiDexEnabled true
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-image-picker')
compile project(':react-native-i18n')
compile project(':react-native-geolocation-service')
implementation project(':react-native-i18n')
implementation project(':react-native-image-picker')
implementation project(':react-native-geolocation-service')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "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'
}
when I emulate on Android 9, something wrong happens. After typing user / password, it does not load the next page and I realize that my 'index.js' Bundle does not load when starting the react-native run-android command.
How can I solve?
Verify that your existing apps work correctly on the new version of the platform. This step does not use new APIs or change the app's targetSdkVersion, but it may require minor changes.
can you try low TargetSdkVersion?
If this is resolved, please refer to here for more information.

How to access BuildConfig product flavor variables in React native android

Hi I followed the below link to create product flavours
enter link description here
I set up a variable in the flavours and I am unable to access that in the code.
build.gradle.
productFlavors {
production {
minSdkVersion rootProject.ext.minSdkVersion
applicationId 'com.xxx.production'
targetSdkVersion rootProject.ext.targetSdkVersion
resValue "string", "build_config_package", "com.myapp"
buildConfigField "boolean", "MOCK_VERSION", "false"
resValue "string", "MOCK_VERSION_ABCD", "false"
}
staging {
minSdkVersion rootProject.ext.minSdkVersion
applicationId 'com.xxx.staging'
targetSdkVersion rootProject.ext.targetSdkVersion
resValue "string", "build_config_package", "com.myapp"
buildConfigField "boolean", "MOCK_VERSION", "false"
resValue "string", "MOCK_VERSION_ABCD", "false"
}
t3st {
minSdkVersion rootProject.ext.minSdkVersion
applicationId 'com.xxx.test'
targetSdkVersion rootProject.ext.targetSdkVersion
resValue "string", "build_config_package", "com.myapp"
buildConfigField "boolean", "MOCK_VERSION", "true"
resValue "string", "MOCK_VERSION_ABCD", "true"
}
}
I tried to access it in my Login.js file
import { BuildCofig } from 'react-native';
loginEndpointDecider = () => {
if(BuildCofig.MOCK_VERSION){
alert('MOCK_VERSION - true');
}else{
alert('MOCK_VERSION - false');
}
}
To run the app
react-native run-android --variant=stagingDebug
I am trying to access buildConfigField MOCK_VERSION.
Could you please suggest how to get this working.
Thanks
R
I've used react-native-build-config for this. Works well but remember to set up keep rules for the generated BuildConfig class if you are using proguard. The framework that inspired this library react-native-config also works but I had problems configuring the library to work with cocoapods when targeting >=0.56 RN.

Android studio 3.0 compile time error BUILD FAILED

I'm facing this issue after moving on android studio 3.0.
Whenever I try to run after couple of time then this error occurs.
Information:Gradle tasks [:app:assembleDevDebug]
Error:java.lang.RuntimeException: com.android.build.api.transform.TransformException: java.io.IOException: Could not delete path 'D:\Akash\Final\android_main\app\build\intermediates\transforms\desugar\dev\debug\0.jar'.
Error:com.android.build.api.transform.TransformException: java.io.IOException: Could not delete path 'D:\Akash\Final\android_main\app\build\intermediates\transforms\desugar\dev\debug\0.jar'.
Error:java.io.IOException: Could not delete path 'D:\Akash\Final\android_main\app\build\intermediates\transforms\desugar\dev\debug\0.jar'.
Information:BUILD FAILED in 2s
Information:3 errors
Information:0 warnings
Solution is to rebuild or clean then run app.
Because of this i am not able to use instant run feature.
I have already tried this solution and it works works.
But why am I facing this issue frequently like 4-5 times in an hour?
P.S I do not have admin access. as mentioned HERE as accepted answer
The rest of my projects are working fine without any issue.
You may find this question as duplicate but the previous solutions are not really helpful to me at all.
Build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'
apply plugin: 'realm-android'
repositories {
maven {
url "https://XXX.XXX.com/XXX.XXX.com"
}
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
flavorDimensions "default"
project.archivesBaseName = "XXX";
signingConfigs {
release {
storeFile file (System.getenv('XXX'))
storePassword System.getenv("XXX")
keyAlias System.getenv("XXX")
keyPassword System.getenv("XXX")
}
}
playAccountConfigs {
defaultAccountConfig {
serviceAccountEmail = 'XXX-XXX-account#api-XXX-XXX.iam.XXX.com'
pk12File = file('XXX-XXX.p12')
}
}
defaultConfig {
applicationId "com.XXX.app"
minSdkVersion 16
targetSdkVersion 26
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
signingConfig signingConfigs.release
playAccountConfig = playAccountConfigs.defaultAccountConfig
ndk {
abiFilters 'armeabi-v7a'
}
}
lintOptions {
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
dexOptions {
javaMaxHeapSize "4g"
jumboMode true
}
productFlavors {
pro {
buildConfigField "XXX", "XXX", System.getenv("XXX")
buildConfigField "XXX", "XXX", System.getenv("XXX")
buildConfigField "XXX", "XXX", System.getenv("XXX")
buildConfigField "XXX", "XXX", System.getenv("XXX")
}
qa {
buildConfigField "XXX", "XXX", System.getenv("XXX")
buildConfigField "XXX", "XXX", System.getenv("XXX")
manifestPlaceholders = [facebookId: "XXX"]
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "XXX-${variant.baseName}-${variant.versionName}.apk"
}
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/XXX'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs'
})
testImplementation 'junit:junit:4.12'
implementation project(path: ':instacount')
implementation project(path: ':cordova')
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:palette-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.android.gms:play-services-maps:11.0.4'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.squareup.picasso:picasso:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
implementation 'com.github.bumptech.glide:glide:3.8.0'
implementation 'net.danlew:android.joda:2.8.2'
implementation 'com.auth0.android:auth0:1.8.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
implementation 'com.amazonaws:aws-android-sdk-s3:2.4.4'
implementation 'testfairy:testfairy-android-sdk:1.+#aar'
implementation 'com.afollestad.material-dialogs:commons:0.9.0.1'
implementation 'com.jenzz.appstate:appstate:3.0.1'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.commonsware.cwac:cam2:0.7.6'
implementation 'org.parceler:parceler-api:1.1.9'
annotationProcessor 'org.parceler:parceler:1.1.9'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.5'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.jakewharton.rxbinding:rxbinding:0.4.0'
implementation 'com.caverock:androidsvg:1.2.1'
}
play {
track = 'beta'
}
I also encountered the same problem and solved it.
Try to update Realm plugin to 4.2.0.
See File handles are not released in RealmTransformer · Issue #5521 · realm/realm-java
try this one for missing java file as 1.jar,2.jar....28.jar,29.jar...as soon
in gradle.properties add the following:
android.enableD8.desugaring = true