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

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

问题描述

我有这是在开发的IntelliJ不摇篮旧项目的问题。我想把它移植到Android Studio和摇篮,但我遇到了很多问题。由于该项目是很旧,使用旧的谷歌播放服务版本。在的IntelliJ我刚刚添加的旧的GPS libproject到依赖性(google_play_services_5089000_r19),一切运行良好。在Android Studio中我设法将其添加为一个库模块并添加编制项目(':segmentedradios)来添加其他库作为依赖的Gradle,但我不能使GPS图书馆工作。我试图将其添加为一个模块,而Android工作室说:没有模块选择指向 libroject 库的目录之后。我也试图将其添加为一个依赖的Gradle,但我不断收到这样的错误:

 错误:包com.google.android.gcm不存在
错误:包com.google.android.maps不存在
错误:无法找到符号变量GCMRegistrar

尽管我试过〜10种不同的解决方案,该项目仍然无法正常工作。如何解决呢?

摇篮:

 应用插件:'com.android.application安卓{
    compileSdkVersion谷歌Inc.:Google的API:18
    buildToolsVersion21.1.2    defaultConfig {
        的applicationIDmy_package.app_name
        14的minSdkVersion
        targetSdkVersion 18
    }    buildTypes {
        发布 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard的-rules.txt
        }
    }
}依赖{
    编译com.android.support:support-v4:18.0.0
    编译文件(库/ libGoogleAnalyticsV2.jar')
    编制项目(':segmentedradios')
    编译com.google.android.gms:播放服务:5.0.89
}


解决方案

GCMRegistrar 不是谷歌Play的一部分服务,反而是的现在完全去precated gcm.jar 文件。

您需要添加 gcm.jar 来你的依赖,如果你想使用它,直到你迁移到谷歌播放服务GCM实施暂时保留:

 编译文件(库/ gcm.jar')

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

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

Gradle:

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 is not part of Google Play Services, but is part of the now entirely deprecated gcm.jar file.

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不存在 - 迁移到摇篮后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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