I am getting the error: \"Ambiguous method call\" on initializing Toolbar using Android Studio 3.0 RC1. I have extended my Activity with AppCompatActivity and compiling my appli
You have
import android.support.v7.app.AppCompatActivity
import android.app.Activity
both in your code.
Remove import android.app.Activity
as I can see, it's not required for you.
First make sure that you have no transitive dependencies that are using older support libraries. Run the following command and make sure that no older support libraries are in use.
gradlew :app:dependencies
Make sure that your gradle file is updated with latest dependencies. eg: compileSdkVersion 27, targetSdkVersion 27, buildToolsVersion 27.0.3. etc. It would also benefit to make sure that non of your app flavors have been using a custom targetSdkVersion.
Ctrl + click on the findViewById method. It will show you the 2(perhaps more?) conflicting methods. In my case the conflict was between the findViewById method from API 23 and API 27. Therefore I had to remove the SDK and sources for Android version 23. Once I removed it and did Invalidate Caches/Restart it solved my problem.
My compileSDK version was lower than the targetSDK version so all I had to do was match them and sync project and the error was resolved.
If you recently updated your project to API, Try doing
File -> Invalidate Caches / Restart
then
File -> Sync Project with Gradle Files
this resolve for me.
Upgrade to appcompat 27 solved this for me
"File - Invalidate Caches / Restart" Solved my problem.