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

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

Open
aykutmehmetd opened this issue Apr 3, 2024 · 8 comments
Open

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

aykutmehmetd opened this issue Apr 3, 2024 · 8 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@aykutmehmetd
Copy link

aykutmehmetd commented Apr 3, 2024

React Native Step Counter New Issue

Expected Behavior

  • I am trying to build with this library.

Actual Behavior

  • I am getting the following error:
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": {}
  }
}
  1. app.json:
{
  "expo": {
    "android": {
      "permissions": [
        "android.permission.ACTIVITY_RECOGNITION",
        "android.permission.BODY_SENSORS_BACKGROUND"
      ],
    },
    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "newArchEnabled": true,
          }
        }
      ]
    ],
  }
}
  1. eas build -e development -p android

Specifications

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

  • @dongminyu/react-native-step-counter version: 0.2.5

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.

  • INFO OUTPUT
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
@aykutmehmetd aykutmehmetd changed the title "compileDebugKotlin" Error in build "compileDebugKotlin" Error in android build Apr 3, 2024
@aykutmehmetd aykutmehmetd changed the title "compileDebugKotlin" Error in android build "compileDebugKotlin" Error when trying to build for android Apr 3, 2024
@AndrewDongminYoo
Copy link
Owner

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:

  • Transition to Expo Bare Workflow: Only limited native modules are available in the Expo Managed workflow, so you can switch to the Expo Bare workflow to give you access to native code and libraries.

  • Creating a pure React Native project: How to create a pure React Native project using the npx react-native init command, without using Expo, to include the @dongminyu/react-native-step-counter library.

@aykutmehmetd
Copy link
Author

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
Copy link

YesSkyscrapers commented Apr 17, 2024

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.

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

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction`

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
Copy link

nppull commented May 7, 2024

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
Copy link
Owner

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.

@AndrewDongminYoo AndrewDongminYoo added bug Something isn't working good first issue Good for newcomers labels May 12, 2024
@AndrewDongminYoo AndrewDongminYoo self-assigned this May 12, 2024
@sonirudra
Copy link

same here, in Bare workflow.

@nstegwart
Copy link

nstegwart commented Aug 19, 2024

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

@nstegwart
Copy link

nstegwart commented Aug 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants