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

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

Closed
ShchipskiiYura opened this issue Dec 8, 2023 · 6 comments
Closed

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

ShchipskiiYura opened this issue Dec 8, 2023 · 6 comments
Labels
Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Version Info Platform: Android Android applications.

Comments

@ShchipskiiYura
Copy link

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

Copy link

github-actions bot commented Dec 8, 2023

⚠️ 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

@github-actions github-actions bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Dec 8, 2023
Copy link

github-actions bot commented Dec 8, 2023

⚠️ 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.

@github-actions github-actions bot added Platform: Android Android applications. and removed Needs: Triage 🔍 labels Dec 8, 2023
@cortinico
Copy link
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

@professorkolik
Copy link

professorkolik commented Dec 19, 2023

@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

@cortinico
Copy link
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.

@professorkolik
Copy link

@cortinico thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Version Info Platform: Android Android applications.
Projects
None yet
Development

No branches or pull requests

3 participants