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

导了一个 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/android-studiodaoruxiangmuyoushuangshuangcailejigekeng/

Android Studio导入项目又双双踩了几个坑》有1个想法

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注