【问题标题】:No record for key [permission#${applicationId}.permission.C2D_MESSAGE]密钥 [permission#${applicationId}.permission.C2D_MESSAGE] 没有记录
【发布时间】:2017-09-19 22:23:54
【问题描述】:

我正在使用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'

【问题讨论】:

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


【解决方案1】:

我通过@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" />

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

【讨论】:

    【解决方案2】:

    由于旧的依赖库参考项目级build.gradle,我遇到了这个问题。

    在我的例子中是 Firebase

    classpath 'com.google.gms:google-services:3.0.0'
    

    我已经更新到了

    classpath 'com.google.gms:google-services:3.1.0'
    

    我还从 Firebase 控制台更新了配置文件,问题已经解决。

    也许对你有帮助……

    【讨论】:

      【解决方案3】:

      找到了解决这个问题的方法:

      gradle assemble -info 提示我 Manifest 有不同的 SDK 版本,无法合并。

      我需要编辑我的 Manifests 和 build.gradle 文件,然后一切正常。


      为了清楚起见,您需要在 AndroidManifest.xml

      中编辑 uses-sdk
      <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16" />
      

      android 部分,尤其是build.gradle 文件中的minSdkVersiontargetSdkVersion

      android {
          compileSdkVersion 17
          buildToolsVersion "17.0.0"
      
          defaultConfig {
              minSdkVersion 14
              targetSdkVersion 16
          }
      }
      

      【讨论】:

      • 我已经尝试过了,但是没有用。我的错误不是SDK 错误。感谢您的回答
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-19
      • 1970-01-01
      • 1970-01-01
      • 2019-11-21
      • 2010-11-29
      • 2016-04-28
      • 2015-01-29
      相关资源
      最近更新 更多