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 our Cocos support some of the Unity Android/IOS builds? #17810

Open
17628673421 opened this issue Nov 5, 2024 · 11 comments
Open

Can our Cocos support some of the Unity Android/IOS builds? #17810

17628673421 opened this issue Nov 5, 2024 · 11 comments
Labels
Feature Request Needs Triage Needs to be assigned by the team

Comments

@17628673421
Copy link

17628673421 commented Nov 5, 2024

Use Case

When using Unity I can put some Android developed features wrapped into an aar package under Assets/Plugins/Android. It is also possible to pre-modify the contents of mainTemplate.gradle, settingsTemplate.gradle, AndroidManifest.xml.

Problem Description

Cocos doesn't have that right now.

Proposed Solution

  1. Similar to the function under Unity Assets/Plugins, for example, I can encapsulate the Android developed function into an aar package and put it into Assets/Plugins/Android. You can pre-modify the contents of mainTemplate.gradle, settingsTemplate.gradle, AndroidManifest.xml.

  2. StreamingAssets folder function, will build the platform needs to be placed in the assets of the resources directly into this.

3.Calling Android native API through AndroidJavaObject and AndroidJavaClass classes provided by Unity. this way allows you to call Android Java code in C# scripts without writing JNI interfaces.
This is the current gap I see between doing native packages and using Unity.

Putting in the next big release support can all be genuinely desirable with this kind of alignment feature.

How it works

No response

Alternatives Considered

Just implement something similar

Additional Information

No response

@17628673421 17628673421 added Feature Request Needs Triage Needs to be assigned by the team labels Nov 5, 2024
@longchuan
Copy link
Contributor

Not our cocos,It is cocos.Not some of,should be the same of.
this is the doc:
https://docs.cocos.com/creator/3.8/manual/zh/editor/publish/custom-project-build-template.html

@17628673421
Copy link
Author

How can I call Android code in the game script like Unity does? Call the native API directly instead of via a bridge.

@17628673421
Copy link
Author

And StreamingAssets are directly accessible in scripts and support building multiple platforms

@longchuan
Copy link
Contributor

How can I call Android code in the game script like Unity does? Call the native API directly instead of via a bridge.

https://docs.cocos.com/creator/3.8/manual/zh/advanced-topics/native-secondary-development.html

@longchuan
Copy link
Contributor

And StreamingAssets are directly accessible in scripts and support building multiple platforms

https://docs.cocos.com/creator/3.8/manual/zh/asset/bundle.html

@17628673421
Copy link
Author

Am I not clear? I don't even know what to say. @minggo Please have a look.

I've been using cocos for 4 years, and what I want to talk about is adding direct calls to native apis instead of bridging implementations. For example, the following C# code

` AndroidJavaClass unityPlayer_ = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity_ = unityPlayer_.GetStatic("currentActivity");

    AndroidJavaObject builder = new AndroidJavaClass("com.android.xxx.api.xxxx")
        .CallStatic<AndroidJavaObject>("newBuilder", currentActivity);

    installReferrerClient = builder.Call<AndroidJavaObject>("build");`

@longchuan
Copy link
Contributor

That was bridge

@17628673421
Copy link
Author

What about the nativescript approach
`
import { Application, Utils } from "@nativescript/core";
declare const com: any;

this.client = com.xx.sdk.xx;
const config = new com.xx.sdk.xxx(
Utils.android.getApplicationContext(),
xxx,
com.xxx.sdk.xxx.xxx
);
`

@17628673421
Copy link
Author

It is indeed a kind of bridge, but it can be implemented in the form of calling the native API directly from within the script

@longchuan
Copy link
Contributor

It is indeed a kind of bridge, but it can be implemented in the form of calling the native API directly from within the script

cocos' native is JNI. It is a framework what android supported.C# is not C++,so unity add a custom bridge.

@longchuan
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Needs Triage Needs to be assigned by the team
Projects
None yet
Development

No branches or pull requests

2 participants