android studio 升级3.0后,遇到的相关异常(6-7个bug)描述和解决办法!

异常描述1:
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':socialapp:processDebugResources'.
> Failed to execute aapt
Error:(1067) error: unknown element found.
F:\svn\new_quxin\socialapp\build\intermediates\manifests\full\debug\AndroidManifest.xml
Error:(1071) error: unknown element found.
Error:(1067) unknown element found.
Error:(1071) unknown element found.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':socialapp:processDebugResources'.
> Failed to execute aapt

解决办法:
  你AS升级后,新建一个工程,选择Project模式, 这时候会看到有个gradle.properties 文件,把他复制到你报错的项目中.(因为你之前的老的studio建立的项目中是没有这个文件的,你根本在里面找不到!)
里面内容如下:
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
#   http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
#   http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.enableAapt2=false//这句代码一定要加上

然后重新build 即可,该问题得到了解决
接着你程序又会编译异常:
报:
Could not find method releaseTime() for arguments [] on ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type

该错:
解决办法:
/ applicationVariants.all{ variant ->
// variant.outputs.each{ output ->
// def outputFile = output.outputFile
// if (outputFile != null && outputFile.name.endsWith('.apk')) {
// // 输出apk名称为tengniu_v1.0_2015-01-15_pc_tengniu.apk
// if (variant.buildType.name.equals("release")) {
// def fileName = "xxxx.apk"
// output.outputFile = new File(outputFile.parent, fileName)
// } else {
// def fileName = "debug_xxxx.apk"
// output.outputFile = new File(outputFile.parent, fileName)
// }
// }
// }
// }

以前打包输入包名的位置,报错了. 还是编译不通过!
 解决办法:
  把之前的这些注释掉,然后替换为:
android.applicationVariants.all { variant ->

variant.outputs.all {

outputFileName =   "xxx_ ${defaultConfig.versionName} _ ${releaseTime()} .apk"
}

}
参考文档: http://blog.csdn.net/l_lhc/article/details/78458090
备注:xxx是你的应用名.
重新编译一下,该问题得到解决,目前我遇到的就这两个问题
如果还有其他问题:
   1.可能是你的gradle版本不对.
    找到你的新项目的 gradle/ gradle-wrapper.properties 文件.
     把.里面的
distributionUrl = https \: //services.gradle.org/distributions/gradle-4.1-all.zip
复制到你的报错的项目中的gradle/gradle-wrapper.properties
distributionUrl = https \: //services.gradle.org/distributions/gradle-x.x-all.zip.把这个替换掉
2.可能这样弄的再编译,还会报其他错:
如:
位置如下:... gradle\m2repository\com\android\tools\build\gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
这个时候,
找一下你的本地电脑中的gradle版本:
Error:Could not find com.android.tools.build:gradle:2.2.3.
Searched in the following locations:
file:/E:/studio/gradle/m2repository/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
file:/E:/studio/gradle/m2repository/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
https://maven.google.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
https://maven.google.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
Required by:
project :

这个时候.检查一下你项目中的:build.gradle文件
例:E:\studio\gradle\m2repository\com\android\tools\build\gradle ,里面有几个自己的版本,更换为你自己本地对应的版本即可
最后,如果你的程序还 报错,你就自己检查一下!,或者百度下
可能你编译通过后,运行到你的虚拟机的时候,你的程序还会报下面这个错误(弹框类型)!

Installation failed with message INSTALL_FAILED_CANCELLED_BY_USER.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
 这个错误的原因,是因为 studio不支持,需要你换arm架构的手机或者虚拟机!,换个真机运行一下,就不会报这个错!

再次运行,如果报
Installation failed with message Failed to finalize session : INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?

该问题解决办法:
选择studio最上面的导航栏,先clear Project,然后再次rebuild project,再次运行即可!

你可能感兴趣的:(安卓Bug)