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

Can't build on Android [RN 0.72.14] #3598

Closed
TobiDevloft opened this issue Aug 28, 2024 · 25 comments · Fixed by #3604 or #3613
Closed

Can't build on Android [RN 0.72.14] #3598

TobiDevloft opened this issue Aug 28, 2024 · 25 comments · Fixed by #3604 or #3613

Comments

@TobiDevloft
Copy link

TobiDevloft commented Aug 28, 2024

Continuation of #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'.
@badredaha
Copy link

Yes same here ++

@snowdamiz
Copy link

snowdamiz commented Aug 28, 2024

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",
}

@dandrykevych
Copy link

dandrykevych commented Aug 28, 2024

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

image

@snowdamiz
Copy link

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

@Lucasdsk
Copy link

Lucasdsk commented Aug 28, 2024

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.

@snowdamiz
Copy link

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",
}

@Ception
Copy link

Ception commented Aug 29, 2024

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.

@Gp2mv3
Copy link
Contributor

Gp2mv3 commented Aug 29, 2024

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

@TobiDevloft
Copy link
Author

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

@mfazekas
Copy link
Contributor

@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

@TobiDevloft
Copy link
Author

Alright, reopening! Thanks for your work :)

@TobiDevloft TobiDevloft reopened this Aug 29, 2024
@Lacerda53
Copy link

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

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

@periakteon
Copy link

same:

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

@snowdamiz
Copy link

same:

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

Remove the ^. What is your RN version?

@periakteon
Copy link

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

Remove the ^. What is your RN version?

I fixed by changing to:

#3598 (comment)

@mfazekas
Copy link
Contributor

mfazekas commented Sep 1, 2024

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

@mattijsf
Copy link
Member

mattijsf commented Sep 2, 2024

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

mattijsf commented Sep 2, 2024

@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.

@mfazekas
Copy link
Contributor

mfazekas commented Sep 3, 2024

@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.

@mattijsf
Copy link
Member

mattijsf commented Sep 3, 2024

@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 #3598 (comment) are enough. Maybe you hit some caching / node_modules situation where the build succeeded with the change 🤷

@luniumall
Copy link

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

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

@Ception
Copy link

Ception commented Sep 4, 2024

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

@mfazekas
Copy link
Contributor

mfazekas commented Sep 6, 2024

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

@Dat-Mobile
Copy link

I can confirm this is working for me

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet