maps icon indicating copy to clipboard operation
maps copied to clipboard

Can't build on Android [RN 0.72.14]

Open TobiDevloft opened this issue 1 year ago • 6 comments
trafficstars

Continuation of https://github.com/rnmapbox/maps/issues/3593

Environment

  • Dev OS: OSX 14.5
  • @rnmapbox/maps version: 10.1.30
  • React Native version: 0.72.14
  • Expo version: -

Steps to reproduce

npx [email protected] init sample --version 0.72.14
cd sample
yarn add @rnmapbox/maps
# Android Setup
yarn android

Result


> Task :rnmapbox_maps:processDebugManifest
package="com.rnmapbox.rnmbx" found in source AndroidManifest.xml: /Users/username/Projects/sample/node_modules/@rnmapbox/maps/android/src/main/AndroidManifest.xml.
Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated.
Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace
This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.

> Task :rnmapbox_maps:compileDebugKotlin
'compileDebugJavaWithJavac' task (current target is 11) and 'compileDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.

> Task :rnmapbox_maps:compileDebugKotlin FAILED
45 actionable tasks: 40 executed, 5 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

e: /Users/username/Projects/sample/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt: (212, 5): 'addView' overrides nothing
e: /Users/username/Projects/sample/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt: (227, 5): 'removeView' overrides nothing
e: /Users/username/Projects/sample/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt: (236, 5): 'removeAllViews' overrides nothing
e: /Users/username/Projects/sample/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt: (13, 5): 'getChildAt' overrides nothing
e: /Users/username/Projects/sample/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt: (17, 5): 'getChildCount' overrides nothing
e: /Users/username/Projects/sample/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt: (21, 5): 'addView' overrides nothing
e: /Users/username/Projects/sample/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt: (25, 5): 'removeViewAt' overrides nothing
e: /Users/username/Projects/sample/node_modules/@rnmapbox/maps/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ResourceDrawableIdHelper.kt: (5, 37): Unresolved reference: Companion

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':rnmapbox_maps:compileDebugKotlin'.

TobiDevloft avatar Aug 28 '24 10:08 TobiDevloft

Yes same here ++

badredaha avatar Aug 28 '24 13:08 badredaha

Force the rnmapbox version to be 10.1.29 or lower. This library raised the gradle target version so its no longer matching your RN gradle version.

My workiing setup although I am using expo:

{
    "react-native": "0.74.5",
    "@rnmapbox/maps": "10.1.29",
}

snowdamiz avatar Aug 28 '24 15:08 snowdamiz

same here, 10.1.29 doesnt solve the issue, ios is fine

image

dandrykevych avatar Aug 28 '24 18:08 dandrykevych

same here, 10.1.29 doesnt solve the issue, ios is fine

image

Yea it looks like you are having a different issue than what op had

snowdamiz avatar Aug 28 '24 18:08 snowdamiz

Hey folks, I'm having a similar issue:

Environment

Dev OS: Windows @rnmapbox/maps version: 10.1.29 React Native version: 0.74.3 Expo version: 51.0.23

Result running yarn android

> Task :rnmapbox_maps:compileDebugKotlin FAILED
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt:212:5 'addView' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt:227:5 'removeView' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt:236:5 'removeAllViews' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:13:5 'getChildAt' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:17:5 'getChildCount' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:21:5 'addView' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:25:5 'removeViewAt' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ResourceDrawableIdHelper.kt:5:37 Unresolved reference: Companion

FAILURE: Build failed with an exception.

Lucasdsk avatar Aug 28 '24 19:08 Lucasdsk

Hey folks, I'm having a similar issue:

Environment

Dev OS: Windows @rnmapbox/maps version: 10.1.29 React Native version: 0.74.3 Expo version: 51.0.23

Result running yarn android

> Task :rnmapbox_maps:compileDebugKotlin FAILED
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt:212:5 'addView' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt:227:5 'removeView' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt:236:5 'removeAllViews' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:13:5 'getChildAt' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:17:5 'getChildCount' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:21:5 'addView' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:25:5 'removeViewAt' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ResourceDrawableIdHelper.kt:5:37 Unresolved reference: Companion

FAILURE: Build failed with an exception.

Here is my working setup for expo right now

{
   "expo": "~51.0.26",
   "@rnmapbox/maps": "10.1.29",
   "react-native": "0.74.5",
}

snowdamiz avatar Aug 28 '24 19:08 snowdamiz

Hey folks, I'm having a similar issue:

Environment

Dev OS: Windows @rnmapbox/maps version: 10.1.29 React Native version: 0.74.3 Expo version: 51.0.23

Result running yarn android

> Task :rnmapbox_maps:compileDebugKotlin FAILED
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt:212:5 'addView' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt:227:5 'removeView' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt:236:5 'removeAllViews' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:13:5 'getChildAt' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:17:5 'getChildCount' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:21:5 'addView' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:25:5 'removeViewAt' overrides nothing
e: file:///C:/Users/lucas/Documents/development/app/node_modules/@rnmapbox/maps/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ResourceDrawableIdHelper.kt:5:37 Unresolved reference: Companion

FAILURE: Build failed with an exception.

Here is my working setup for expo right now

{
   "expo": "~51.0.26",
   "@rnmapbox/maps": "10.1.29",
   "react-native": "0.74.5",
}

Thank you, you just saved me a LOT of headache. Granted it's my own fault, I should've checked the issues earlier. I Thought It was something I did in my code. For now this is the best solution and can confirm works.

Ception avatar Aug 29 '24 01:08 Ception

I also had the issue on RN 0.74, reverting to rnmapbox/maps 10.1.27 solved the issue.

Gp2mv3 avatar Aug 29 '24 09:08 Gp2mv3

@snowdamiz Thank you, reverting to "10.1.29" resolved the issue for me!

TobiDevloft avatar Aug 29 '24 10:08 TobiDevloft

@TobiDevloft you can open the issue. I'll need to take a look, to see if we can make rnmapbox compatible with both RN<0.75 and >=0.75. In 10.1.30 I've made it compile with RN 0.75, but it sounds like this breaks with <=RN 0.74. At worst we'll need to provide patches so ppl can use the latest version with older react using patch-packages

mfazekas avatar Aug 29 '24 11:08 mfazekas

Alright, reopening! Thanks for your work :)

TobiDevloft avatar Aug 29 '24 11:08 TobiDevloft

I have the same problem, did you find a solution?

"react-native": "0.72.1", "@rnmapbox/maps": "10.1.29"

Lacerda53 avatar Aug 29 '24 15:08 Lacerda53

same:

"@rnmapbox/maps": "^10.1.28",

periakteon avatar Aug 30 '24 19:08 periakteon

same:

"@rnmapbox/maps": "^10.1.28",

Remove the ^. What is your RN version?

snowdamiz avatar Aug 30 '24 19:08 snowdamiz

same: "@rnmapbox/maps": "^10.1.28",

Remove the ^. What is your RN version?

I fixed by changing to:

https://github.com/rnmapbox/maps/issues/3598#issuecomment-2316145748

periakteon avatar Aug 30 '24 19:08 periakteon

released v10.1.31-rc.0 this should work with RN 0.75, and 0.72 pls test

mfazekas avatar Sep 01 '24 07:09 mfazekas

I still have this issue with v10.1.31-rc.0:

Task :rnmapbox_maps:compileDebugKotlin FAILED e: ResourceDrawableIdHelper.kt:5:37 Unresolved reference: Companion

ext.kotlinVersion = '1.9.21' [email protected] @rnmapbox/[email protected]

Just did another test with 0.72 but it still fails with rc.0:

npx react-native init MapboxTest --version 0.72.1
cd MapboxTest
yarn add @rnmapbox/[email protected]
# update android/build.grale with maven repo details
yarn android
> Task :rnmapbox_maps:compileDebugKotlin FAILED
45 actionable tasks: 45 executed

info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 

e: /Users/mattijs/Development/MapboxTest/node_modules/@rnmapbox/maps/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ResourceDrawableIdHelper.kt: (5, 37): Unresolved reference: Companion

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':rnmapbox_maps:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

mattijsf avatar Sep 02 '24 08:09 mattijsf

@mfazekas

I think it's better for now to either not override ResourceDrawableIdHelper.getInstance and just use the deprecated ResourceDrawableIdHelper.getInstance in the codebase. Or create a

class ResourceDrawableIdHelperCompat {
    companion object {
        fun getInstance(): ResourceDrawableIdHelper {
            return ResourceDrawableIdHelper.getInstance() // deprecated, .instance is preferred but can't be used on rn <0.75
        }
    }
}

and reference ResourceDrawableIdHelperCompat everywhere but it doesn't make much sense expect for have a single point for refactoring the accessor later on.

mattijsf avatar Sep 02 '24 09:09 mattijsf

@mattijsf thanks, do you have new arch enabled? Not sure why I haven't seen this issue, while testing... Sure we can remove getInstance override. I think a few RC's ago this was RN0.75 was not working without it. Sure we can live with deprecated.

mfazekas avatar Sep 03 '24 07:09 mfazekas

@mattijsf thanks, do you have new arch enabled? Not sure why I haven't seen this issue, while testing... Sure we can remove getInstance override. I think a few RC's ago this was RN0.75 was not working without it. Sure we can live with deprecated.

I'm not using new arch. Just the instructions I wrote in https://github.com/rnmapbox/maps/issues/3598#issuecomment-2324118509 are enough. Maybe you hit some caching / node_modules situation where the build succeeded with the change 🤷

mattijsf avatar Sep 03 '24 12:09 mattijsf

Force the rnmapbox version to be 10.1.29 or lower. This library raised the gradle target version so its no longer matching your RN gradle version.

My workiing setup although I am using expo:

{
    "react-native": "0.74.5",
    "@rnmapbox/maps": "10.1.29",
}

I am using the same version, but still failed

luniumall avatar Sep 03 '24 16:09 luniumall

I still have this issue with v10.1.31-rc.0:

Task :rnmapbox_maps:compileDebugKotlin FAILED e: ResourceDrawableIdHelper.kt:5:37 Unresolved reference: Companion

ext.kotlinVersion = '1.9.21' [email protected] @rnmapbox/[email protected]

Just did another test with 0.72 but it still fails with rc.0:

npx react-native init MapboxTest --version 0.72.1
cd MapboxTest
yarn add @rnmapbox/[email protected]
# update android/build.grale with maven repo details
yarn android
> Task :rnmapbox_maps:compileDebugKotlin FAILED
45 actionable tasks: 45 executed

info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 

e: /Users/mattijs/Development/MapboxTest/node_modules/@rnmapbox/maps/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ResourceDrawableIdHelper.kt: (5, 37): Unresolved reference: Companion

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':rnmapbox_maps:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

same here

luniumall avatar Sep 03 '24 19:09 luniumall

It's unbelievable the amount of people that don't bother reading comments. Pure laziness 😂

Ception avatar Sep 04 '24 00:09 Ception

Can you try with v10.1.31-rc.1 ?

released v10.1.31-rc.1 this should work with RN 0.75, and 0.72 pls test

mfazekas avatar Sep 06 '24 03:09 mfazekas

I can confirm this is working for me

{
    "react-native": "0.74.3",
    "@rnmapbox/maps": "10.1.29",
}

Dat-Mobile avatar Sep 09 '24 18:09 Dat-Mobile