Google Play Game Services + BaseGameUtils added to a Gradle project = package does not exist

时光毁灭记忆、已成空白 提交于 2019-12-20 01:41:01

问题


I already read many answers on this subject but can't fix my problem, and here it is :

I have a gradle project that is a game, in that game I want to add google game services like I successfully did with 'type-a-number' (which is NOT a gradle project).

But I get the following error:

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

NOTE : in my activity everything that was red because of coming from BaseGameUtils change to normal after the following :

  • imported BaseGameUtils as a module, added it as a module dependency to my project and check the 'library mobule' box.
  • imported google-play-services.jar as a library
  • added to my build.gradle file (the one in my module root) :

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

    ==> Is there a possibility to add a BaseGameUtils dependencies here ?

  • tried to check/uncheck the export box of BaseGameUtils dependency

  • tried to change 'compile' to 'provided'
  • change the settings.gradle to

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

(one time with :libraries, one time without)

Nothing listed above worked..

What I'm doing wrong ?

What I'm missing ?


回答1:


Your settings.gradle should be:

include ':MyModule', ':BaseGameUtils'

Note the comma.

Your build.gradle for MyModule should also have

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



回答2:


When I was following the step-by-step here: https://developers.google.com/games/services/android/init

I was hung up on:

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

and I just needed to change it to:

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

hope that helps someone :)



来源:https://stackoverflow.com/questions/19284521/google-play-game-services-basegameutils-added-to-a-gradle-project-package-do

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!