AndrewDongminYoo / react-native-step-counter

[리액트 네이티브 라이브러리] 사용자의 걸음 수를 계산합니다. Android는 StepCounter (or Accelerometer) 센서 API를, iOS는 CoreMotion CMPedometer 를 사용하여 걸음 수를 측정합니다.
https://andrewdongminyoo.github.io/react-native-step-counter/
MIT License
29 stars 10 forks source link

"compileDebugKotlin" Error when trying to build for android #47

Open aykutmehmetd opened 4 months ago

aykutmehmetd commented 4 months ago

React Native Step Counter New Issue

Expected Behavior

Actual Behavior

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':dongminyu_react-native-step-counter:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction

Steps to Reproduce the Problem

  1. npx create-expo-app my-app --template tabs@50
  2. npx expo install @dongminyu/react-native-step-counter
  3. eas init
  4. Create eas.json:
    {
    "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "distribution": "internal"
    },
    "production": {}
    }
    }
  5. app.json:
    {
    "expo": {
    "android": {
      "permissions": [
        "android.permission.ACTIVITY_RECOGNITION",
        "android.permission.BODY_SENSORS_BACKGROUND"
      ],
    },
    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "newArchEnabled": true,
          }
        }
      ]
    ],
    }
    }
  6. eas build -e development -p android

Specifications

first, you should check your react-native-step-counter version and write it down.

second, you should check your react-native version and write it down. you should use this command. npx react-native info and then, it would be better if you paste the output of this command.


System:
  OS: macOS 14.4.1
  CPU: (8) arm64 Apple M1
  Memory: 79.73 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.0
    path: /usr/local/bin/node
  Yarn: Not Found
  npm:
    version: 9.8.1
    path: /usr/local/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11330709
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: javac 17
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.6
    wanted: 0.73.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
AndrewDongminYoo commented 4 months ago

Thank you for your interest and first issue. I don't know much about the Expo ecosystem, and I haven't used it recently, so I can't say for sure, but it seems like it would be pretty hard to use React Native's new architecture (Turbo Modules and Fabric Components) in an Expo-managed workflow app. You can consider the following approaches to resolve the issue:

aykutmehmetd commented 4 months ago

I didn't use new architecture, so i can't say for sure about how can be hard to use the new architecture in Expo workflow.

  1. Transition to Expo Bare Workflow: I'm already trying to do this. If I build the app, I will already be in bare workflow.
  2. Creating a pure React Native project: Maybe i can try this but eventually i need to use Expo in production.

Ok then, I'll keep trying to find an solution. If i do, I'll let you know.

YesSkyscrapers commented 4 months ago

I got same error without expo and new architecture, but before this error i got this:

`e: /Users/macbook/Documents/projects/project/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt: (38, 26): Property getter or setter expected e: /Users/macbook/Documents/projects/project/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt: (64, 9): Unresolved reference: sensorManager e: /Users/macbook/Documents/projects/project/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt: (68, 38): Unresolved reference: sensorManager e: /Users/macbook/Documents/projects/project/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt: (70, 40): Unresolved reference: sensorManager e: /Users/macbook/Documents/projects/project/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt: (105, 38): Unresolved reference: sensorManager e: /Users/macbook/Documents/projects/project/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt: (107, 40): Unresolved reference: sensorManager Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

Original error looks like "StepCounterModule.kt: (38, 26): Property getter or setter expected" Im not good at kotlin, but looks like kotlin version error, but i tried change 1.6.0-1.7.0-1.8.0, but still got error...

Maybe it will help with issue

nppull commented 3 months ago

same problem

android 
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34
kotlinVersion = "1.9.0"

react-native: 0.73.5
@dongminyu/react-native-step-counter: 0.2.5
AndrewDongminYoo commented 3 months ago

I thought it was simply an issue with trying to use this module in expo, but it looks like there's something wrong with the kotlin area. I'll try a few more things to reproduce and resolve this issue and let you know what I find.

sonirudra commented 3 months ago

same here, in Bare workflow.

nstegwart commented 1 week ago

Newest react native using kotlin '1.9.23', can you upgrade this library kotlin version? Maybe this will resolve the issue

I got the same error. I upgraded React Native from 0.72 to 0.74 in the Expo Bare Workflow. It was actually stable in React Native 0.72, but when I upgraded, an error appeared:

Task :dongminyu_react-native-step-counter:compileDebugKotlin FAILED e: file:///project_folder/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt:38:26 Property getter or setter expected e: file:///project_folder/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt:64:9 Unresolved reference: sensorManager e: file:///project_folder/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt:68:38 Unresolved reference: sensorManager e: file:///project_folder/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt:70:40 Unresolved reference: sensorManager e: file:///project_folder/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt:105:38 Unresolved reference: sensorManager e: file:///project_folder/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt:107:40 Unresolved reference: sensorManager

FAILURE: Build failed with an exception.

nstegwart commented 1 week ago

Newest react native using kotlin '1.9.23', can you upgrade this library kotlin version? Maybe this will resolve the issue

I got the same error. I upgraded React Native from 0.72 to 0.74 in the Expo Bare Workflow. It was actually stable in React Native 0.72, but when I upgraded, an error appeared:

Task :dongminyu_react-native-step-counter:compileDebugKotlin FAILED e: file:///project_folder/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt:38:26 Property getter or setter expected e: file:///project_folder/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt:64:9 Unresolved reference: sensorManager e: file:///project_folder/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt:68:38 Unresolved reference: sensorManager e: file:///project_folder/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt:70:40 Unresolved reference: sensorManager e: file:///project_folder/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt:105:38 Unresolved reference: sensorManager e: file:///project_folder/node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt:107:40 Unresolved reference: sensorManager

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':dongminyu_react-native-step-counter:compileDebugKotlin'.

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction Compilation error. See log for more details

I've successfully run the library on Expo Bare Workflow (React Native 0.74) with the following modifications:

Changes Made:

  1. Edited the gradle.properties file Path: node_modules/@dongminyu/react-native-step-counter/android/build.gradle Updated the following lines: StepCounter_compileSdkVersion=34 StepCounter_kotlinVersion=1.9.23 StepCounter_targetSdkVersion=34 StepCounter_minSdkVersion=24 StepCounter_ndkversion=26.1.10909125

  2. Edited the sensorManager variable Path: node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.kt Changed this line: private val lateinit sensorManager: SensorManager to: private var sensorManager: SensorManager

  3. Update the minSdkVersion in android/build.gradle to 24.

  4. Then yarn android