eddieowens / react-native-boundary

Native implementation of geofencing/region monitoring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Failing on Android. Cannot find symbol JobIntentService

SilverInfinity opened this issue · comments

I've been trying to build this for android all day, and I'm completely stuck. The build always fails with the error:

BoundaryEventBroadcastReceiver.java:6: error: cannot find symbol
import android.support.v4.app.JobIntentService;
                             ^
  symbol:   class JobIntentService
  location: package android.support.v4.app

Environment:
OS: macOS High Sierra 10.13.4
Node: 8.9.4
Yarn: 1.3.2
npm: 5.6.0
Watchman: Not Found
Xcode: Xcode 9.3 Build version 9E145
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4 => 0.55.4

As far as i can tell, it is because JobIntentService was added as of support versions 26.1.0, and I'm getting some kind of version conflict? Its an older project an we're still using an older version of react-native, and quite a few other packages, and unfortunately due to breaking changes between RN 55 and 57 its not feasible to update at the moment.

I've tried added/updated the versions of compile 'com.android.support:appcompat-v7:26.1.0' and compile 'com.android.support:support-v4:26.1.0 to the dependencies block in my build.gradle, updating the compileSdkVersion to 26, Excluding the com.android.support from other projects...

But nothing seemed to work until as a last ditch effort I went into my node_modules folder and updated the build.gradle file in react-native-boundary to add compile 'com.android.support:support-v4:26.1.0 to the dependencies there, and finally got a successful build.

I'm still very new to mobile development, so I'm still not entirely familiar with all of this, but should compile 'com.android.support:support-v4:26.1.0 be added to this projects build.gradle dependancies? or am I still missing something?

It seems like you need to force the versions within your android/build.gradle file. You can do that by adding

ext {
  compileSdkVersion = 27
  buildToolsVersion = "27.0.3"
  targetSdkVersion = 26
  minSdkVersion = 16
  supportLibVersion = "27.1.1"
  googlePlayServicesVersion = "11+"
}

To the file, then reference it within your android/app/build.gradle like so,

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    ...
    defaultConfig {
        ...
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        ...
    }
dependencies {
    ...
    compile "com.android.support:appcompat-v7:$rootProject.supportLibVersion"
    ...
}

If that doesn't work, then try to search around for how to force versions in Android. Hope this helps!

Need to change all the imports from android support library to androidx library. Was facing the same issue, but changing all the android support library imports to androidx library solved the problem.
But first, you need to mention all the required libraries in your dependencies block in app/build.gradle file like this-
implementation('androidx.appcompat:appcompat:1.4.0') implementation('androidx.legacy:legacy-support-v4:1.0.0') implementation('androidx.annotation:annotation:1.4.0')