Android笔记(四)(部分报错整理)

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
    }
    ...

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值