MainApplication.java 在 React Native (Expo) 中该如何找到?

huangapple go评论59阅读模式
英文:

Where do I find MainApplication.java in React Native (Expo)?

问题

我正在尝试找到MainApplication.java文件,以便进行编辑。我正在使用Expo Go。
我一直无法找到它。我还在Sublime Text中使用了查找功能。
什么都没找到。

MainApplication.java 在 React Native (Expo) 中该如何找到?

MainApplication.java 在 React Native (Expo) 中该如何找到?

MainApplication.java 在 React Native (Expo) 中该如何找到?

我应该在哪里找到它?

英文:

I'm trying to find the MainApplication.java file, so I can edit it. I'm using Expo Go.
I've been unable to find it. I've also used finder in Sublime Text comes with.
Nothing was found.

MainApplication.java 在 React Native (Expo) 中该如何找到?

MainApplication.java 在 React Native (Expo) 中该如何找到?

MainApplication.java 在 React Native (Expo) 中该如何找到?

Where am I supposed to find it?

答案1

得分: 0

我不确定使用Expo是否可行,因为目标是在项目之外开发本机代码模块。

我建议您直接使用React Native。请参考:

设置开发环境

这样您将拥有更多关于本机代码源和配置更改的灵活性。

英文:

I am not sure it is doable with Expo as the aim is to develop a native code module outside the project.

I would recommend you to use React Native directly. See:

Setting up the development environment

You will have much more flexibility regarding native code source and if you need to change the configuration.

答案2

得分: 0

我在CLI上,但可能在这里:

android/app/src/main/java/com/{项目名称}/someFolder/MainApplication.javaandroid/app/src/main/java/co/{项目名称}/someFolder/MainApplication.java

示例路径:
android/app/src/main/java/co/matt/rtp/MyAppPackage.java

英文:

I'm on CLI but probably here:

android/app/src/main/java/com/{nameOfProject}/someFolder/MainApplication.java or android/app/src/main/java/co/{nameOfProject}/someFolder/MainApplication.java

Example path:
android/app/src/main/java/co/matt/rtp/MyAppPackage.java

答案3

得分: 0

如果你正在使用Expo,这意味着你正在使用托管工作流。你不会找到MainApplication.java,因为Expo已经处理了它。你可以执行eject命令,这会将项目从托管工作流转换为原生工作流。

请参考Expo文档中的以下引用:

使用Expo工具构建应用程序有两种方法,分别是托管工作流和原生工作流。

在托管工作流中,你只需编写JavaScript/TypeScript代码,Expo工具和服务会为你处理其他一切。而在原生工作流中,你可以使用任何Expo库和服务,但需要自己负责处理原生iOS和Android项目。

Expo文档链接

英文:

If you're using Expo that's mean you using managed workflow.
You will not find MainApplication.java because expo took care of it.
You can do eject, it was changing the project from managed workflow to bare

Please check below references from expo

> The two approaches to building applications with Expo tools are called
> the managed and bare workflows.
>
> With the managed workflow you only write JavaScript/TypeScript and
> Expo tools and services take care of everything else for you. In the
> bare workflow you can use any Expo library and service, and you are
> responsible for the native iOS and Android projects.

https://docs.expo.dev/archive/managed-vs-bare/

答案4

得分: -2

在使用Expo创建的React Native项目中,没有直接相当于在典型的原生React Native项目中找到的MainApplication.java文件。Expo将原生代码配置(包括MainApplication.java文件)抽象出来,以提供简化的开发体验。

Expo为您管理原生代码配置,使您主要专注于JavaScript代码,并利用Expo预配置的开发环境。这种抽象使得在不涉及原生代码设置和维护的情况下更容易开发和部署React Native应用程序。

但是,如果您有特定的原生代码要求或需要定制Expo项目的某些方面,您可以将项目“eject”(退出)以创建原生的React Native项目。退出后,您将可以访问原生代码文件,包括MainApplication.java文件。
请记住,从Expo中退出是一次性操作,建议仅在必要时执行,因为它会增加项目设置和维护的复杂性。

要退出Expo项目并获得对原生代码文件的访问权限,您可以在项目的根目录中运行以下命令:
expo eject
此命令将引导您完成退出项目并生成必要的原生代码文件的过程。退出后,您可以在Android项目结构的适当位置找到MainApplication.java文件,通常位于android/app/src/main/java/com/your-app-package/目录下。

请谨慎考虑从Expo中退出的影响,因为这可能需要您进行额外的配置和维护,包括管理依赖关系、集成第三方库以及处理Expo的未来更新。

英文:

In React Native projects created with Expo, there is no direct equivalent of the MainApplication.java file that you would typically find in a bare React Native project. Expo abstracts away the native code configuration, including the MainApplication.java file, to provide a streamlined development experience.

Expo manages the native code configuration for you, allowing you to focus primarily on the JavaScript code and leveraging Expo's pre-configured development environment. This abstraction makes it easier to develop and deploy React Native apps without dealing with native code setup and maintenance.

However, if you have specific native code requirements or need to customize certain aspects of your Expo project, you can "eject" your project from Expo to create a bare React Native project. After ejecting, you will have access to the native code files, including the MainApplication.java file.
Keep in mind that ejecting from Expo is a one-way operation, and it's recommended to do it only if necessary, as it adds complexity to the project setup and maintenance.

To eject an Expo project and obtain access to native code files, you can run the following command in your project's root directory:
expo eject
This command will guide you through the process of ejecting your project and generating the necessary native code files. Once ejected, you can find the MainApplication.java file in the appropriate location within the Android project structure, typically under the android/app/src/main/java/com/your-app-package/ directory.

Remember to carefully consider the implications of ejecting from Expo, as it may require additional configuration and maintenance on your part, including managing dependencies, integrating third-party libraries, and handling future updates to Expo.

huangapple
  • 本文由 发表于 2023年5月18日 05:34:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76276352.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定