小编Mat*_*ero的帖子

将Google Play服务升级到11.0.0版本后出错

我有一个奇怪的问题.将Google Play服务库从版本10.2.6上传到版本11.0.0后,当我尝试编译时出现此错误:

错误:任务':app:processDebugGoogleServices'的执行失败.请通过更新google-services插件的版本来修复版本冲突(有关最新版本的信息,访问https://bintray.com/android/android-tools/com.google.gms.google-services/)或将com.google.android.gms的版本更新为11.0.0.

我访问了错误中提到的链接,谷歌服务插件的最后一个版本似乎是3.1.0,即我正在使用的版本,我已经将所有播放服务库升级到11.0.0版本.如何用11.0.0版本的GMS编译我的代码?

这是我的build.gradle文件(模块范围):

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

android {

    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 23
        versionName "0.7.3.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        manifestPlaceholders = [onesignal_app_id               : "12345678-1234-1234-1234-123456789",
                            // Project number pulled from dashboard, local value is ignored.
                            onesignal_google_project_number: "REMOTE"]
        multiDexEnabled true
    }
    buildTypes {

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

    productFlavors {
        prontopro {
            applicationId "com.example.app"
            buildConfigField "boolean", "TEST_ENVIRONMENT", "false"
        }

        prontoproTest {
            applicationId …
Run Code Online (Sandbox Code Playgroud)

android google-play-services build.gradle android-gradle-plugin

13
推荐指数
2
解决办法
2万
查看次数

Firebase云消息传递 - Android:应用关闭时的通知点击操作无效

我正在使用Firebase云消息传递将数据消息传递到我正在开发的应用程序.根据FCM文档,当应用程序处于前台时:

客户端应用程序在onMessageReceived()中接收数据消息,并可以相应地处理键值对.

它工作正常.当应用在后台时,行为是不同的:

可以在用于启动活动的Intent中检索数据有效负载.

它看起来似乎不太好用.我在通知JSON中使用了"click_action"参数,其中我指定了我要打开的"activity"标记内Android Manifest中使用的intent过滤器的名称.例如,我的通知可能是:

{
    "to" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...",
    "notification" : {
        "body" : "This is a test",
        "title" : "Test",
        "click_action" : "com.test.click"
    },
    "data" : {
        "key" : "data"
    }
}
Run Code Online (Sandbox Code Playgroud)

我的清单在"MainActivity"中有这个intent-filter:

<intent-filter>
    <action android:name="com.test.click" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

当我的应用程序处于后台并且我启动通知时,一切似乎都运行良好:我单击通知并显示正确的活动,并且数据键位于收到的意图的"额外"中.我的应用程序关闭时出现问题:当我点击通知时,应用程序正确启动并使用"com.test.click"intent-filter打开活动,但如果我尝试发送另一个通知,则当我点击时没有任何反应,在重新启动应用程序之前,后台通知不再起作用.

更清楚一点:当我的应用程序处于前台或后台时,通知工作正常.如果我的应用程序已关闭,则会正确处理第一个通知,但在重新启动应用程序之前,所有其他后台通知都不再有效:如果我点按通知,我的应用会显示上次观看的活动,就好像我从"最近的应用"菜单.如果我关闭并重新启动应用程序,通知将恢复正常工作.

这是Android中的数据消息或FCM问题的错误吗?有没有办法解决这个问题?

我正在使用Nexus 5 API 23进行测试.

android firebase firebase-cloud-messaging

9
推荐指数
1
解决办法
7186
查看次数

Android导航视图-项目高程

有没有一种方法,可以使用Google支持库的NavigationView元素,在NavigationView内的项目上使用高程来实现以下效果:

带标头高程的导航视图

您可以看到导航抽屉的标题具有高程,就像视图底部的页脚一样。

我尝试使用“ android:elevation”属性,但它似乎无法正常工作。
这是我目前对NavigationView的代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="end">

    <include
        layout="@layout/app_bar_product_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_filters">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:gravity="center|end"
            android:padding="16dp"
            android:elevation="16dp"
            android:orientation="horizontal"
            tools:targetApi="lollipop">

            <TextView
                android:textAppearance="@style/TextAppearance.AppCompat.Button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Clear"/>

        </LinearLayout>

    </android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

这是导航视图标题的XML文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorAccent"
    android:elevation="8dp"
    android:gravity="bottom"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:theme="@style/ThemeOverlay.AppCompat.Light"
    tools:targetApi="lollipop">

    <android.support.v4.widget.Space
        android:layout_width="match_parent"
        android:layout_height="@dimen/status_cheat" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/ordina_per"
            android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
            android:textColor="@android:color/white" …
Run Code Online (Sandbox Code Playgroud)

xml android android-layout navigation-drawer android-elevation

5
推荐指数
1
解决办法
734
查看次数