1、今天在用Android Studio开发时遇到类似如下问题:
Error:Execution failed for task ':myapp:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2
这个问题是说项目中存在内容重复,这个时候我们应该去检查一下我们项目的依赖包查看是否有重复的内容,删除重复的依赖包再次build项目就可以了。
2、在Android Studio开发中遇到如下问题:
java.lang.UnsatisfiedLinkError: Couldn't load bmob from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/okhttp.lc.com.okhttptext-2.apk"],nativeLibraryDirectories=[/data/app-lib/okhttp.lc.com.okhttptext-2, /system/lib]]]: findLibrary returned null
造成这个问题的原因是AS无法识别libs下的包,解决方法是在相应位置添加 jniLibs.srcDirs =[‘libs’]这句话,如下代码所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "okhttp.lc.com.okhttptext"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
/**
*添加这部分代码
*/
sourceSets.main{
//让AS识别libs下的.so第三方包
jniLibs.srcDirs =['libs']
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/Bmob_Push_V0.9beta_20160520.jar')
compile files('libs/BmobSDK_V3.4.7_0527.jar')
compile files('libs/filechoose.jar')
compile files('libs/okhttp-3.2.0.jar')
compile files('libs/okio-1.7.0.jar')
compile files('libs/org.apache.http.legacy.jar')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.code.gson:gson:2.2.4'
}
3、关于Can’t start Git:git.exe的问题
某日打开Android Studio 弹出了Can’t start Git:git.exe的提示,这个问题是因为Android Studio找不到git.exe。解决办法:随便下载一个Git安装,将git.exe的路径在Android Studio中配置一下就OK了。
4、Plugin Error问题解决方法
一次我打开Android Studio的时候突然报了这个错,提示如下:
Plugin Error
Problems found loading plugins:
Plugin "Google Analytics Uploader" was not loaded: required plugin "Android Support" is disabled.
Plugin "SDK Updater" was not loaded: required plugin "Android Support" is disabled.
Plugin "Android NDK Support" was not loaded: required plugin "Android Support" is disabled.
Plugin "Google App Indexing" was not loaded: required plugin "Android Support" is disabled.
Plugin "Google Cloud Tools For Android Studio" was not loaded: required plugin "Android Support" is disabled.
Plugin "Google Cloud Testing" was not loaded: required plugin "Android Support" is disabled.
Plugin "Google Services" was not loaded: required plugin "Android Support" is disabled.
一开始我吓尿了。。。以为出现了什么大问题,但是后来搜索资料发现其实就是Android Studio中的Android Support停用了,只要我们再重新启用即可解决问题。
File –> Plugins –>勾选Android Support –>Apply –>ok
重启Android Studio后 搞定!
5 Android Studio解决unspecified on project app resolves to an APK archive which is not supported
解决方发:http://blog.youkuaiyun.com/u012336923/article/details/48049479
出现这个问题可能是因为项目里面有两个 Module,二其中的一个 Module依赖了另一个 Module。
例如 Module A依赖了 Module B的时候出现了这个问题,解决办法是打开 Module B的build.gradle文件
将apply plugin: ‘com.android.application’改成 apply plugin: ‘com.android.library’
重新编译以后Module B就会被当作library来编译,这是会出现另外一个错误 Error:Library projects cannot set applicationId. applicationId is set to ‘package_name’ in default config.
解决办法是将build.gradle — android — defaultConfig中的applicationId删除;