gpt4 book ai didi

android - 错误 : package com. google.android.gcm 不存在 - 迁移到 Gradle 后

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:19:58 25 4
gpt4 key购买 nike

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

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 种不同的解决方案,但该项目仍然无法正常工作。如何解决?

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 不是 Google Play 服务的一部分,而是 now entirely deprecated 的一部分gcm.jar 文件。

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

compile files('libs/gcm.jar')

关于android - 错误 : package com. google.android.gcm 不存在 - 迁移到 Gradle 后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28952873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com