Error : Ambiguous method call. Both findViewById (int) in AppCompactActivity and Activity

后端 未结 17 2194
我寻月下人不归
我寻月下人不归 2021-02-05 00:29

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

相关标签:
17条回答
  • 2021-02-05 00:44

    For me changing build tool version to 27.0.2 worked, given that all your other dependencies are API 27 as well.

    buildToolsVersion '27.0.2'
    
    0 讨论(0)
  • 2021-02-05 00:47

    For me, it was the compileSdkVersion which was different than the support libraries used

    0 讨论(0)
  • 2021-02-05 00:47

    I ran into the same issue with Android Studio 3.0.0 build 171.4408382. Building via Gradle on the command line worked just fine, but the IDE presented me with the above mentioned error. I have tried to use API level 26 with appcompat v26.1.0 and API level 27 with appcompat v27.0.1, but neither combination worked.

    My "solution" was to downgrade compileSdkVersion and targetSdkVersion to API level 25 and the appcompat library to version 25.4.0.

    For all of the mentioned version combinations I used Gradle plugin v3.0.0 and the Android build tool v27.0.1.

    0 讨论(0)
  • 2021-02-05 00:51

    For me none of the given solutions worked, however I had this issue because I had both 25 and 27 android sdk installed on my computer. As soon as I removed the sdk 25, the problem disappeared.

    0 讨论(0)
  • 2021-02-05 00:52

    Upgrading your targetSdkVersion or buildToolsVersion might resolve the problem.

    0 讨论(0)
  • 2021-02-05 00:54

    Maybe you have difference between compileSdkVersion and targetSdkVersion

    0 讨论(0)
提交回复
热议问题