升级到最新的Android Studio 3.0 PreView后,会提示我们升级Gradle版本,然后就挂掉了。IDE报如下错误:
Error:(1, 0) The android gradle plugin version 3.0.0-alpha1 is too old, please update to the latest version.
To override this check from the command line please set the ANDROID_DAILY_OVERRIDE environment variable to "8d256f619ba96afd1273947e8b8bebea4cb2fd05"
[Upgrade plugin to version 2.3.2 and sync project]
百度大部分答案都是手动修改gradle文件至可用版本,但是我们之前编译明明是通过的,为什么会出现这种情况呢?笔者最后在stackOverFlow上找到了答案:https://stackoverflow.com/questions/44301207/android-plugin-is-too-old-2-4-0-alpha7/44302290#44302290
There is a 40 day limit for beta/alpha versions and after that, Android Studio forces you to update to the latest version.
But it doesn't exist (the newest is the alpha with AS 3.0) so a possible solution is setting that environment variable, executing in the command line (in MAC):
launchctl setenv ANDROID_DAILY_OVERRIDE 8d256f619ba96afd1273947e8b8bebea4cb2fd05
And relaunch Android Studio
原来beta/alpha版本有40天限制,在此之后Android Studio就会强制我们升级新版本。但是这个所谓的新版本在引用库中并不存在(最新版是配合Android Studio 3.0使用的alpha版),解决方法是更新一下环境变量ANDROID_DAILY_OVERRIDE,设置为Android Studio中提示的值。
在MAC中我们可以在terminal中输入如下命令:
launchctl setenv ANDROID_DAILY_OVERRIDE xxx(Android Studio报错信息中提示的值)
Windows修改环境变量原理是一样的,在此就不再赘述。
PS:更新完成后记得重启Android Studio