Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find a version of 'androidx.appcompat:appcompat' that satisfies the version constraints #757

Closed
kirkryan opened this issue Jul 4, 2019 · 18 comments

Comments

@kirkryan
Copy link

kirkryan commented Jul 4, 2019

Your Environment

"name": "newBackgroundGps",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"cocoa-lumberjack": "^3.0.5",
"react": "16.8.6",
"react-native": "0.60.0",
"react-native-background-fetch": "^2.6.0",
"react-native-background-geolocation": "^3.0.7"
},
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/runtime": "^7.4.5",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.8.0",
"eslint": "^6.0.1",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.55.0",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native"
}
}

  • Plugin config
    NA

Expected Behavior

Android can build successfully - using React-native 0.60.0

Actual Behavior

Failed with error message:

Cannot find a version of 'androidx.appcompat:appcompat' that satisfies the version constraints:

Steps to Reproduce

  1. Build a brand new app via react-native init
  2. Install react-native-background-geolocation following instructions precisely
  3. Open in Android studio
  4. Error is shown, even after "clean build" is run

Context

Create a barebone project with react-native 0.60 and react-native-background-geolocation
See gif recording off all steps:

react-native-0 60-background-geolocation-error

Debug logs

Logs
Cannot find a version of 'androidx.appcompat:appcompat' that satisfies the version constraints: 
   Dependency path 'newBackgroundGps:react-native-background-geolocation:unspecified' --> 'com.android.support:appcompat-v7:28.0.0' because of the following reason: ENABLE_JETIFIER is enabled
   Constraint path 'newBackgroundGps:react-native-background-geolocation:unspecified' --> 'androidx.appcompat:appcompat:{strictly 1.0.0}' because of the following reason: debugRuntimeClasspath uses version 1.0.0
   Dependency path 'newBackgroundGps:react-native-background-geolocation:unspecified' --> 'com.facebook.react:react-native:0.60.0' --> 'androidx.appcompat:appcompat:1.0.2'


@christocracy
Copy link
Member

Yes, migrating to AndroidX is going to be a pain for the next while.

See here

@mikehardy
Copy link
Contributor

https://github.com/mikehardy/jetifier should ease the transition but gradle dependencies analysis is a skill that most have avoided so there's always some learning involved

@christocracy
Copy link
Member

christocracy commented Jul 4, 2019

Thanks @mikehardy. I'm going to have to look into providing better support for AndroidX. I see what you did here. I knew AndroidX was going to be painful. Can't wait until this is all behind us.

@christocracy
Copy link
Member

I’ve pushed a commit to master of private repo which should help fix this.

@dakkafex
Copy link

dakkafex commented Jul 13, 2019

Will your update be pushed to the public repo? kinda makes the library dead in the water as it is now

@christocracy
Copy link
Member

See CHANGELOG

@MXLI88
Copy link

MXLI88 commented Jul 17, 2019

Hi,
as a temporary solution !!! I changed the build.gradle under android folder in node_modules react-native-background-geolocation.

compileOnly 'com.facebook.react:react-native:+'

TO

implementation('com.facebook.react:react-native:+') {
exclude group: 'com.android.support'
}

full build.gradle:

apply plugin: 'com.android.library'

// Android dependencies
def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_TARGET_SDK_VERSION = 28
def DEFAULT_SUPPORT_LIB_VERSION = "28.0.0"

// Plugin dependencies
def DEFAULT_GOOGLE_PLAY_SERVICES_LOCATION_VERSION = "17.0.0"
def DEFAULT_OK_HTTP_VERSION = "3.12.1"
def DEFAULT_ANDROID_PERMISSIONS_VERSION = "0.1.8"
def DEFAULT_EVENTBUS_VERSION = "3.0.0"
def DEFAULT_REMOVE_DEBUG_SOUNDS_IN_RELEASE = true

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)

defaultConfig {
    minSdkVersion 16
    targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
    versionCode 1
    versionName "1.0"
}

// TODO
def removeDebugSounds = safeExtGet('removeBackgroundGeolocationDebugSoundsInRelase', DEFAULT_REMOVE_DEBUG_SOUNDS_IN_RELEASE)

}

repositories{
maven {
url './libs'
}
}

dependencies {
def supportLibVersion = safeExtGet('supportLibVersion', DEFAULT_SUPPORT_LIB_VERSION)
def supportLibMajorVersion = supportLibVersion.split('\.')[0] as int
def appCompatLibName = (supportLibMajorVersion < 20) ? "androidx.appcompat:appcompat" : "com.android.support:appcompat-v7"
def playServicesLocationVersion = safeExtGet('googlePlayServicesLocationVersion', DEFAULT_GOOGLE_PLAY_SERVICES_LOCATION_VERSION)
def okHttpVersion = safeExtGet('okHttpVersion', DEFAULT_OK_HTTP_VERSION)
def androidPermissionsVersion = safeExtGet('androidPermissionsVersion', DEFAULT_ANDROID_PERMISSIONS_VERSION)
def eventBusVersion = safeExtGet('eventBusVersion', DEFAULT_EVENTBUS_VERSION)

implementation('com.facebook.react:react-native:+') {
exclude group: 'com.android.support'
}
implementation "$appCompatLibName:$supportLibVersion"
implementation "com.google.android.gms:play-services-location:$playServicesLocationVersion"
implementation "org.greenrobot:eventbus:$eventBusVersion"
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
implementation(group: 'com.transistorsoft', name:'tslocationmanager', version: '+')
implementation 'org.slf4j:slf4j-api:1.7.25'
implementation 'com.github.tony19:logback-android:1.3.0-2'
implementation "com.intentfilter:android-permissions:$androidPermissionsVersion"

}

@kirkryan
Copy link
Author

The latest version works perfectly fine with a new RN app - I didn’t have to change anything.

@arrygoo
Copy link

arrygoo commented Jul 29, 2019

I still get this error :(
Doing

implementation('com.facebook.react:react-native:+') {
exclude group: 'com.android.support'
}

Fixes it

@christocracy
Copy link
Member

If you have to exclude com.android.support, you have problems with other plugins or you haven’t carefully followed the setup steps.

There’s no such thing as com.android.support when using AndroidX.

@MXLI88
Copy link

MXLI88 commented Jul 29, 2019

Changing compileonly too

implementation('com.facebook.react:react-native:+')

Without exclude group Works too.. I had/have only problems with "compileOnly"
In RN 0.60.4

@christocracy
Copy link
Member

It’s always a good idea to generate a fresh new react native init foo to see what the default template generates.

Sometimes it’s a good idea to regen a fresh app and move your JS into it.

@MXLI88
Copy link

MXLI88 commented Aug 1, 2019

Hi again Just created a new test project , everything Works fine with only backgroundgeolocation installed, after installing firebase and react-native-maps i run into this problem again.

:(..

I found the quick solution for changing compileonly to implementation here:
HTTPS://github.com/react-native-community/react-native-maps/issues/2940

Runing with RN 0.60.4

@CarstenHoyer
Copy link

@christocracy I had/have the same issue. I am on 0.60.5 and have followed the guide for >= 0.60. I also have some of the same modules as people mention above. (rn-firebase, rn-maps). Though I am not sure it is the correct solution, it is true, that if I change your build.gradle to not use compileOnly the app compiles.

Change: https://github.com/transistorsoft/react-native-background-geolocation/blob/master/android/build.gradle#L48

To

implementation ('com.facebook.react:react-native:+') {
    exclude group: 'com.android.support'
}

Possibly without the exclude

@CarstenHoyer
Copy link

PS: I have jetifier enabled. That might be relevant

@christocracy
Copy link
Member

Show me your gradle files:

  • android/build.gradle
  • android/app/build.gradle

@mikehardy
Copy link
Contributor

react-native-firebase has some issues with androidx library specification, and an unrelated issue with CI that is stopping us from releasing v5.5.7 :-(

invertase/react-native-firebase#2476

I have attached a patch-package file in a comment on that pull request for people to use in the meantime, I needed it in my project - either for this module in combo with react-native-firebase or another, I'm not sure invertase/react-native-firebase#2476 (comment)

@christocracy
Copy link
Member

Thanks @mikehardy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants