6

I have updated to Android Studio 3.1 Stable Version today(27 March 2018).

I have an old project. With new studio version, it gets build successful and app gets installed on Emulator, but the on the IDE, Activity file shows

Can Not resolver Error

. enter image description here

gradle file app module

enter image description here

Project level gradle file

enter image description here

Mahi
  • 472
  • 5
  • 7

2 Answers2

8

I spent a long time on this yesterday after migrating from Android Studio 2.3 to 3.1. Tried everything from other answers to similar questions. Google's maven repository was correctly configured, tried invalidating caches and restarting, restarted the computer, etc.

The one thing that worked for me was closing Android Studio, deleting the .idea folder from my root folder and starting Android Studio again. Since I had everything checked into git before starting the upgrade I was able to do:

rm -rf .idea/
git checkout .idea

So I ended up with my original idea project files, but you should be fine if you can't revert to your checked in idea files. After reopening Android Studio it recreated some of the files I ended up deleting and everything worked again. Hope that helps others with the same problem.

This answer is old but basically suggests the same thing so I guess this problem keeps showing up. https://stackoverflow.com/a/21100896/791560

obernal
  • 189
  • 2
  • 4
  • So simple, yet so difficult to find when desperately trying! – Entreco Mar 29 '18 at 21:42
  • Then do i need to delete .idea folder in every project? – Wahdat Jan Mar 30 '18 at 02:35
  • I was having a similar problem (many errors in Android Studio, even though the app compiles and runs on phones just fine) and deleting the project's .idea/ folder fixed it for me. – Max Jun 15 '18 at 21:21
2

I was able to Fix:

https://developer.android.com/studio/build/dependencies.html#google-maven

From Android Studio 3.1, if we are working on Old projects built on 3.0 or lower, you need to add maven repository at top level build.gradle file. i.e., add google() under repositories of all projects.

For new projects, it gets added automatically.

App level, build tools version should be at min 27.0.3

Make sure compilesdk version and support library version are the same version level.

Mahi
  • 472
  • 5
  • 7