错误:com.google.android.gcm 包不存在 - 迁移到 Gradle 后 [英] error: package com.google.android.gcm does not exist - After migrating to Gradle

查看:31
本文介绍了错误:com.google.android.gcm 包不存在 - 迁移到 Gradle 后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在没有 Gradle 的情况下使用 IntelliJ 开发的旧项目的问题.我想将它迁移到 Android Studio 和 Gradle,但我遇到了很多问题.由于项目比较老,所以使用了旧的 Google Play Services 版本.在 Intellij 中,我刚刚将旧 gps 的 libproject 添加到依赖项(google_play_services_5089000_r19)中,一切正常.在 Android Studio 中,我设法通过将其添加为库模块并将 compile project(':segmentedradios') 添加为 gradle 依赖项来添加其他库,但我无法使 gps 库工作.我尝试将其添加为模块,但 Android Studio 在指向 libroject 库的目录后说未选择模块".我也尝试将其添加为 gradle 依赖项,但我不断收到如下错误:

I have a problem with an old project which was developed in IntelliJ without Gradle. I wanted to migrate it to Android Studio and Gradle, but I am experiencing a lot of problems. Since the project was quite old, the old Google Play Services version was used. In Intellij I had just added libproject of the old gps to dependencies (google_play_services_5089000_r19) and everything worked fine. In Android Studio I managed to add other libraries by adding it as a library module and adding compile project(':segmentedradios') as a gradle dependency, but I just can't make gps library work. I've tried to add it as a module, but Android Studio says that "no module selected" after pointing to libroject library's directory. I also tried to add it as a gradle dependency, but I am keep getting errors like these:

error: package com.google.android.gcm does not exist
error: package com.google.android.maps does not exist
error: cannot find symbol variable GCMRegistrar

尽管我尝试了大约 10 种不同的解决方案,但该项目仍然无法运行.如何解决?

Despite I tried ~10 different solutions, the project still does not work. How to fix it?

分级:

apply plugin: 'com.android.application'

android {
    compileSdkVersion "Google Inc.:Google APIs:18"
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "my_package.app_name"
        minSdkVersion 14
        targetSdkVersion 18
    }

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

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
    compile files('libs/libGoogleAnalyticsV2.jar')
    compile project(':segmentedradios')
    compile 'com.google.android.gms:play-services:5.0.89'
}

推荐答案

GCMRegistrar 不是 Google Play 服务的一部分,而是 现已完全弃用 gcm.jar 文件.

GCMRegistrar is not part of Google Play Services, but is part of the now entirely deprecated gcm.jar file.

如果您想暂时继续使用它,则需要将 gcm.jar 添加到您的依赖项中,直到您迁移到 Google Play 服务的 GCM 实施:

You'll need to add gcm.jar to your dependencies if you'd like to temporarily keep using it until you migrate to Google Play Services' GCM implementation:

compile files('libs/gcm.jar')

这篇关于错误:com.google.android.gcm 包不存在 - 迁移到 Gradle 后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆