Android Studio 常见问题汇总

1.Error:com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)

解决方法:在build中加入

 
  
implementation "com.google.guava:guava:23.0-android"

2.  com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex 
解决方法:原因是方法数超出限制导致的 在app的build.gradle文件中添加:
defaultConfig{
    multiDexEnabled true
}

3. Could not find method google() for arguments [] on repository container.   gradle升级到最新版本可解决。

4.app:externalNativeBuildCleanDebug 因版本不支持cmake 删除

Android Studio 常见问题汇总_第1张图片


5.eclipse 转 android studio Could not resolve all files for configuration ':classpath'.

在build.gradle中 添加

google() 如:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

6.Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

下载过程中断连导致gradle出错,需要到对应目录删除重新下载。


7.Android Studio Error—Gradle: 错误:编码 GBK 的不可映射字符的

解决办法:

在项目下的build.gradle下添加以下代码即可解决

tasks.withType(Compile) {  
    options.encoding = "UTF-8"  
}  

8.Android dependency has different version for the compile and runtime

因为同一个build依赖两个不同版本的jar包导致,查询一下各个依赖的版本和api 、implementation的区别。

9.无法下载相关jar 出现 Could not resolve XXX

比如:Could not resolve com.android.tools.lint:lint-gradle:26.1.2.

是由于Gradle 下载的时候网络不好,下载了损坏的Gradle包 可以到官方下载替换:

Gradle官方下载

10.编译上传AAR包到Nexus导致的问题:Could not write to file 'D:\androidDemo\CommonLib\commonlib\build\poms\pom-default.xml'

因为build.gradle添加了  multiDexEnabled true造成包冲突的问题,正式版AAr包应该去掉


11、Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.

Android Studio 3.0 和Gradle 3.0已经遗弃compile的方式依赖,检查并修改为implementation或者api

12.Execution failed for task ':domain:transformClassesWithMultidexlistForDebug'.

> com.android.build.api.transform.TransformException: Error while generating the main dex list.

多Module的情况 请查询是否Multidex了,如果Multidex查询是否多个Apopplication执行了Multidex.install(this).

你可能感兴趣的:(android开发)