Android Studio升级之后遇到的一系列问题

升级AS,我个人还是有点担忧的。因为as的配置真的让人觉得脑阔痛。

下面就是我遇到一系列搜了很久才解决的问题:

1.报错:Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation'

项目中的引用标签进行替换。按照下面依次替换

compile =>implementation
androidTestCompile =>androidTestImplementation
testCompile => testImplementation

2.报错:Unable to resolve dependency for ':app@debug/compileClasspath':Could not resolve com.android.support:appcompat-v4:25.0.0

项目中的V4包冲突,在自己的那个项目目录下的build.gradle里添加如下代码

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.0.0'//填写自己的目标v4版本
            }
        }
    }
}

和2同类型报错还有:Android dependency 'com.android.support:support-support-v4' has different version for the compile (23.0.0) and runtime (25.0.0) classpath.

意思是差不多的。

3.初入项目,各种build不成功,删了重新build也不成功。然后在自己项目下的build.gradle中添加

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

这个也是问一个朋友,给这样处理的。我还没弄明白,但是还挺有效果的。

4.askExecutionException: Execution failed for task ':app:transformJackWithJackForDebug'

这篇博客很全面:https://blog.csdn.net/wjj1996825/article/details/79838430

5.Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\Android\sdk\build-tools\23.0.3\aapt.exe'' finished with non-zero exit value 1

一旦出现"xxxx finished with non-zero exit value 1",基本都是说什么文件或者依赖重复了,还有gradle的配置出错。

这篇博客:https://blog.csdn.net/qq_32452623/article/details/52278904

6.AndroidStudio引包失败

这篇博客:https://blog.csdn.net/mr_chenxu/article/details/77987404

7.org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':mApp:processDebugResources'.

这个问题需要自己在自己的Android Studio里面的Terminal去寻找答案,(我都是看了很多博客之后才知道还有这个操作,这个真的太好用。废话不多说。)

来一个链接博客,来寻找出现这个问题的原因。

这篇博客:https://blog.csdn.net/wjj1996825/article/details/79838430

良心Tips:如果你升级了as,那就千万不要再打开老as了,最好是卸载老版的Android Studio!否则会把你玩儿死。

后面持续更新....

猜你喜欢

转载自blog.csdn.net/sweet_smile5/article/details/82883449