Reputation: 29
My activity_main.xml has this code :
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity" tools:ignore="MergeRootFrame" />
The line tools:context gives me the error that it cannot resolve the symbol MainAcitvity.
Can anyone help me with this ?
Upvotes: 1
Views: 7008
Reputation: 573
If this problem occurs everytime you create a new project and you don't even get autocomplete suggestions in XML layouts, try changing your compile sdk version
or gradle version
and let the gradle sync again. This solved the issue for me.
Go to Project Structure Settings by pressing Ctrl+Alt+Shift+S
and
To change SDK version
go inside Modules section change your SDK version
To change Gradle version
go inside Project section change your SDK version
Upvotes: 1
Reputation: 3926
Ideally it should work. if not, clean build again. Make sure your MainActivity is there and visible. you can also try to give full name to your activity. you also check your manifest for the package and activity name.
if its really not working, there is something wrong. try to delete this attribute and run it to see you are able to run it.
we need this attribute for layout editor to guess a default theme, since themes are defined in the Manifest and are associated with activities, not layouts.
Upvotes: 0
Reputation: 1861
Give the complete path for
tools:context=".MainActivity"
like
tools:context="com.example.android.sunshine.app.MainActivity"
Upvotes: 2