【问题标题】:Google Play Game Services + BaseGameUtils added to a Gradle project = package does not existGoogle Play 游戏服务 + BaseGameUtils 添加到 Gradle 项目 = 包不存在
【发布时间】:2013-10-17 13:11:05
【问题描述】:

我已经阅读了很多关于这个主题的答案,但无法解决我的问题,这里是:

我有一个 gradle 项目,它是一个游戏,我想在该游戏中添加谷歌游戏服务,就像我成功使用 'type-a-number' 所做的那样(这不是一个 gradle 项目)。

但我收到以下错误:

Gradle: error: package com.google.example.games.basegameutils does not exist
Gradle: error: cannot find symbol class BaseGameActivity
Gradle: error: cannot find symbol variable super

注意:在我的活动中,由于来自 BaseGameUtils 的所有红色内容在以下情况后都变为正常:

  • 将 BaseGameUtils 作为模块导入,将其作为模块依赖项添加到我的项目中并选中“library mobule”框。
  • 将 google-play-services.jar 作为库导入
  • 添加到我的 build.gradle 文件(我的模块根目录中的那个):

    dependencies {
        compile 'com.android.support:support-v4:18.+'
        compile 'com.google.android.gms:play-services:3.+'
    }
    

    ==> 是否可以在这里添加 BaseGameUtils 依赖项?

  • 尝试勾选/取消勾选 BaseGameUtils 依赖项的导出框

  • 试图将“编译”更改为“提供”
  • 将 settings.gradle 更改为

    include ':MyModule' '(:libraries):BaseGameUtils'
    

(一次使用 :libraries,一次不使用)

上面列出的都没有用..

我做错了什么?

我错过了什么?

【问题讨论】:

    标签: android dependencies gradle google-play-games build.gradle


    【解决方案1】:

    您的settings.gradle 应该是:

    include ':MyModule', ':BaseGameUtils'
    

    注意逗号。

    MyModulebuild.gradle 也应该有

    dependencies {
        compile 'com.android.support:support-v4:18.+'
        compile 'com.google.android.gms:play-services:3.+'
        compile project(':BaseGameUtils')
    }
    

    【讨论】:

    • 可以用逗号,但我现在收到此错误:Gradle:评估项目“:MyModule”时出现问题。 > 在项目 ':MyModule' 中找不到路径为 ':BaseGamesUtils' 的项目。
    • 我会指定这是因为模块 BaseGameUtils 不在我的项目中,如 MyModule,那么如何指向它?
    • @Mino - 所有模块都需要在 IntelliJ/Android Studio 的项目中。
    【解决方案2】:

    当我按照这里的步骤进行操作时:https://developers.google.com/games/services/android/init

    我被挂断了:

    dependencies {
        compile project(':BaseGameUtils')
        // ...
    }
    

    我只需要将其更改为:

    dependencies {
        compile project(':libraries:BaseGameUtils')
        // ...
    }
    

    希望对某人有所帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-20
      • 1970-01-01
      • 2014-02-02
      相关资源
      最近更新 更多