Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 3.1 Stable. Build Successful but Can Not Resolve Error

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

like image 327
Mahi Avatar asked Mar 27 '18 16:03

Mahi


2 Answers

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

like image 94
obernal Avatar answered Sep 27 '22 20:09

obernal


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.

like image 28
Mahi Avatar answered Sep 27 '22 20:09

Mahi