I started a new project. Following this question, I set app/src
as "Sources Root". Then I made a new class CustomClass
under app/src
. I want to construct an instance of this class for the app to access and run, so I tried to do this in MainActivity (in /app/src/main/java/com.example.testapp
):
import CustomClass;
public class MainActivity extends AppCompatActivity {
CustomClass newObject = new CustomClass();
...
}
but the first line gives a "Cannot resolve symbol 'CustomClass' " error.
If I make another class in /app/src
, it can import CustomClass without an issue. It seems like MainActivity doesn't know where to look for the new class. How can I tell it to import the new class?