react-native-step-counter
react-native-step-counter copied to clipboard
"compileDebugKotlin" Error when trying to build for android
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
npx create-expo-app my-app --template tabs@50npx expo install @dongminyu/react-native-step-countereas initCreate eas.json:
{
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"distribution": "internal"
},
"production": {}
}
}
app.json:
{
"expo": {
"android": {
"permissions": [
"android.permission.ACTIVITY_RECOGNITION",
"android.permission.BODY_SENSORS_BACKGROUND"
],
},
"plugins": [
[
"expo-build-properties",
{
"android": {
"newArchEnabled": true,
}
}
]
],
}
}
eas build -e development -p android
Specifications
first, you should check your
react-native-step-counterversion and write it down.
- @dongminyu/react-native-step-counter version: 0.2.5
second, you should check your
react-nativeversion and write it down. you should use this command.npx react-native infoand 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
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.
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.
- Transition to Expo Bare Workflow: I'm already trying to do this. If I build the app, I will already be in bare workflow.
- 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.
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
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
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.
same here, in Bare workflow.
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
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:
-
Edited the gradle.properties file Path:
node_modules/@dongminyu/react-native-step-counter/android/build.gradleUpdated the following lines:StepCounter_compileSdkVersion=34StepCounter_kotlinVersion=1.9.23StepCounter_targetSdkVersion=34StepCounter_minSdkVersion=24StepCounter_ndkversion=26.1.10909125 -
Edited the sensorManager variable Path:
node_modules/@dongminyu/react-native-step-counter/android/src/main/java/com/stepcounter/StepCounterModule.ktChanged this line:private val lateinit sensorManager: SensorManagerto:private var sensorManager: SensorManager -
Update the
minSdkVersioninandroid/build.gradleto24. -
Then
yarn android