Android studio 编译工程报错,做个简单的记录
1、Cause: com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V
studio导入https://github.com/manuelvicnt/RxJava2-MVVM-Android-Structure工程时报错。错误内容如下:
Parallel execution is an incubating feature.
Download https://jcenter.bintray.com/me/tatarka/gradle-retrolambda/3.3.1/gradle-retrolambda-3.3.1.pom
Download https://jcenter.bintray.com/me/tatarka/gradle-retrolambda/3.3.1/gradle-retrolambda-3.3.1.jar
Download https://jcenter.bintray.com/io/reactivex/rxjava2/rxandroid/2.0.0/rxandroid-2.0.0.pom
Download https://jcenter.bintray.com/io/reactivex/rxjava/1.1.5/rxjava-1.1.5.pom
Download https://jcenter.bintray.com/io/reactivex/rxjava/1.1.5/rxjava-1.1.5.jar
Download https://jcenter.bintray.com/io/reactivex/rxjava2/rxjava/2.0.0/rxjava-2.0.0.jar
Download https://jcenter.bintray.com/io/reactivex/rxjava2/rxandroid/2.0.0/rxandroid-2.0.0.aar
The CompileOptions.bootClasspath property has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the CompileOptions.bootstrapClasspath property instead.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
CONFIGURE FAILED in 30s
Cause: com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V
解决办法:
1)和本地的gradle版本有关。修改 project的 build.gradle文件,将
classpath 'com.android.tools.build:gradle:2.2.2' 改为
classpath 'com.android.tools.build:gradle:2.2.3'
还有gradle/wrapper/gradle-wrapper.properties文件的distributionUrl属性,这里改为
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
2、AAPT: No resource identifier found for attribute 'appComponentFactory' in package 'android'
错误分析:
查看了一下studio的报错,已经提示的很明显。
com.android.support:appcompat-v7:27.1.1,中有引用库版本升级到了28.0.0
使用插件 Gradle View 二次查看确认,如下:
解决办法:
方法1:目前想到的方式是直接强行控制住这两个库的版本,定死到27.1.1
在工程的 build.gradle 文件中加入
configurations.all {
resolutionStrategy.force "com.android.support:support-annotations:27.1.1"
resolutionStrategy.force "com.android.support:support-compat:27.1.1"
}
注:感觉应该还有更好的办法。因为还创建了27.1.1版本的测试工程做对比,测试工程中同样使用了
implementation 'com.android.support:appcompat-v7:27.1.1' (是在同一台PC上,保证了环境相同)测试工程里面这两个应用库的版本没有自动升级到28.0.0,所以猜测应该是工作工程的哪里配置有问题导致了这个原因
3、kotlin-android-extensions 插件无效问题
4、Unable to determine application id: com.android.tools.idea.run.ApkProvisionException: The currently selected variant "debug" uses split APKs,
but none of the 1 split apks are compatible with the current device with density "-1" and ABIs "".
问题原因:。。。(没能找出真正原因,暂时放这里做个记录)
解决办法:关掉IDE重启!!!
5、studio真机调试时:Device supports,but APK only supports armeabi rmeabi-v7a
adb的问题
解决方法:
adb kill-server
adb start-server
刷新一下studio