Android Stuido 编译时遇到的问题
这个错误信息的原因是从NDK r17
版本开始,已经不支持"armeabi、mips、mips64"
这三种ABI
格式了,而当前机器上安装的NDK
版本是NDK r17
之后的版本。
不过这个提示很能迷惑人,会让人误以为自己的build.gradle
中配置了MIPS
的ABI
。实际上根本没有配置,是低版本的构建工具自己在默认构建MIPS
格式,而又找不到对应的工具链。
解决方法很简单,要么使用低于NDK r17
的NDK
版本,要么修改主工程的build.gradle
,找到如下
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
将上面的 classpath 'com.android.tools.build:gradle:3.0.1' 改为 classpath 'com.android.tools.build:gradle:3.2.1' 重新执行 Buid/Rebuild Project 又出现了如下的问题
File ->Settings
如上所示 将 Use local gradle distribution 下的 Gradle home: 选中本地已经下载解压完的 gradble-4.6 文件目录,再次编译后,会出现如下的问题
处理方法:
把AndroidManifest.xml 里的sdk最小版本设置都删掉 Androidstudio3.0 以后 不能在manifest.xml 设置这些 必须在 gradle里设置, 如下图所示 将
android:minSdkVersion="18" 一行删除, 再次重新编译.
此时出现如下的错误信息:
Error:FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
* 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
BUILD FAILED in 3s
参照上面的提示, 修改app/build.gradle 文件, 此文件内容如下, 将文件中的26 改为 27 ,如下所示的红色加粗字体.
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.zmg.zmg_jdqc"
minSdkVersion 18
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
再次编译 这次编译成功了.