前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >android studio 3.0 升级 项目遇到的问题及更改思路(问题小结)

android studio 3.0 升级 项目遇到的问题及更改思路(问题小结)

作者头像
砸漏
发布2020-10-27 10:39:31
7170
发布2020-10-27 10:39:31
举报
文章被收录于专栏:恩蓝脚本

Android Studio从3.0版本新增了许多功能,当然首当其冲就是从3.0版本新增了对 Kotlin 开发语言的支持,除此之外还有其他一些新功能,例如:Android Profiler (其中包含了: CPU Profiler、Memory Profiler、Network Profiler ),APK Debugger,Device File Explorer,Java 8 Language Features等。

android studio 3.0版本升级问题修改:

===》 问题一

代码语言:javascript
复制
Error:Cannot choose between the following configurations of project :pickerview: 
 - debugApiElements 
 - debugRuntimeElements 
 - releaseApiElements 
 - releaseRuntimeElements 
All of them match the consumer attributes: 
 - Configuration 'debugApiElements': 
  - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required. 
  - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. 
  - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. 
  - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required. 
 - Configuration 'debugRuntimeElements': 
  - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required. 
  - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. 
  - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. 
  - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required. 
 - Configuration 'releaseApiElements': 
  - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required. 
  - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. 
  - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. 
  - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required. 
 - Configuration 'releaseRuntimeElements': 
  - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required. 
  - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. 
  - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. 
  - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required. 

===》解决方法:

Warning:android-apt plugin is incompatible with future version of Android Gradle plugin. Please use ‘annotationProcessor’ configuration instead.

原因:更新Android studio 原来项目出现问题。

分析: 尤其是采用butterknife工具的,采用新的Android Studio都会出现这样的问题,本人根据提示最后猜测原因可能是Android studio更新,然后gradle更新了,这样的话可能使原来的android-apt 工具跟不上节奏了,所以让采用annotationProcessor工具。

解决: 把project下的build.gradle 当中的依赖

修改成如下:

代码语言:javascript
复制
buildscript { 
repositories { 
mavenCentral() 
} 
dependencies { 
classpath ‘com.android.tools.build:gradle:2.4.0-alpha7' 
//classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.8' //注释掉
} 
} 

然后再把module下的build.gradle :

修改如下:

代码语言:javascript
复制
dependencies { 
compile project(‘:roadvance-sdk')
compile ‘com.google.dagger:dagger:2.10' 
//apt ‘com.google.dagger:dagger-compiler:2.10'
annotationProcessor ‘com.google.dagger:dagger-compiler:2.10'
compile ‘com.android.support:appcompat-v7:25.3.1'
compile ‘com.jakewharton:butterknife:8.5.1' 
//apt ‘com.jakewharton:butterknife-compiler:8.5.1'
annotationProcessor ‘com.jakewharton:butterknife-compiler:8.5.1' 
}

再把 apply plugin: ‘com.neenbedankt.android-apt ‘ 这个引用给删除。

重新reBuild的一下

===》 问题二

Error:Execution failed for task ‘:wigetlib:javaPreCompileDebug’. Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. – butterknife-7.0.1.jar (com.jakewharton:butterknife:7.0.1) Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future. See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

解决方法:

在app的build中

代码语言:javascript
复制
android {
  ... 
 defaultConfig { 
     ...
    //添加如下配置就OK了
 javaCompileOptions { 
      annotationProcessorOptions {
       includeCompileClasspath = true
      }
     }
     ...
  }
    ...
 }

=====》 问题三

Information:Gradle tasks [:pickerview:generateDebugSources, :pickerview:generateDebugAndroidTestSources, :pickerview:mockableAndroidJar, :zhxflib:generateDebugSources, :zhxflib:generateDebugAndroidTestSources, :zhxflib:mockableAndroidJar, :wigetlib:generateDebugSources, :wigetlib:generateDebugAndroidTestSources, :wigetlib:mockableAndroidJar, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar] D:\zhihuixinfanWorkerSpace\ZhiHuiXinFan\app\build\intermediates\manifests\full\debug\AndroidManifest.xml Error:(12) error: unknown element <uses-library found. Error:(12) unknown element <uses-library 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 ‘:app:processDebugResources’. Failed to execute aapt Information:BUILD FAILED in 8s Information:6 errors Information:0 warnings Information:See complete output in console

解决方法:

在项目的gradle.properties中:

android.enableAapt2=false

修改了以上问题,我的项目可以正常运行了!!!

总结

以上所述是小编给大家介绍的android studio 3.0 升级 项目遇到的问题及更改思路(问题小结),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对ZaLou.Cn网站的支持!

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020-09-11 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档