解决Android Studio中Gradle版本不对应无法调试app的问题

遇到的问题

Windows操作系统下,在导入一个Android工程到Android Studio中时,调试时Gradle拨错,错误提示如下:

--------------------------------------------------------------------------------------------

FAILURE: Build failed with an exception.



* Where:
Build file 'F:\AndroidStudioProjects\BundleTest\app\build.gradle' line: 1


* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
   > Gradle version 2.10 is required. Current version is 2.2.1. If using the gradle wrapper, try editing the distributionUrl in F:\AndroidStudioProjects\BundleTest\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip


* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

--------------------------------------------------------------------------------------------

错误原因:显然当前的Gradle版本为2.2.1,而要求的版本是2.10,于是版本不兼容导致报错


解决办法:使用Gradle Wrapper

第一步:

保证分布的URL gradle-2.10-all.zip位于该Android 工程的gradle wrapper文件目录下,就像下面这样

MyAndroidProject/gradle/wrapper/gradle-wrapper.properties


第二步:


  1.  如果是Unix-like操作系统,则在命令行中运行:

    ./gradlew wrapper

    如果是Windows操作系统,则在命令行中运行:

    gradlew.bat wrapper

  2. 运行Gradle Wrapper相关的命令

    如果是Unix-like操作系统:

    ./gradlew build

    如果是Windows操作系统:

    gradlew.bat build



你可能感兴趣的:(Java,Android,Android,android,studio,Java,android开发)