Android Studio中未解析的符号

时间:2015-08-04 21:43:52

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

我正在尝试将GCM添加到我的应用中,因此我正在关注this guide

但是我在以下问题上遇到了未解决的符号错误:

import android.support.v7.app.AppCompatActivity;

和我的R图书馆

这是我的manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.examplegcm"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="21" />

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
    <uses-permission android:name="com.example.examplegcm.permission.C2D_MESSAGE"/>
    <uses-permission android:name="com.google.android.c2dm.permission.SEND"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>




    <application
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:label="@string/app_name"
        android:theme="@style/MyTheme" >

        <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" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="com.example.examplegcm" />
            </intent-filter>
        </receiver>
        <service
            android:name="com.example.examplegcm.chatGCM.MyGcmListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>
        <service
            android:name="com.example.examplegcm.chatGCM.MyInstanceIDListenerService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.gms.iid.InstanceID"/>
            </intent-filter>
        </service>

        <activity
            android:name=".MainApplication"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoDisplay" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

以下是我的gradle

顶级:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.google.gms:google-services:1.3.0-beta1'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

应用

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion '22.0.1'

    defaultConfig {
        applicationId "com.alaarami.letsrun"
        minSdkVersion 16
        targetSdkVersion 21
    }

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

dependencies {
    compile 'com.android.support:support-v4:21.0.3'
    compile files('libs/slf4j-api-1.7.12.jar')
    compile files('libs/slf4j-simple-1.7.12.jar')
    apply plugin: 'com.google.gms.google-services'
    compile 'com.google.android.gms:play-services:7.5.0'
}

编译Sdk版本:16 构建工具版本:22.0.1

jdk:1.8

已安装的SDK:

SDKs

更新

它已经解决了...我不知道如何。什么都没做

1 个答案:

答案 0 :(得分:0)

添加到您的依赖项

compile 'com.android.support:appcompat-v7:21.0.3'

这是包含AppCompatActivity的工件。