Skip to content

[0.73] Crash build android app when update packages #41854

Closed

Description

@ShchipskiiYura

Description

import com.brentvatne.react.ReactVideoPackage

...

 override fun getPackages(): ArrayList<ReactPackage> {
            packages.add(new ReactVideoPackage())
            // Packages that cannot be autolinked yet can be added manually here, for example:
            // packages.add(new MyReactNativePackage());
            return PackageList(this).packages

        }

When I try to add new package to getPackages method in android, I have crash a build with error

file:///Users/username/Desktop/projectName/android/app/src/main/java/com/projectName/MainApplication.kt:44:26 Unresolved reference: new

FAILURE: Build failed with an exception.

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

Steps to reproduce

yarn android

React Native Version

0.73

Affected Platforms

Runtime - Android

Output of npx react-native info

emulator pixel 4

Stacktrace or Logs

Note: Recompile with -Xlint:unchecked for details.
e: file:///Users/user/Desktop/projectName/android/app/src/main/java/com/projectName/MainApplication.kt:44:48 Expecting an expression
e: file:///Users/user/Desktop/projectName/android/app/src/main/java/com/projectName/MainApplication.kt:44:26 Unresolved reference: new

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > 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.

Reproducer

https://github.com/

Screenshots and Videos

No response

Activity

  1. github-actions commented on Dec 8, 2023

    @github-actions
    ⚠️ Add or Reformat Version Info
    ℹ️ We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.70.2
  2. github-actions commented on Dec 8, 2023

    @github-actions
    ⚠️ Missing Reproducible Example
    ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
    • If your bug is UI related: a Snack
    • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
  3. cortinico commented on Dec 8, 2023

    @cortinico
    Contributor

    Closing as you provided no reproducer.
    Your code is not compiling, most likely because you have a missing import.
    Sadly without a reproducer I can't tell you exaclty which line is broken and which import to include

  4. professorkolik commented on Dec 19, 2023

    @professorkolik

    @cortinico there is no need to create reproducer since the "issue" exists in ReproducerApp by default

    It's about this line
    https://github.com/react-native-community/reproducer-react-native/blob/main/ReproducerApp/android/app/src/main/java/com/reproducerapp/MainApplication.kt#L21

    Just uncomment packages.add(); and AndroidStudio will throw error => Unresolved reference: add

    So I assume it should look smth like

    override fun getPackages(): List<ReactPackage> {
       val packages = PackageList(this).packages
       
       packages.add(new MyReactNativePackage());
    
       return packages;
    }
    

    [UPD] Additionally because of moving to Kotlin no need to have new for creating instance as per https://kotlinlang.org/docs/classes.html#creating-instances-of-classes

  5. cortinico commented on Dec 27, 2023

    @cortinico
    Contributor

    @professorkolik this will be fixed in 0.73.2
    The fix is here: #41856
    It's a comment also so it's a low priority fix.

  6. professorkolik commented on Dec 27, 2023

    @professorkolik

    @cortinico thank you

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions