1. 在github上下载下来的代码,出现的一些报错
-
Error:Project with path 'lib' could not be found
解决:在setttings.gradle增加以下代码
include ':app', ':lib'
-
Error:Plugin with id 'com.novoda.bintray-release' not found
解决:在项目根目录下的build.gradle的dependencies 添加
classpath 'com.novoda:bintray-release:0.3.4'
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
//添加下面这行代码就OK了
classpath 'com.novoda:bintray-release:0.3.4
}
-
Execution failed for task ':app:processDebugResources'
解决:buildToolsVersion与compileSdkVersion 不匹配导致,修改
-
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
解决:引入的Libary与现有的工程中的Libs重复了
在app下的build.gradle的defaultConfig添加multiDexEnabled true
defaultConfig {
multiDexEnabled true
}
-
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/项目包名
解决:在app下的build.gradle的defaultConfig标签添加
ndk {
//选择要添加的对应cpu类型的.so库。
abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'mips'
}
注意添加的与导入的.so库对应,把多余的删掉
-
导入别人的android studio项目或者在github下的项目时无法运行和编译的根本是gradle不一致的情况
删除下列文件
根目录下的build.gradle,修改gradle的版本
gradle下的gradle-wrapper.properties 也修改为合适的版本
2. RecyclerView刷新数据的时候IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter
public class WrapContentLinearLayoutManager extends LinearLayoutManager {
public WrapContentLinearLayoutManager(Context context) {
super(context);
}
public WrapContentLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
public WrapContentLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
super.onLayoutChildren(recycler, state);
} catch (IndexOutOfBoundsException e) {
Log.e("problem", "meet a IOOBE in RecyclerView");
}
}
}
LinearLayoutManager linearLayoutManager=new WrapContentLinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(linearLayoutManager);
如果不分页的话 设置加载更多false
3. 引入nice-spinner:1.4.5报错
在app的 build.gradle中 android节点下添加
android {
...
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
...
}