如何在Android Studio中创建类文件 [英] How to create class files in Android Studio

查看:1248
本文介绍了如何在Android Studio中创建类文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我需要在Android Studio中创建类文件,以便我可以使用URLClassLoader。我需要这样做,以便我可以通过套接字传递自定义对象,我不断得到一个ClassNotFoundException。我知道解决这个问题的传统方法是将对象的类添加到类路径中,但我无法弄明白 - 我在网上阅读的内容似乎已经过时,或者用于不同的设置。

So I'm needing to create class files in Android Studio so I can use URLClassLoader. I need to do this so that I can pass custom objects through a socket, I keep getting a ClassNotFoundException. I know the conventional way to go about this is to add the object's class to the classpath, but I couldn't figure that out - things I read online seemed to either be outdated, or for a different setup.

但我看不到如何创建类文件。当我构建IntelliJ对象时,会创建类文件。但不是在AndroidStudio中。为什么?

I can't see how to create class files, though. When I build an IntelliJ object, the class files get created. But not in AndroidStudio. Why?

推荐答案

可以通过右键单击Java文件夹然后新建> Java类来创建Java类

Java classes can be created by right-clicking on a Java folder then New > Java Class

通过右键单击另一个文件夹并选择新建>文件夹> Java文件夹

A Java folder can be created by right-clicking another folder and selecting New > Folder > Java Folder

通过转到模块的文件夹找到编译的Java类文件,然后转到构建>中间件>类> debug> company.name> com> app.name

The compiled Java class file will be found by going to the module's folder then build > intermediates > classes > debug > company.name > com > app.name

这篇关于如何在Android Studio中创建类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆