AndroidStudio: Cannot resolve MainActivity character

I have the error "Cannot resolve MainActivity character" in this code.

<activity android:name=".MainActivity" //here android:label="@string/app_name" android:launchMode="singleTask" > <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="MainActivity" android:scheme="callback" /> </intent-filter> </activity> 

Needless to say, MainActivity inherits activity and the package name is also correct.

Why?

thanks

Here is an image of the directory structure.

Snapshot of the directory structure

+10
java android android-studio manifest
source share
7 answers

Is it possible that your src directory is not set as the source directory?

Your IDE seems to see your com.example.fovoapp as a simple directory structure instead of a package. Also, looking at your linked image, the little "J" in the java files tells me that. When a java file is installed as a source, it is usually displayed as a class "C".

I may be wrong, but make sure you set the src directory as the source, and this should fix the problem.

+19
source share

in the AndroidManifest.xml file and your classes should be the same.

AndroidManifest.xml header:

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

the code:

 package com.ahmet.currencies; import ...; public class MainActivity extends Activity {} 
+11
source share

Perhaps you are using the wrong path for the src directory.
It should be on the way: ./yourApp/src/main , not ./yourApp/src/androidTest
You can move it manually.

+2
source share

right-click the src folder-> Mark the directory as-> root source.

Now your mainactivity.java file with the character 'j' to go to the character 'c'.

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

+1
source share

In the build.gradle file , add the following.

 android { sourceSets { main.java.srcDirs += 'src/<YOUR DIRECTORY NAME>' } ... ... } 
0
source share

set a compatible API level. I also have the same error on my face, so I set my API level to 23 in file-> project structure-> app-> flavor β†’ target sdk version

0
source share

Net Caches

File β†’ Invalidate Caches / Restart ...

0
source share

All Articles