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

在将Android Studio升级到3.0后,遇到了AAPT2错误,表现为Execution failed for task ':app:processDebugResources'等。解决方法包括在gradle.properties中添加android.enableAapt2=false,更新gradle版本,以及修改applicationVariants的outputFileName。此外,针对INSTALL_FAILED_NO_MATCHING_ABIS错误,可通过清除项目并重新构建来解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

异常描述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 <permission> found.
F:\svn\new_quxin\socialapp\build\intermediates\manifests\full\debug\AndroidManifest.xml
Error:(1071) error: unknown element <uses-permission> found.
Error:(1067) unknown element <permission> found.
Error:(1071) unknown element <uses-permission> 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

# 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
# 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"
}

}
备注:xxx是你的应用名.
重新编译一下,该问题得到解决,目前我遇到的就这两个问题
如果还有其他问题:
   1.可能是你的gradle版本不对.
    找到你的新项目的 gradle/ gradle-wrapper.properties 文件.
     把.里面的
复制到你的报错的项目中的gradle/gradle-wrapper.properties
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
Required by:
project :
<a href="openFile:F:\svn\new_quxin\build.gradle">Open File</a>

这个时候.检查一下你项目中的: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,再次运行即可!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值