Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activity name is not a valid class name

Android Studio 1.5 started prompting error while I try to create a new Activity, check attached image:

enter image description here

like image 730
AVEbrahimi Avatar asked Nov 22 '15 08:11

AVEbrahimi


People also ask

Which are not valid class name?

1. Which one of the following is not a valid class name? Explanation: You declare a class with the class keyword and an arbitrary class name. Class names can be any combination of numbers and letters, although they must not begin with a number.

Which is a valid class name?

It is very easy to choose a valid class name or selectors in CSS just follow the rule. A valid name should start with an underscore (_), a hyphen (-) or a letter (a-z)/(A-Z) which is followed by any numbers, hyphens, underscores, letters.

Which are not valid class name in Java?

1shopproduct is NOT a valid class name (in Java) , because according to Java Class naming rules, class name never starts with a number .

How do I fetch a class name?

The simplest way is to call the getClass() method that returns the class's name or interface represented by an object that is not an array. We can also use getSimpleName() or getCanonicalName() , which returns the simple name (as in source code) and canonical name of the underlying class, respectively.


2 Answers

its because in Project Pane you haven't selected your java package. Select your java package then try to add new activity or fragment. it worked for me :)

Wrong Selection:

enter image description here

Right Selection:

enter image description here

like image 155
Muhammad Hamza Shahid Avatar answered Oct 20 '22 12:10

Muhammad Hamza Shahid


It's a bug in Android studio 1.5 ,just add your package name manually and it will get fixed.

like image 21
ramses1592 Avatar answered Oct 20 '22 12:10

ramses1592