amplitude/Amplitude-TypeScript

Unable to compile app when adding @amplitude/analytics-react-native

mihaibulic2 opened this issue · 7 comments

Expected Behavior

Should compile

Current Behavior

Doesn't:

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/Users/mihai/dev/paced-breathing-3.0/react-native/android/app/build.gradle' line: 2

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.facebook.react'.
   > The value for property 'languageVersion' is final and cannot be changed any further.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

* 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 6s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installPlayDebug -PreactNativeDevServerPort=8081 FAILURE: Build completed with 2 failures. 1: Task failed with an exception.
-----------
* Where:
Build file '/Users/mihai/dev/paced-breathing-3.0/react-native/android/app/build.gradle' line: 2 * What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.facebook.react'. > The value for property 'languageVersion' is final and cannot be changed any further. * 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.
============================================================================== 2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle * 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 6s.
info Run CLI with --verbose flag for more details.

This seems like nonsense errors:

  • I didn't change anything related to languageVersion or facebook/react
  • I do specify compileSdkVersion

Possible Solution

Steps to Reproduce

  1. Update to:
  • RN 0.73.6
  • Gradle: gradle-8.7
  • Android gradle plug-in: 8.3.1
  • Target Android SDK 34
  • Java 17
  1. run npx react-native run-android --mode=playDebug, everything compiles and runs works perfectly
  2. npm install @amplitude/analytics-react-native@latest
  3. run npx react-native run-android --mode=playDebug again, annnnd compile errors

I wasted a whole day dealing with this. As of now, I just ripped out Amplitude from our app entirely in favor of Firebase/GA which works more easily / hasn't caused us any problems. If this gets fixed, could add Amp back, but atm it's just too much of a pain / not worth it.

This seems to be an issue with the plugin not being tested with React Native 0.73. Unfortunately the solution is to remove @amplitude/analytics-react-native.

You guys can’t just fix this? You’re just saying I have to find another analytics provider / can’t use Amplitude?

I can confirm that it's not working with RN 73, as mentioned in original post as soon as you add the plugin, it gives you the following error

`1: Task failed with an exception.

  • Where:
    Build file '/Users/XXXX/android/app/build.gradle' line: 2

  • What went wrong:
    A problem occurred evaluating project ':app'.

Failed to apply plugin 'com.facebook.react'.
The value for property 'languageVersion' is final and cannot be changed any further.

  • 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.
==============================================================================

2: Task failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':app'.

com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

  • 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.
==============================================================================`

@nmongiya @mihaibulic2 - I tried testing the amplitude library against both 0.73.6 and 0.74.1 and I am not running into this issue in there.

Here's a branch which has test apps with version 0.74.1 (Amplitude-TypeScript/examples/react-native/app_v2/) and 0.73.6 (Amplitude-TypeScript/examples/react-native/app_v2/)

Gradle version

izaaz.yunus@Izaazs-MacBook-Pro android % ./gradlew -v                                       

------------------------------------------------------------
Gradle 8.7
------------------------------------------------------------

Build time:   2024-03-22 15:52:46 UTC
Revision:     650af14d7653aa949fce5e886e685efc9cf97c10

Kotlin:       1.9.22
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          17.0.5 (Oracle Corporation 17.0.5+9-LTS-191)
OS:           Mac OS X 14.2.1 aarch64

Am I missing something in my test?

Also, could you please share your build.gradle file? Maybe y'all have something configured there which I haven't?

image

Closing this issue since I see it working with the latest version of RN. But if anyone has any more information to share, I'm happy to spend more time understand why it may not be working.

I'm having the same error when @amplitude/analytics-react-native version 1.4.9 is autolinked in my project that has React Native 0.72.10.

------------------------------------------------------------
Gradle 8.5
------------------------------------------------------------

Build time:   2023-11-29 14:08:57 UTC
Revision:     28aca86a7180baa17117e0e5ba01d8ea9feca598

Kotlin:       1.9.20
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          17.0.10 (Azul Systems, Inc. 17.0.10+7-LTS)
OS:           Mac OS X 14.2.1 aarch64

@izaaz would you suggest me to upgrade to Gradle 8.7?

After upgrading to Gradle 8.7 I started getting 3 different errors rather than 2. It is still an app with React Native 0.72.10.

FAILURE: Build completed with 3 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/[my-app]/android/app/build.gradle' line: 3

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.facebook.react'.
   > The value for property 'languageVersion' is final and cannot be changed any further.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle

* 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.
==============================================================================

3: Task failed with an exception.
-----------
* What went wrong:
Failed to query the value of property 'buildFlowServiceProperty'.
> Could not isolate value org.jetbrains.kotlin.gradle.plugin.statistics.BuildFlowService$Parameters_Decorated@1a5a7375 of type BuildFlowService.Parameters
   > A problem occurred configuring project ':app'.
      > compileSdkVersion is not specified. Please add it to build.gradle

* 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.
==============================================================================

------------------------------------------------------------
Gradle 8.7
------------------------------------------------------------

Build time:   2024-03-22 15:52:46 UTC
Revision:     650af14d7653aa949fce5e886e685efc9cf97c10

Kotlin:       1.9.22
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          17.0.10 (Azul Systems, Inc. 17.0.10+7-LTS)
OS:           Mac OS X 14.2.1 aarch64