在Gradle上编译Google Play服务库时,应用在Android 4.4上崩溃

时间:2016-01-28 15:45:47

标签: java android gradle google-play-services

我正在尝试在我的应用中实施Google Cloud Messaging,它在运行Android 5.1的设备上运行良好。但是,当我尝试在4.4或更低版本的设备上安装它时,我的所有依赖项都会崩溃。

它显示的例外是Unable to start activity ComponentInfo{com.mycompany.myapp/com.mycompany.myapp.ui.LoginActivity}: android.view.InflateException: Binary XML file line #66: Error inflating class fr.castorflex.android.smoothprogressbar.SmoothProgressBar。起初我以为是SmoothProgressBar库失败了,所以我从依赖项中删除了它,然后它是CircleImageView,然后是Material-Ripple。

有趣的是,正如我所说,当我编译'com.google.android.gms:play-services:8.4.0'并且仅在Android 4.4或更低版本时,应用程序崩溃。

这就是我的gradle看起来像

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.mycompany.myapp"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "0.3b"
        multiDexEnabled true
    }
    applicationVariants.all { variant ->
        variant.resValue "string", "versionName", variant.versionName
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.google.zxing:core:3.2.0'
    compile 'com.github.castorflex.smoothprogressbar:library:1.0.0'
    compile 'com.github.aakira:expandable-layout:1.4.1@aar'
    compile 'com.github.castorflex.smoothprogressbar:library-circular:1.0.0'
    compile 'com.github.philjay:mpandroidchart:v2.1.6'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.balysv:material-ripple:1.0.2'
    compile 'com.journeyapps:zxing-android-embedded:3.0.3@aar'
    compile 'com.commit451:PhotoView:1.2.4'
}

这是我的明白

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mycompany.myapp">


    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" /> <!-- To retrieve the account name (email) as part of sign-in: -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- To auto-complete the email text field in the login form with the user's emails -->
    <uses-permission android:name="android.permission.READ_PROFILE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.hmkcode.android.gcm.permission.C2D_MESSAGE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />


    <!-- Servicios de localización -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <!-- Acceso a la cámara del dispositivo -->
    <uses-permission android:name="android.permission.CAMERA" />

    <!-- Permiso para almacenar en almacenamiento -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <!-- Permiso para acceder a internet -->
    <uses-permission android:name="android.permission.INTERNET" />

    <!-- Permiso para conocer el estado de la red -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name=".ui.LoginActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.MenuPrincipalActivity"
            android:label="@string/title_activity_menu_principal"
            android:screenOrientation="portrait" />

        <!-- lots of activities -->

        <service
            android:name=".services.DescargaInformacionService"
            android:enabled="true"
            android:exported="false" />
        <service
            android:name=".services.ReportePosicionService"
            android:enabled="true"
            android:exported="false" />
        <service
            android:name=".services.EnvioDatosService"
            android:enabled="true"
            android:exported="false" />
        <service
            android:name=".services.GcmService"
            android:enabled="true"
            android:exported="false" />

        <receiver
            android:name=".services.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />

                <category android:name="com.hmkcode.android.gcm" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

知道我可能做错了什么吗?也许到很多图书馆?任何帮助将不胜感激。

0 个答案:

没有答案