Task :segment_analytics-react-native:compileDebugKotlin FAILED

See original GitHub issue

This problem started after updating Android Studio and Kotlin plugin to latest versions, on Windows as well as Ubuntu.

React Native: 0.63.2 Android Studio Version 4.1 Kotlin Version: 1.4.10

Command: yarn run android

Logs:

Welcome to Gradle 6.2!

Here are the highlights of this release:
 - Dependency checksum and signature verification
 - Documentation links in deprecation messages
 - Shareable read-only dependency cache

For more details see https://docs.gradle.org/6.2/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

> .... Other Tasks ....

> Task :segment_analytics-react-native:compileDebugKotlin FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
133 actionable tasks: 133 executed
Note: /path/to/project/parent/rn-app/node_modules/@react-native-community/async-storage/android/src/main/java/com
/reactnativecommunity/asyncstorage/AsyncStorageModule.java uses or overrides a deprecated API.

.... Some other Notes ....

Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
e: /path/to/project/parent/rn-app/node_modules/@segment/analytics-react-native/android/src/main/java/com/segment/
analytics/reactnative/core/RNAnalyticsModule.kt: (279, 27): 'forEach((Map.Entry<K, V>) -> Unit): Unit' is only available since 
Kotlin 1.3.50 and cannot be used in Kotlin 1.3
e: /path/to/project/parent/rn-app/node_modules/@segment/analytics-react-native/android/src/main/java/com/segment/
analytics/reactnative/core/RNAnalyticsModule.kt: (283, 32): 'forEach((Map.Entry<K, V>) -> Unit): Unit' is only available since 
Kotlin 1.3.50 and cannot be used in Kotlin 1.3

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':segment_analytics-react-native:compileDebugKotlin'.
> Compilation error. See log for more 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 6m 16s

error Failed to install the app. Make sure you have the Android development environment set up: 
https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
error Command failed with exit code 1.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:22
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

19reactions
chinvib66commented, Oct 16, 2020

So, I solved this by setting kotlinVersion in project/android/build.gradle to the installed version 1.4.10

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 16
        compileSdkVersion = 29
        targetSdkVersion = 29
        kotlinVersion = "1.4.10"
    }

.... rest of the code

From the logs in my 1st comment I see that the problem lies in the usage of Unit class in the package, which is introduced in Kotlin v 1.3.50; while the package specifies default version to be used as 1.3.21 as seen here.

So, I guess the defaultKotlinVersion for the package needs to be upgraded to atleast 1.3.50 for proper functioning.

4reactions
anisurrahman072commented, Nov 4, 2022

Hey guys, I have found these two lines in the log: One is: react-native-agora:compileDebugKotlin Two is: Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.0.

So then i updated my android/build.gradle. So i basically add this line under ext

ext {
	....... other code
        kotlinVersion = "1.6.0"
}

That’s it. It is working perfectly now 🎉🚀✌️

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native-screens:compileDebugKotlin FAILED
The error I get is the following: Task :react-native-screens:compileDebugKotlin FAILED Deprecated Gradle features were used in this build, ...
Read more >
Analytics for React Native 2.0 | Segment Documentation
Analytics React Native 2.0 enables you to process and track the history of a payload, while Segment controls the API and prevents unintended...
Read more >
@segment/analytics-react-native-plugin-mixpanel - npm
The hassle-free way to add Segment analytics to your React-Native app.. Latest version: 0.2.4, last published: a month ago.
Read more >
React-Native Execution failed for task - Ananda
Task :react-native-gesture-handler:compileDebugKotlin FAILED. Adding the following lines in the android/build.gradle fixes the error: buildscript {
Read more >
segment/analytics-react-native-mixpanel - npm package - Snyk
Mixpanel Integration for Segment's React-Native analytics library. ... Settings that will be used if the request to get the settings from Segment fails....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found