AndroidStudio : Cannot resolve symbol MainActivity

后端 未结 7 1768
说谎
说谎 2021-01-17 13:07

I got an error \"Cannot resolve symbol MainActivity\" on this code.



        
相关标签:
7条回答
  • 2021-01-17 13:25

    It's possible that your 'src' directory isn't set as a source directory?

    Your IDE seems to be seeing your com.example.fovoapp as a simple directory structure instead of a package. Also looking at your linked image, the little "J" on the java files tells me that also. When a java file is set as source usually it shows up as a Class "C".

    I could be wrong but make sure you set your src directory as source and that should fix the issue.

    0 讨论(0)
  • 2021-01-17 13:32

    Clean Caches

    File -> Invalidate Caches / Restart...
    
    0 讨论(0)
  • 2021-01-17 13:38

    project structure, right click on src folder->Mark directory as-> sources root.

    Now your mainactivity.java file with 'j' symbol to change to 'c' symbol.

    The error was that the project did not have a valid source folder from where it could look for the activity class.

    0 讨论(0)
  • 2021-01-17 13:41

    set your compatible api level. i also same the face error so i set my api level to 23 in file-> project structure-> app-> flavour -> target sdk version

    0 讨论(0)
  • 2021-01-17 13:42

    Maybe you use the wrong path for the src directory.
    It should be in the path : ./yourApp/src/main and not ./yourApp/src/androidTest
    You can move it manually.

    0 讨论(0)
  • 2021-01-17 13:46

    package name on AndroidManifest.xml file and your classes must be same.

    AndroidManifest.xml header:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
       package="com.ahmet.currencies">

    Code:

    package com.ahmet.currencies;
    
    import ...;
    
    
    public class MainActivity extends Activity {}
    
    0 讨论(0)
提交回复
热议问题