第一主要步骤
修改项目的 com.android.tools.build:gradle的版本和你现在AS使用的版本一直;不然会出现一个劲在哪导入项目显示加载的进度条.
要是使用了library 记得修改library的tools.build:gradle的版本
第二步修改
导入会出现 Android开发编译时出现Error:Some file crunching failed, see logs for details 错误
解决方法:
在build.grandle文件中buildToolsVersion下边添加黄色代码即可
aaptOptions {
cruncherEnabled = false
useNewCruncher = false
}
整体的gradle文件
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = '3.3.2'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
aaptOptions {
cruncherEnabled = false
useNewCruncher = false
}
defaultConfig {
applicationId "com.chinaztt.fda.ui"
minSdkVersion 15
targetSdkVersion 22
versionCode 5
versionName "1.1.5"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/org.apache.http.legacy.jar')
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'com.wang.avi:library:1.0.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'me.imid.swipebacklayout.lib:library:1.0.0'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
//由于我本地采用Volley源码库依赖的,因为需要修改Volley源代码,后期会上传Volley修改之后的代码
//这边大家要使用Volley库的时候,直接打开下面的引入方式即可
//compile 'com.mcxiaoke.volley:library:1.0.19'
compile files('libs/gson-2.2.4.jar')
compile project(':Volley')
compile project(':ViewPagerIndicator')
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
//添加fdv_okhttp工具封装依赖库
compile project(':fdv_okhttp')
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
// if you have multiple outputs (when using splits), you may want to have other index than 0
// you should set your package name here if you are using different application IDs
// resourcePackageName "your.package.name"
// You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
}
解决在api 23 之后找不到HttpStatus办法
第一种:就是使用低版本,编译的时候使用22或者其他地域23的版本
第二种:就是加入代码:
useLibrary'org.apache.http.legacy'
解决使用的时候使用自己版本的gradle
一般在项目的gradle/wrapper/gradle-wrapper.properties文件中修改
具体展示如下:
怎么查看自己AS的gradle的版本:
修改出现dex相关的错误
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/gson/JsonSerializer;
出现的错误的原因就是jar包的重复的添加,在编译的时候有相同的jar包导致的.
在这个项目中我们使用了三个library的类库;在demo中我们添加了Gson的解析和v4和v7包,我们Dependencies下面分别依赖了三个类库,这个三个类库中都同时添加了v4或者v7或者是GSON;我们要解决不能重复的添加;
我的解决办法:
三个类库都是用这样的方式,没有重复的不用修改.