1:错误 Failure [INSTALL_FAILED_OLDER_SDK]
打开android工程导航列表如下图
找到build.gradle 修改minsdkversion和targetSdkVersion的值 改成你手机或者模拟器的版本对应的api等级
2:Error:duplicate files during packaging of APK ........
Path in archive: META-INF/LICENSE.txt
...................
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK META-INF/LICENSE.txt
File 1: /Users/Lin1/AndroidStudioProject/app/libs/jaxen-1.1-beta-6.jar.jar
File 2: /Users/Lin1/AndroidStudioProject/app/libs/dom4j-1.6.1.jar
解决办法是在build.gradle中插入
packagingOptions {
exclude 'META-INF/LICENSE.txt' }
3:Android Studio-Gradle项目中添加JNI生成文件(.so文件)
解决方案http://www.tuicool.com/articles/yuAjAz
其实弄了大半天无非就是把.SO文件打包到APK的lib文件夹中,假如仔细阅读了Gradle的使用方法,自然就知道其实Gradle官方在新版已经自动实现了打包.SO文件的.很简单级就是在配置的android节点下build.gradle加入下面的内容就ok:
sourceSets { main { jniLibs.srcDirs = ['libs'] } }其他地方无需修改,整个项目的配置文件如下:
apply plugin: 'android' android { compileSdkVersion 19 buildToolsVersion "19.0.0" defaultConfig { minSdkVersion 16 targetSdkVersion 19 versionCode 1 versionName "1.0" } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } sourceSets { main { jniLibs.srcDirs = ['libs'] } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) }这不就是很简单么,无需手动打包,也无需很复杂的打包拷贝命令,简单的操作就ok。可以说多看看官方文档是多么的重要。
4:How to import android project as library and NOT compile it as apk (Android studio 1.0)
解决方案http://stackoverflow.com/questions/27536491/how-to-import-android-project-as-library-and-not-compile-it-as-apk-android-stud
当然也有可能是你引入的android 工程不是libray工程
将你想要引入的工程改成library 将想要引入的工程的build.gradle
apply plugin: 'com.android.application'
改成
apply plugin: 'com.android.library'
5:Suggestion: use tools:overrideLibrary="XXXX" to force usage
...............
> Manifest merger failed with multiple errors, see logs
AndroidManifest.xml添加
<uses-sdk tools:overrideLibrary="XXXX"/>