'tools:replace =“ android:allowBackup”'到<application>元素

时间:2019-08-09 07:48:10

标签: android build androidx

当我添加实现'com.github.MdFarhanRaja:SearchableSpinner:2.0'时遇到问题 警告提示给我

'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:20:5-123:19 to override.

这是我的Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.together">
    <!--
         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but you must specify either coarse or fine
         location permissions for the 'MyLocation' functionality.
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 맵 이용하기 위함 -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 다음 지도 -->
    <uses-permission android:name="android.permission.INTERNET" /> <!-- 대략적인 위치 참조 권한 -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 정확한 위치 참조 권한 -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
        android:allowBackup="false"
        android:appComponentFactory="whateverString"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:usesCleartextTraffic="true"
        tools:replace="android:appComponentFactory">

但是当我改变

 tools:replace="android:appComponentFactory"

此为

'tools:replace="android:allowBackup"

与此 新的错误显示和对我的建议

Manifest merger failed : Attribute application@appComponentFactory value=(whateverString) from AndroidManifest.xml:22:9-53
    is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:20:5-123:19 to override.

建议将此更改为android:appComponentFactory

如果要实施该怎么办?

这是我的模块:应用 +我添加了build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.blogapp"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

        }
    }

    compileOptions {

        sourceCompatibility JavaVersion.VERSION_1_8

        targetCompatibility JavaVersion.VERSION_1_8

    }
}

dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:animated-vector-drawable:28.0.0'//
    implementation 'com.android.support:exifinterface:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3' //있고 ㅇㅇ


    //Expandable 프래그먼트 goodbyepet selectmenu
    implementation 'com.thoughtbot:expandablerecyclerview:1.3'
    implementation 'com.thoughtbot:expandablecheckrecyclerview:1.4'


    //유튜브 강의 3 추가함
    //1장에서 설정한거 추가


    //1장에서 설정한거 추가
    implementation 'com.jakewharton:butterknife:8.8.1'
    //유튜브 강의 3 추가함


    // firebase core

    implementation 'com.google.firebase:firebase-core:16.0.9'

    // firebase auth
    implementation 'com.google.firebase:firebase-auth:17.0.0'

    // firebase storage
    implementation 'com.google.firebase:firebase-storage:17.0.0'

    // firebase realtime database
    implementation 'com.google.firebase:firebase-database:17.0.0'

    implementation "com.wdullaer:materialdatetimepicker:3.6.4"


    implementation 'com.android.support:support-v13:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'

    //photo control
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'

    // card view
    implementation 'com.android.support:cardview-v7:28.0.0'

    // swipe cards for petching
    implementation 'com.lorentzos.swipecards:library:1.0.9'

    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'    //있고 ㅇㅇ
    androidTestImplementation 'com.android.support.test:runner:1.0.2'   //있고 ㅇㅇ
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'  //있고 ㅇㅇ

    // Design library for Coordinator Layout and Toolbars
    implementation 'com.android.support:design:28.0.0'

    // circle design
    implementation 'de.hdodenhof:circleimageview:3.0.0'

    // rectangle design
    implementation 'com.github.siyamed:android-shape-imageview:0.9.3@aar'

    // bumptech/glide
    implementation 'com.github.bumptech.glide:glide:4.9.0'

    //picaso/glide
    implementation 'com.squareup.picasso:picasso:2.71828'

    // Edit Text
    implementation 'com.rengwuxian.materialedittext:library:2.1.4'

    // lombok 사용
    compileOnly 'org.projectlombok:lombok:1.18.8'
    annotationProcessor 'org.projectlombok:lombok:1.18.8'
    implementation 'com.android.support:gridlayout-v7:28.0.0'

    // User Map
    implementation 'com.android.support:appcompat-v7:28.0.0'

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'com.google.android.gms:play-services-maps:16.1.0'

    implementation 'com.google.android.gms:play-services-location:16.0.0'

    implementation 'com.google.android.gms:play-services-places:16.1.0'

    implementation 'noman.placesapi:placesAPI:1.1.3'

    implementation 'com.thoughtbot:expandablecheckrecyclerview:1.4'


    testImplementation 'junit:junit:4.12'

    androidTestImplementation 'com.android.support.test:runner:1.0.2'

    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'org.jetbrains:annotations-java5:15.0'


    //Calendar

    implementation 'joda-time:joda-time:2.10.1'


    // LifeCycle online or offline 여부 판별
    implementation "android.arch.lifecycle:extensions:1.1.1"

    // retrofit2 통신 라이브러리
    implementation 'com.google.firebase:firebase-messaging:19.0.1'
    implementation 'androidx.annotation:annotation:1.1.0'

    //calendar view
    implementation 'com.github.prolificinteractive:material-calendarview:1.5.0'


    // Searchable Spinner



}

apply plugin: 'com.google.gms.google-services'

这是我的突出版本

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath 'com.google.gms:google-services:4.2.0'
        // radio button
        classpath 'lib.kingja.switchbutton:switchbutton:1.1.8'
        classpath 'com.android.support:appcompat-v7:28.0.0'
        classpath 'com.google.android.gms:play-services-maps:17.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}



2 个答案:

答案 0 :(得分:1)

android:allowBackup="false"之后添加tools:replace="android:allowBackup"。 在 mainfest 文件中使用此代码即可解决此问题。

答案 1 :(得分:0)

如评论中所述,您正在使用依赖于支持库的第三方库,并且在项目中使用了AndroidX。可以使用Jetifier来解决:

转到您的 gradle.properties 文件并添加以下行:

android.enableJetifier=true

  

android.enableJetifier::设置为true时,此标志表示您希望拥有工具支持(来自Android Gradle插件)以自动转换现有的第三方库,就像为第三方库编写的那样AndroidX。如果该标志不存在,则Android Studio的行为就像该标志被设置为false一样。

如果这仍然导致错误,请使用“重构”菜单中的Migrate to AndroidX,它应该会自动解决此问题。

enter image description here