欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

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

程序员文章站 2023-12-09 19:45:33
android studio从3.0版本新增了许多功能,当然首当其冲就是从3.0版本新增了对 kotlin 开发语言的支持,除此之外还有其他一些新功能,例如:android...

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 升级 项目遇到的问题及更改思路(问题小结)

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

===》 问题一

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 当中的依赖

修改成如下:

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 :

修改如下:

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 for more details. 

解决方法:

在app的build中

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 升级 项目遇到的问题及更改思路(问题小结),希望对大家有所帮助