0

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 ?

HHK
  • 4,852
  • 1
  • 23
  • 40

5 Answers5

3

Your .java files should be in a package in the src folder not in the res/layout folder, res/layout is for .xml layout files and can only have names with lowercase letters and numbers after the first letter.

Evan
  • 287
  • 4
  • 14
1

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 (i.e. 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.

enter image description here

for more see this official document

MilapTank
  • 9,988
  • 7
  • 38
  • 53
0

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

Shabbir Dhangot
  • 8,954
  • 10
  • 58
  • 80
0

Put java file in your Package Folder. i.e. src/.

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

Jeeten Parmar
  • 5,568
  • 15
  • 62
  • 111
0

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

DiLDoST
  • 335
  • 3
  • 12