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

Build failed for Android, Unity 2023.2.15f1, library version 1.0.10 #123

Open
braginpavel opened this issue Jun 24, 2024 · 18 comments
Open

Comments

@braginpavel
Copy link

braginpavel commented Jun 24, 2024

Hi,

Tried to build app for Android, Unity 2023.2.15f1, library version 1.0.10. Got error below:

> Task :azesmway_react-native-unity:compileDebugJavaWithJavac FAILED
/Users/paul/Documents/projects/project/node_modules/@azesmway/react-native-unity/android/src/main/java/com/azesmwayreactnativeunity/UPlayer.java:100: error: incompatible types: UnityPlayer cannot be converted to FrameLayout
            return unityPlayer;
                   ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':azesmway_react-native-unity:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/8.0.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 20s
329 actionable tasks: 4 executed, 325 up-to-date
Error: /Users/paul/Documents/projects/project/android/gradlew exited with non-zero code: 1
Error: /Users/paul/Documents/projects/project/android/gradlew exited with non-zero code: 1
    at ChildProcess.completionListener (/Users/paul/Documents/projects/project/node_modules/@expo/cli/node_modules/@expo/spawn-async/build/spawnAsync.js:52:23)
    at Object.onceWrapper (node:events:629:26)
    at ChildProcess.emit (node:events:514:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
    ...
    at Object.spawnAsync [as default] (/Users/paul/Documents/projects/project/node_modules/@expo/cli/node_modules/@expo/spawn-async/build/spawnAsync.js:17:21)
    at spawnGradleAsync (/Users/paul/Documents/projects/project/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:72:46)
    at Object.assembleAsync (/Users/paul/Documents/projects/project/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:52:18)
    at runAndroidAsync (/Users/paul/Documents/projects/project/node_modules/@expo/cli/build/src/run/android/runAndroidAsync.js:36:24)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@cf-moritzjaeger
Copy link

I am having the same problem with Unity 6

@rmethaniya
Copy link

rmethaniya commented Jul 17, 2024

Could you please try this? Here's the link: https://github.com/byplay-io/react-native-unity.git

@orjiAce
Copy link

orjiAce commented Aug 7, 2024

hi has anyone been able to fix the above issue?

@orjiAce
Copy link

orjiAce commented Aug 7, 2024

Could you please try this? Here's the link: https://github.com/byplay-io/react-native-unity.git

hi please can you explain more on how to apply this solution?

@orjiAce
Copy link

orjiAce commented Aug 14, 2024

Hi,

Tried to build app for Android, Unity 2023.2.15f1, library version 1.0.10. Got error below:

> Task :azesmway_react-native-unity:compileDebugJavaWithJavac FAILED
/Users/paul/Documents/projects/project/node_modules/@azesmway/react-native-unity/android/src/main/java/com/azesmwayreactnativeunity/UPlayer.java:100: error: incompatible types: UnityPlayer cannot be converted to FrameLayout
            return unityPlayer;
                   ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':azesmway_react-native-unity:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/8.0.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 20s
329 actionable tasks: 4 executed, 325 up-to-date
Error: /Users/paul/Documents/projects/project/android/gradlew exited with non-zero code: 1
Error: /Users/paul/Documents/projects/project/android/gradlew exited with non-zero code: 1
    at ChildProcess.completionListener (/Users/paul/Documents/projects/project/node_modules/@expo/cli/node_modules/@expo/spawn-async/build/spawnAsync.js:52:23)
    at Object.onceWrapper (node:events:629:26)
    at ChildProcess.emit (node:events:514:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
    ...
    at Object.spawnAsync [as default] (/Users/paul/Documents/projects/project/node_modules/@expo/cli/node_modules/@expo/spawn-async/build/spawnAsync.js:17:21)
    at spawnGradleAsync (/Users/paul/Documents/projects/project/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:72:46)
    at Object.assembleAsync (/Users/paul/Documents/projects/project/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:52:18)
    at runAndroidAsync (/Users/paul/Documents/projects/project/node_modules/@expo/cli/build/src/run/android/runAndroidAsync.js:36:24)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

hi did you find a solution? I'm having this same issue

@orjiAce
Copy link

orjiAce commented Aug 24, 2024

I am having the same problem with Unity 6

hi did you find a solution?

@cf-moritzjaeger
Copy link

cf-moritzjaeger commented Aug 26, 2024

Sadly not yet. I progressed with my project in Unity 2022 for now.

@orjiAce
Copy link

orjiAce commented Aug 27, 2024

@azesmway hi guys please help with this, thanks

@alexboyer
Copy link

alexboyer commented Oct 4, 2024

Sadly not yet. I progressed with my project in Unity 2022 for now.

Did this solve the issue for you? We're seeing the same error using 2023.

@douglasndm
Copy link

Sadly not yet. I progressed with my project in Unity 2022 for now.

So is it working for you on Unity 2022?

@cf-moritzjaeger
Copy link

Sadly not yet. I progressed with my project in Unity 2022 for now.

So is it working for you on Unity 2022?

Yes, because the problem is caused by a change made in Unity 2023 (and onwards)

@ramanradzivonau
Copy link

Same problem with Unity 6000.0.23f1
Are there any solutions?

@douglasndm
Copy link

Same problem with Unity 6000.0.23f1 Are there any solutions?

I was only able to work with Unity 2022

@dhruvaura
Copy link

Anyone get solution for above? Unity 2022 working fine.
With Unity 2023 and after version not working due to 'Android: UnityPlayer java class no longer extends FrameLayout' reason ref: https://docs.unity3d.com/cn/2023.2/Manual/UpgradeGuide20231.html

@azesmway I saw you made changes in UPlayer.java. To get new unity 2023 class UnityPlayerForActivityOrService. That is fine. But we are getting this error now...

D:\Dhruv\react\unity2023\react-native-unity-app-main\node_modules\@azesmway\react-native-unity\android\src\main\java\com\azesmwayreactnativeunity\UPlayer.java:100: error: incompatible types: UnityPlayer cannot be converted to FrameLayout
            return unityPlayer;

I think something code implementation need to change in method 'requestFocusPlayer' and 'requestFrame' of UPlayer.java.
Please provide any solution if you have.

Anybody get solution of above please tell here. Thanks.

@dlyrsk
Copy link

dlyrsk commented Nov 30, 2024

Yes, UnityPlayer no longer extends FrameLayout in newer versions, causing this compile error because of incompatible types.


For a quick fix, just modify node_modules (temporary test solution) <project>/node_modules/@azesmway/react-native-unity/android/src/main/java/com/azesmwayreactnativeunity/UPlayer.java:100 to let it return null (return null;).

To fix this issue and make it work for both old and new UnityPlayer class, change com.azesmwayreactnativeunity.UPlayer.requestFrame:

  public FrameLayout requestFrame() {
      try {
          //Attempt to invoke getFrameLayout() for the newer UnityPlayer class
          Method getFrameLayout = unityPlayer.getClass().getMethod("getFrameLayout");
          return (FrameLayout) getFrameLayout.invoke(unityPlayer);
      } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
          // If it is old UnityPlayer, use isInstance() and cast() to bypass incompatible type checks when compiling using newer versions of UnityPlayer
          if (FrameLayout.class.isInstance(unityPlayer)) {
              return FrameLayout.class.cast(unityPlayer);
          } else {
              return null;
          }
      }
  }

@dhruvaura
Copy link

same issue
@gyanani-ritika
I have used above solution which provided by dlyrsk. It worked and solved issue above mentioned.

@gyanani-ritika
Copy link

@dhruvaura but it's not a good fix, whenever well run npm i it will again reset to the older/existing code

@dhruvaura
Copy link

@dhruvaura but it's not a good fix, whenever well run npm i it will again reset to the older/existing code

I think no need to run multiple time npm install after once you successfully integrate unity with react. Because after onwards you have to just replace exported android build and test.

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

No branches or pull requests

10 participants