【问题标题】:Replace other declarations but no other declaration present?替换其他声明但不存在其他声明?
【发布时间】:2019-07-01 19:41:47
【问题描述】:

我的 AndroidManifest.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.varianttecnology.uberclone">

<!--
     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.ACCESS_COARSE_LOCATION"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <!--
         The API key for Google Maps-based APIs is defined as a string resource.
         (See the file "res/values/google_maps_api.xml").
         Note that the API key is linked to the encryption key used to sign the APK.
         You need a different API key for each encryption key, including the release key that is used to
         sign the APK for publishing.
         You can define the keys for the debug and release targets in src/debug/ and src/release/. 
    -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />

    <activity
        android:name=".Welcome"
        android:label="@string/title_activity_welcome"></activity>
</application>

我正在使用 build.gradle 版本

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.3.1'
    classpath 'com.google.gms:google-services:4.1.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://maven.google.com'
    }
    maven {
        url "http://dl.bintray.com/glomadrian/maven"
      }
   }
}

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

而 build.gradle(APP) 文件是这样的

apply plugin: 'com.android.application'

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

packagingOptions {
    exclude 'META-INF/services/javax.annotation.processing.Processor'
}

lintOptions {
    disable 'InvalidPackage'
   }
 }

dependencies {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   implementation 'com.android.support:appcompat-v7:28.0.0'
   implementation 'com.android.support.constraint:constraint-layout:1.1.3'
   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'

//Add libraries
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-auth:16.1.0'

implementation 'com.android.support:design:28.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'

implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.github.d-max:spots-dialog:1.1@aar'
implementation 'com.android.support:support-media-compat:28.0.0'

implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services:16.1.0'

implementation 'com.firebase:geofire-android:2.1.2'
implementation 'com.android.support:mediarouter-v7:28.0.0'
implementation 'com.github.glomadrian:MaterialAnimatedSwitch:1.1@aar'
}
apply plugin: 'com.google.gms.google-services'

但是AndroidManifest.xml文件中总是显示这个Warning,这个Warning怎么解决?

E:\Andriod\EdmtDev\Uber 
Clone\UberClone\app\src\main\AndroidManifest.xml:24:9-31:50 Warning:
activity#com.google.firebase.auth.internal.FederatedSignInActivity@android:l 
aunchMode was tagged at AndroidManifest.xml:24 to replace other declarations 
but no other declaration present

问题:

  1. 这个新选项卡是 AS 3.2.1 中的新内容吗?还是因为 AS 3.2.1 发现了以前版本没有的新警告?

  2. 警告是关于什么的?

  3. 我该如何解决?

【问题讨论】:

标签: java android android-gradle-plugin


【解决方案1】:

请尝试在 AndroidManifest.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"
    ...>

<activity
    android:name="com.google.firebase.auth.internal.FederatedSignInActivity"
    tools:replace="android:launchMode"
    android:launchMode="standard" />
...

【讨论】:

  • 为我工作。不要忘记第一部分。我一开始就跳过了。将 xmlns:tools="http://schemas.android.com/tools" 添加到 AndroidManifest.xml 顶部的开始清单标记中,否则您将收到有关 tools:replace="android:launchMode" 的错误
【解决方案2】:

这个问题可以通过合并多个清单文件的权限来解决

<uses-permission tools:node="merge" android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission tools:node="merge" android:name="android.permission.ACCESS_COARSE_LOCATION" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-14
    • 1970-01-01
    • 1970-01-01
    • 2020-08-12
    • 2013-11-17
    • 2021-04-19
    • 1970-01-01
    • 2016-06-09
    相关资源
    最近更新 更多