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

Android build error - Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. #11

Open
luisfuertes opened this issue Mar 24, 2021 · 9 comments

Comments

@luisfuertes
Copy link

luisfuertes commented Mar 24, 2021

Your Environment

  • Plugin version: "@darron1217/react-native-background-geolocation": "^0.6.6"
  • Platform: Android
  • OS version: All (Not build)
  • Device manufacturer and model: All (Not build)
  • Running in Simulator: No
  • React Native version: "react-native": "0.63.3"
  • Plugin configuration options:
  • Link to your project:

Context

android/build.gradle

buildscript { 
 dependencies {
   classpath("com.android.tools.build:gradle:3.5.4")
 }
}

android/gradle/wrapper/gradle-wrapper.properties:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Expected Behavior

Build correctly

Actual Behavior

Build crash with error:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

Possible Fix

Make compatible with Gradle 7

Steps to Reproduce

  1. Make ./gradlew assembleRelease on Android

Context

I cant build my project

Debug logs

Build logs with: ./gradlew assembleRelease --warning-mode all

> Task :@darron1217_react-native-background-geolocation-common:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
Property 'allSecondaryInputs' is private and annotated with @Internal. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'logging' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'oldSecondaryInputs' is declared without normalization specified. Properties of cacheable work must declare their normalization via @PathSensitive, @Classpath or @CompileClasspath. Defaulting to PathSensitivity.ABSOLUTE. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'path' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'projectName' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'temporaryDir' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'transform' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'workerExecutor' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
@darron1217
Copy link
Owner

This project doesn't support gradle 7.0 currently.

My gradle version is 6.8.1

@luisfuertes
Copy link
Author

But i don't use gradle 7.

I use this and don't know why i can't build with that versions

android/build.gradle

buildscript { 
 dependencies {
   classpath("com.android.tools.build:gradle:3.5.4")
 }
}

android/gradle/wrapper/gradle-wrapper.properties:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Thanks for answer, i try to build with gradle version 6.8.1.

What version do you use here?

classpath("com.android.tools.build:gradle:3.5.4"

@darron1217
Copy link
Owner

Here's what I'm using.

classpath('com.android.tools.build:gradle:4.0.1')

And you can check your gradle version with gradle -v command

@luisfuertes
Copy link
Author

I updated gradle versions to your versions.

In local i can do react-native run-android but i use Azure Pipeline to build app and have next errors since i installed this component (with mauron85 component, project build was ok):


/home/vsts/work/1/s/node_modules/@darron1217/react-native-background-geolocation/android/common/src/main/java/com/marianhello/bgloc/BackgroundGeolocationFacade.java:489: error: cannot find symbol
            if (ContextCompat.checkSelfPermission(context, perm) != PackageManager.PERMISSION_GRANTED) {
                ^
  symbol:   variable ContextCompat
  location: class BackgroundGeolocationFacade
/home/vsts/work/1/s/node_modules/@darron1217/react-native-background-geolocation/android/common/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java:144: error: package NotificationCompat does not exist
        NotificationCompat.Builder builder = null;
                          ^
/home/vsts/work/1/s/node_modules/@darron1217/react-native-background-geolocation/android/common/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java:147: error: package NotificationCompat does not exist
            builder = new NotificationCompat.Builder(getContext(), NotificationHelper.SYNC_CHANNEL_ID);
                                            ^
/home/vsts/work/1/s/node_modules/@darron1217/react-native-background-geolocation/android/common/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java:218: error: package NotificationCompat does not exist
            NotificationCompat.Builder builder = new NotificationCompat.Builder(getContext(), NotificationHelper.SYNC_CHANNEL_ID);
                              ^
/home/vsts/work/1/s/node_modules/@darron1217/react-native-background-geolocation/android/common/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java:218: error: package NotificationCompat does not exist
            NotificationCompat.Builder builder = new NotificationCompat.Builder(getContext(), NotificationHelper.SYNC_CHANNEL_ID);
                                                                       ^
/home/vsts/work/1/s/node_modules/@darron1217/react-native-background-geolocation/android/common/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java:231: error: cannot find symbol
        LocalBroadcastManager.getInstance(getContext().getApplicationContext()).sendBroadcast(intent);
        ^
  symbol:   variable LocalBroadcastManager
  location: class SyncAdapter
/home/vsts/work/1/s/node_modules/@darron1217/react-native-background-geolocation/android/common/src/main/java/com/marianhello/bgloc/sync/NotificationHelper.java:55: error: package NotificationCompat does not exist
            NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext, NotificationHelper.SERVICE_CHANNEL_ID);
                              ^
/home/vsts/work/1/s/node_modules/@darron1217/react-native-background-geolocation/android/common/src/main/java/com/marianhello/bgloc/sync/NotificationHelper.java:55: error: package NotificationCompat does not exist
            NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext, NotificationHelper.SERVICE_CHANNEL_ID);
                                                                       ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
36 errors

Any idea about how can i fix it? Thanks!

@darron1217
Copy link
Owner

@luisfuertes You must enable Android X and jetifier to make it compatible.

android/gradle.properties

android.useAndroidX=true
android.enableJetifier=true

and run yarn install or npm install to run jetifier. (If it's not working, run npx jetify manually)

@luisfuertes
Copy link
Author

luisfuertes commented Mar 26, 2021

I already had it activated

On local i can do ./gradlew assembleRelease but in Pipeline it fail.

Similar like this issue

@bennyrock20
Copy link

Hi @luisfuertes were you able to fix it?

@luisfuertes
Copy link
Author

@bennyrock20 no, finally i used this mododule (is not free)

@dev-andremonteiro
Copy link

@bennyrock20 I was able to fix this by forking this library and running jetifieron it to update code to androidX, if you can't keep your android/grandle.properties because of other libraries

android.useAndroidX=false
android.enableJetifier=false

use my forked branch in your project.

If the changes I made to this works for other people I might create a PR to this library.

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

4 participants