简体   繁体   中英

aapt: res/layout/MainActivity.java Invalid file name

I use AIDE to compile android applications from inside Android. Usually, I copy the MainActivity.java to the computer, I edit it and then I copy it again to the mobile phone. Then, I run AIDE to compile the project. At this moment, I have this error :

aapt: res/layout/MainActivity.java Invalid file name:must contain only [a-z0-9_.]

I don't know what is happening. The name is correct MainActivity.java.

Any idea ?

您的 .java 文件应该在 src 文件夹中的包中,而不是在 res/layout 文件夹中,res/layout 用于 .xml 布局文件,并且名称只能包含小写字母和第一个字母后的数字。

src Source Code this is where the Java source code is placed. The Java files are organised into packages that directly map to the folder structure (ie the package apc.examples impels a folder structure examples)

gen Android tools generate code to map resources into the Java code. This generated code is placed in this folder.

Android 2.2 The Android framework library is stored here.

assets Project specific assets are placed here. Developers often store application data files that do not need to change here.

res This is the location to store resources used in the application. Specifically images layouts and strings.

在此处输入图片说明

for more see this official document

You need to Store Java file inside in the package of your project not in the res folder.

res Folder contains only resources of project. Move your file to package folder.

See this Links will give you more idea.

http://developer.android.com/guide/topics/resources/providing-resources.html

http://developer.android.com/tools/projects/index.html

Put java file in your Package Folder. ie src/.

res/layout is for xml file which is design part of your android app.

Or Just Rename it. From:

MainActivity.java

Into:

mainactivity.xml

But it should be a xml placed in layouts folder else move it into the src/java folder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM