Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject

http://blog.csdn.net/ithouse/article/details/71248820http://blog.csdn.net/ithouse/article/details/71248820

 

出现这个错误一般是在高版本的AndroidStudio里导入旧版本的gradle项目,需要:
1. 打开build.gradle(Project :)文件,修改classpath为(如果不知道应该修改为多少,请新建一个项目,参考新建项目里的classpath):

classpath 'com.android.tools.build:gradle:2.3.1'

 

打开gradle/wrapper/gradle-wrapper.properties文件,修改distributionUrl为
distributionUrl=http://services.gradle.org/distributions/gradle-3.3-all.zip

 

或本地相关distribution,然后重试。遇到下载很慢的情况,请手动下载相关distribution,复制到如下目录即可。

C:\Users\Jason\.gradle\wrapper\dists\gradle-3.3-all\对应文件夹\

如遇到类似如下错误:

Error:Execution failed for task ':transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
File1: C:\AppsBackup\libs\jackson-annotations-2.4.0.jar
File2: C:\AppsBackup\libs\jackson-core-2.4.0.jar
File3: C:\AppsBackup\libs\jackson-databind-2.4.0.jar

则在gradle文件的Android节点下添加如下信息:

packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}

posted @ 2017-08-18 16:59  petercao  阅读(1415)  评论(0编辑  收藏  举报