react-native-slider icon indicating copy to clipboard operation
react-native-slider copied to clipboard

Android build failed : Task :@react-native-community_slider:compileDebugJavaWithJavac FAILED

Open uzairkhan01 opened this issue 7 years ago • 19 comments

Environment Android only

info React Native Environment Info: System: OS: macOS High Sierra 10.13.6 CPU: (4) x64 Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz Memory: 568.49 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 8.11.3 - /usr/local/bin/node Yarn: 1.9.4 - /usr/local/bin/yarn npm: 5.6.0 - /usr/local/bin/npm SDKs: iOS SDK: Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3 Android SDK: API Levels: 23, 25, 26, 27, 28 Build Tools: 23.0.1, 23.0.2, 23.0.3, 25.0.3, 26.0.2, 26.0.3, 27.0.3, 28.0.2, 28.0.3 System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google Play Intel x86 Atom, android-27 | Intel x86 Atom_64, android-28 | Android TV Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64 IDEs: Android Studio: 3.1 AI-173.4907809 Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.9 => 0.59.9 npmGlobalPackages: react-native-cli: 2.0.1 react-native-git-upgrade: 0.2.7

Description

Android Build faild if run react-native run-android.Also change react-native-slider version v1.1.3 ,v1.1.2 and v1.1.1

build error Error

Configure project :react-native-webview WARNING: The following project options are deprecated and have been removed: android.enableAapt2 This property has no effect, AAPT2 is now always used.

:react-native-webview:reactNativeAndroidRoot /Users/apple/Desktop/development/app/64bit/node_modules/react-native/android

Task :@react-native-community_slider:compileDebugJavaWithJavac FAILED /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSlider.java:11: error: package android.support.v7.widget does not exist import android.support.v7.widget.AppCompatSeekBar; ^ /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSlider.java:23: error: cannot find symbol public class ReactSlider extends AppCompatSeekBar { ^ symbol: class AppCompatSeekBar /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSlider.java:60: error: cannot find symbol super.setStateListAnimator(null); ^ symbol: variable super location: class ReactSlider /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSlider.java:88: error: cannot find symbol if (seekBarProgress == getMax()) { ^ symbol: method getMax() location: class ReactSlider /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSlider.java:99: error: cannot find symbol setMax(getTotalSteps()); ^ symbol: method setMax(int) location: class ReactSlider /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSlider.java:105: error: cannot find symbol setProgress((int) Math.round((mValue - mMinValue) / (mMaxValue - mMinValue) * getTotalSteps())); ^ symbol: method setProgress(int) location: class ReactSlider /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:37: error: type argument ReactSlider is not within bounds of type-variable T public class ReactSliderManager extends SimpleViewManager { ^ where T is a type-variable: T extends View declared in class SimpleViewManager /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:66: error: incompatible types: ReactSlider cannot be converted to SeekBar SeekBar reactSlider = new ReactSlider(getThemedContext(), null, STYLE); ^ /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:88: error: incompatible types: SeekBar cannot be converted to ReactSlider ((ReactSlider) seekbar).toRealProgress(progress), ^ /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:98: error: incompatible types: SeekBar cannot be converted to ReactSlider ((ReactSlider) seekbar).toRealProgress(seekbar.getProgress()))); ^ /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:107: error: incompatible types: SeekBar cannot be converted to ReactSlider ((ReactSlider) seekbar).toRealProgress(seekbar.getProgress()))); ^ /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:133: error: cannot find symbol view.setEnabled(enabled); ^ symbol: method setEnabled(boolean) location: variable view of type ReactSlider /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:138: error: cannot find symbol view.setOnSeekBarChangeListener(null); ^ symbol: method setOnSeekBarChangeListener() location: variable view of type ReactSlider /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:140: error: cannot find symbol view.setOnSeekBarChangeListener(ON_CHANGE_LISTENER); ^ symbol: method setOnSeekBarChangeListener(OnSeekBarChangeListener) location: variable view of type ReactSlider /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:161: error: cannot find symbol view.getThumb().clearColorFilter(); ^ symbol: method getThumb() location: variable view of type ReactSlider /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:163: error: cannot find symbol view.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN); ^ symbol: method getThumb() location: variable view of type ReactSlider /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:169: error: cannot find symbol LayerDrawable drawable = (LayerDrawable) view.getProgressDrawable().getCurrent(); ^ symbol: method getProgressDrawable() location: variable view of type ReactSlider /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:180: error: cannot find symbol LayerDrawable drawable = (LayerDrawable) view.getProgressDrawable().getCurrent(); ^ symbol: method getProgressDrawable() location: variable view of type ReactSlider /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:191: error: cannot find symbol view.setOnSeekBarChangeListener(ON_CHANGE_LISTENER); ^ symbol: method setOnSeekBarChangeListener(OnSeekBarChangeListener) location: variable view of type ReactSlider Note: /Users/apple/Desktop/development/app/64bit/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 19 errors

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':@react-native-community_slider:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

Reproducible Demo

yarn add @react-native-community/slider react-native link @react-native-community/slider react-native run-android

uzairkhan01 avatar Jun 17 '19 16:06 uzairkhan01

started experiencing this today as well. Looks like there were some releases with breaking changes: https://developers.google.com/android/guides/releases

Taylor123 avatar Jun 17 '19 22:06 Taylor123

posting this here so others have more info: https://github.com/facebook/react-native/issues/25293

Taylor123 avatar Jun 18 '19 16:06 Taylor123

Can you reopen this issue please? Since it hasn't been fixed yet @uzairkhan01

natasha08n avatar Jun 18 '19 20:06 natasha08n

What's happening is dependencies are defaulting to the latest play services or google android apis, so you just need to set the version in your android/build.gradle file similar to the following

buildscript {
    ....
    ext {
            googlePlayServicesVersion = "X.X.X"
            firebaseVersion = "X.X.X" // if you're using firebase or dependencies use firebase
        }
}

edit: this keeps you from using androidx. If you want to use androidx, then you'll need to use something like jetifier + work arounds that are currently being discussed to convert RN dependencies to androidx

Taylor123 avatar Jun 18 '19 21:06 Taylor123

My project is converted to androidx and i have the latest slider Package @react-native-community/slider": "^1.1.3". But still build is failing with error: package android.support.v7.widget does not exist. Can someone help me on this

Kiran0791 avatar Jun 19 '19 10:06 Kiran0791

@Kiran0791 since you're on androidx, you'll need to convert this package to androidx for your project. The package below can help since Jetifier doesn't run on react-native node_modules since they're local dependencies.

https://github.com/mikehardy/jetifier

Taylor123 avatar Jun 19 '19 18:06 Taylor123

@Kiran0791 , I fixed this issue by changing code in node_module.

steps: 1- Open node_modules/@react-native-community/slider/android/build.gradle

2- change api "androidx.appcompat:appcompat:${rootProject.ext.supportLibVersion}" to api "androidx.appcompat:appcompat:1.0.2"

3- Open node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSlider.java

4- change import android.support.v7.widget.AppCompatSeekBar; to import androidx.appcompat.widget.AppCompatSeekBar;

MuhammadUzair avatar Jul 01 '19 14:07 MuhammadUzair

@Kiran0791 , I fixed this issue by changing code in node_module.

steps: 1- Open node_modules/@react-native-community/slider/android/build.gradle

2- change api "androidx.appcompat:appcompat:${rootProject.ext.supportLibVersion}" to api "androidx.appcompat:appcompat:1.0.2"

3- Open node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSlider.java

4- change import android.support.v7.widget.AppCompatSeekBar; to import androidx.appcompat.widget.AppCompatSeekBar;

I couldnt find any of these lines that you have mentioned, they just dont exist in my package.

bimix avatar Jul 28 '19 22:07 bimix

@bimix if the bug still exists in new version then install version 1.1.3 of react-native-slider and implement above changes.

MuhammadUzair avatar Jul 30 '19 08:07 MuhammadUzair

By default running npm install @react-native-community/slider will install version 2.0.0 which is not compatible with react native 0.5X.X 2.0.0 is compatible only with react native version 0.60.0

khanof89 avatar Aug 07 '19 13:08 khanof89

@khanof89 if your react-native <= 0.59 then : npm install @react-native-community/[email protected] or npm install @react-native-community/[email protected]

MuhammadUzair avatar Aug 07 '19 14:08 MuhammadUzair

I went through gradle.bat installDebug --info for more info. I got

reactnativecommunity\slider\ReactSlider.java:11: error: package androidx.appcompat.widget does not exist

But when I check the build.gradle of the npm installed v2.0 version, I don't see anything referring to AppCompatSeekBar or androidx.appcompat.widget.AppCompatSeekBar

daxaxelrod avatar Aug 28 '19 23:08 daxaxelrod

Also running into this - has anyone got a solution yet? Using react native 0.57 and slider 1.1.3

vistafang avatar Sep 08 '19 07:09 vistafang

i was having a similar issue with a different package:

Execution failed for task ':@react-native-community_viewpager:compileReleaseJavaWithJavac'.)

This fixed it for me and I suspect it might help anyone running into this issue as well:

npm i jetifier npx jetify

boazeb avatar Dec 10 '19 17:12 boazeb

Anyone found a solution?

asim47 avatar May 07 '20 07:05 asim47

@asim47 If you're using androidX, which is now default for RN projects, try this answer https://stackoverflow.com/a/56674446/5745639

Taylor123 avatar May 07 '20 16:05 Taylor123

Hello have you find a solution, i have this issue with the last version with RN 0.64.2.

centotaure avatar Oct 08 '21 13:10 centotaure

Hello @centotaure! Can you open a new issue with details and reproduction example? I would handle it but this issue is very old and gives me no hint about where to start, so having your case with the latest version (v4.1.8) would be very helpful.

BartoszKlonowski avatar Oct 08 '21 15:10 BartoszKlonowski

Hi, can you open this issue again?

I'm getting the same error with RNCSlider v.4.1.3 & v4.1.8

Task :react-native-community_slider:compileReleaseJavaWithJavac FAILED /Users/runner/work/1/s/node_modules/@react-native-community/slider/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java:152: error: cannot find symbol if (view.isAccessibilityFocused() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { ^ symbol: variable R location: class VERSION_CODES

play-station avatar Oct 11 '21 19:10 play-station