android-studio - 没有 key [permission#$ {applicationId} .permission.C2D_MESSAGE]的记录

标签 android-studio gradle google-cloud-messaging android-permissions

我正在使用Android Studio 2.2.2Gradle version is 2.14.1。我的项目在一台计算机上运行良好。当我尝试在另一台计算机上打开同一项目时,它向我发送以下错误消息:

Error:Execution failed for task ':app:processReleaseManifest'.
> No record for key [permission#${applicationId}.permission.C2D_MESSAGE]
Information:Gradle tasks [clean, :app:generateReleaseSources, :app:prepareReleaseUnitTestDependencies, :app:mockableAndroidJar]

我检查了 thisthis 或其他问题,但没有解决我的问题。如果有人可以帮助我,请先谢谢。

这是我的 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.newsongplay.app">

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.android.vending.BILLING" />

    <!-- GCM -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <permission android:name="com.newsongplay.app.permission.C2D_MESSAGE"/>

    <uses-permission android:name="com.newsongplay.app.permission.C2D_MESSAGE" />

    <application
        android:name="com.newsongplay.app.activity.WaraMusicApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:replace="android:icon">
        <activity
            android:name="com.newsongplay.app.activity.SplashActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        //Other activity also here

        <receiver
            android:name="com.google.android.gms.gcm.GcmReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="com.google.android" />
            </intent-filter>
        </receiver>

        <service
            android:name=".gcm.PushNotificationService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>

    </application>

</manifest>

这是我的应用程序级别 build.gradle 文件
apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.newsongplay.app"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 2
        versionName "1.0.1"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:cardview-v7:23.4.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.mimecraft:mimecraft:1.1.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile files('libs/YouTubeAndroidPlayerApi.jar')
    compile 'com.malmstein:fenster:0.0.2'
    compile 'com.facebook.android:facebook-android-sdk:4.16.0'
    compile 'com.google.android.gms:play-services-auth:9.0.1'
    compile 'com.google.android.gms:play-services-plus:9.0.1'
    compile 'com.google.android.gms:play-services-gcm:9.0.1'
    compile 'org.apache.commons:commons-io:1.3.2'
}
apply plugin: 'com.google.gms.google-services'

最佳答案

我通过@shailesh提供的this question's answer解决了我的问题。

我在 AndroidManifest.xml 文件中对此进行了更改

<!-- GCM -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
    <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />

我不知道,但是对我有用。

关于android-studio - 没有 key [permission#$ {applicationId} .permission.C2D_MESSAGE]的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42434705/

相关文章:

extjs - Gradle——从任务中执行多个命令

android - 0 台设备支持的应用

android - 如何处理取消注册推送通知?

android - 版本冲突更新为Play-Services 9.4.0 Android Studio 2.2

安卓工作室 : Cannot write to Shared Preferences in instrumented test

java -> com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:org/apache/commons/collections/ArrayStack.class

android - 从服务更新 UI

java - Android 上的 GCM 演示客户端,错误为 "Unable to instantiate activity"

android-studio - 如何使用android studio自动格式化评论中的空格?

c++ - android studio 中的外部 C++ 源文件?