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

View does not build on Android with React Native 0.60(+) #29

Closed
brodycj opened this issue Jul 11, 2019 · 1 comment · Fixed by #244
Closed

View does not build on Android with React Native 0.60(+) #29

brodycj opened this issue Jul 11, 2019 · 1 comment · Fixed by #244
Labels
bug Something isn't working

Comments

@brodycj
Copy link
Owner

brodycj commented Jul 11, 2019

create-react-native-module version: 0.5.0

Command used to generate view module with example:

create-react-native-module --generate-example --view beth-adam

Build output from react-native run-android in generated example:

info JS server already running.
info Installing the app...

> Configure project :react-native-beth-adam
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

> Task :react-native-beth-adam:compileDebugJavaWithJavac

> Task :react-native-beth-adam:compileDebugJavaWithJavac FAILED

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
20 actionable tasks: 20 executed
/Users/brodybits/dev/ctt-b54ec259-dc4d/test1/react-native-beth-adam/example/node_modules/react-native-beth-adam/android/src/main/java/com/reactlibrary/BethAdamManager.java:5: error: package android.support.v7.widget does not exist
import android.support.v7.widget.AppCompatCheckBox;
                                ^
/Users/brodybits/dev/ctt-b54ec259-dc4d/test1/react-native-beth-adam/example/node_modules/react-native-beth-adam/android/src/main/java/com/reactlibrary/BethAdamManager.java:22: error: cannot find symbol
        AppCompatCheckBox cb = new AppCompatCheckBox(c);
        ^
  symbol:   class AppCompatCheckBox
  location: class BethAdamManager
/Users/brodybits/dev/ctt-b54ec259-dc4d/test1/react-native-beth-adam/example/node_modules/react-native-beth-adam/android/src/main/java/com/reactlibrary/BethAdamManager.java:22: error: cannot find symbol
        AppCompatCheckBox cb = new AppCompatCheckBox(c);
                                   ^
  symbol:   class AppCompatCheckBox
  location: class BethAdamManager
3 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-beth-adam: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

BUILD FAILED in 32s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/Users/brodybits/dev/ctt-b54ec259-dc4d/test1/react-native-beth-adam/example/node_modules/react-native-beth-adam/android/src/main/java/com/reactlibrary/BethAdamManager.java:5: error: package android.support.v7.widget does not exist
import android.support.v7.widget.AppCompatCheckBox;
                                ^
/Users/brodybits/dev/ctt-b54ec259-dc4d/test1/react-native-beth-adam/example/node_modules/react-native-beth-adam/android/src/main/java/com/reactlibrary/BethAdamManager.java:22: error: cannot find symbol
        AppCompatCheckBox cb = new AppCompatCheckBox(c);
        ^
  symbol:   class AppCompatCheckBox
  location: class BethAdamManager
/Users/brodybits/dev/ctt-b54ec259-dc4d/test1/react-native-beth-adam/example/node_modules/react-native-beth-adam/android/src/main/java/com/reactlibrary/BethAdamManager.java:22: error: cannot find symbol
        AppCompatCheckBox cb = new AppCompatCheckBox(c);
                                   ^
  symbol:   class AppCompatCheckBox
  location: class BethAdamManager
3 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-beth-adam: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

BUILD FAILED in 32s

    at checkExecSyncError (child_process.js:629:11)
    at execFileSync (child_process.js:647:13)
    at runOnAllDevices (/Users/brodybits/dev/ctt-b54ec259-dc4d/test1/react-native-beth-adam/example/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
    at buildAndRun (/Users/brodybits/dev/ctt-b54ec259-dc4d/test1/react-native-beth-adam/example/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:137:41)
    at then.result (/Users/brodybits/dev/ctt-b54ec259-dc4d/test1/react-native-beth-adam/example/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:103:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Related to #25 (updates for React Native 0.60)

P.S. I think the underlying cause is using importing AppCompatCheckBox from android.support.v7.widget, which seems to be not included by default when using React Native 0.60. Any help with a simple, clean workaround solution to get a sample widget working on recent versions of React Native would be highly appreciated. Doesn’t matter so much which widget, no need for consistency with iOS, just to get this working.

@brodycj brodycj added bug Something isn't working help wanted Extra attention is needed labels Jul 11, 2019
This was referenced Jul 11, 2019
@brodycj brodycj removed the help wanted Extra attention is needed label Jul 22, 2019
@brodycj
Copy link
Owner Author

brodycj commented Jul 22, 2019

The following update seems to solve this issue:

diff --git a/templates/android.js b/templates/android.js
index c9e0648..f2b235a 100644
--- a/templates/android.js
+++ b/templates/android.js
@@ -179,7 +179,7 @@ public class ${name}Module extends ReactContextBaseJavaModule {
 
 import android.view.View;
 
-import android.support.v7.widget.AppCompatCheckBox;
+import androidx.appcompat.widget.AppCompatCheckBox;
 
 import com.facebook.react.uimanager.SimpleViewManager;
 import com.facebook.react.uimanager.ThemedReactContext;

This change should be applied to a generated View project if it is needed for React Native 0.60(+) on Android.

Unfortunately this update would cause a similar failure on React Native pre-0.60. I hope we can drop support for RN pre-0.60 someday.

brodycj pushed a commit that referenced this issue Aug 4, 2019
@brodycj brodycj changed the title View does not build on Android with React Native 0.60 View does not build on Android with React Native 0.60(+) Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant