Android Studio导入项目又双双踩了几个坑

版权声明:http://guozh.net/ 《=== 秘密哦 https://blog.csdn.net/guozhaohui628/article/details/87908791

导了一个 Android 项目,就和打怪通关一样,解决一个问题又出来一个,这里暂且拿其中几个以前没碰到的

No resource identifier found for attribute ‘appComponentFactory’ in package ‘android’

在网上搜到 https://stackoverflow.com/questions/50266035/no-resource-identifier-found-for-attribute-appcomponentfactory-in-package-and ,里面的解决办法并不适合我。

然后将 com.android.support:appcompat-v7 这个包修改成老项目的版本,然后就解决了。如果你不知道哪个包版本有问题。通过注释 app build.gradle 一些依赖,然后同步。不断测试出来,因为注释了依赖,只是类缺少导包报错,和此错误并不一样。

java.lang.RuntimeException: Translation has been interrupted

Multiple dex files define Landroid/support/v4/view/AbsSavedState;

这两个错误是同种情况,V4包冲突了。这里很难解决,因为项目依赖一个 lib jar 包。所以不能像普通的排除方法。

本来普通的排除如下:

  compile ('com.android.support.constraint:constraint-layout:1.1.3'){
        exclude group:'com.android.support',module:'support-v4'
    }

改成如下:

  compile (fileTree(include: ['*.jar'], dir: 'libs')){
        exclude group:'com.android.support',module:'support-v4'
    }

结果不行,如上写法是错误的

而我又没查出来到底哪个包和 lib/.jar 冲突。没办法,将所有的包都添加排除(很骚的操作~~)。

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile ('com.android.support:appcompat-v7:27.1.0'){
        exclude group:'com.android.support',module:'support-v4'
    }
    compile ('com.android.support.constraint:constraint-layout:1.1.3'){
        exclude group:'com.android.support',module:'support-v4'
    }

    compile ('com.android.support:recyclerview-v7:24.1.1'){
        exclude group:'com.android.support',module:'support-v4'
    }
}

 原创 https://guozh.net/?p=356

  【案例】这些日赚上万美金Youtube油管从业者 我很羡慕

公众号「第一勺金」

一个关注 一个可能的机会

猜你喜欢

转载自blog.csdn.net/guozhaohui628/article/details/87908791
今日推荐