如何GooglePlayServices和BaseGameUtils库添加到Android 4.4工作室 [英] How to add GooglePlayServices and BaseGameUtils libs to Android Studio 4.4

查看:441
本文介绍了如何GooglePlayServices和BaseGameUtils库添加到Android 4.4工作室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有很多教程...,但为Eclipse(我不知道为什么谷歌不能为自己提供的工具教程)...
    让我们从头开始,我要分板和成就添加到我的比赛。我使用的Andr​​oid 4.4工作室。我的项目结构如下:

  NameProject
     - > gradle这个
     - >名称
    --->建立
    --->库
    ---> SRC
    --->的build.gradle
     - > //的build.gradle空
     - > settings.gradle

我粘贴:的Google Play-services.jar

Android\\android-studio\\sdk\\extras\\google\\google_play_services\\libproject\\google-play-services_lib\\libs

的文件夹(然后右键单击 - >添加为库)

在我下载样品并粘贴BaseGameUtils目录库目录。
    我的项目树如下:

  NameProject
     - > gradle这个
     - >图书馆
    ---> BaseGameUtils
     - >名称
    --->建立
    --->库
    ---> SRC
    --->的build.gradle
     - > //的build.gradle空
     - > settings.gradle

我伸出MainActivity类别(BaseGameActivity)和进口:


  1. 进口com.google.example.games.basegameutils.BaseGameActivity;

  2. 进口com.google.example.games.tq.R;

但是Android工作室仍然无法看到这些库...

我的的build.gradle 的样子:

  buildscript {
        库{
            mavenCentral()
        }
        依赖{
            类路径'com.android.tools.build:gradle:0.7.+
        }
    }
    应用插件:'机器人'    库{
        mavenCentral()
    }    依赖{
        编译com.android.support:support-v4:13.0.+
        编译文件(库/ GoogleAdMobAdsSdk-6.4.1.jar')
    }    安卓{
        compileSdkVersion 19
        buildToolsVersion '18 .1.1        defaultConfig {
            9的minSdkVersion
            targetSdkVersion 16
        }
    }    依赖{
        编译com.android.support:appcompat-v7:+
        编译com.google.android.gms:播放服务:4.1.32+
    }

我的 settings.gradle 的文件:

 包括(:库):BaseGameUtils',':名称

你能解释一下我一步一步,如何添加这些库?

先谢谢了。


解决方案

我做下一个解决这个问题:


  1. 导入BaseGameUtils目录(也就是BasicSamples /库/内部)作为在Android工作室的模块。

  2. 然后添加此:编制项目(':BaseGameUtils')的依赖关系到我的build.gradle是应用程序目录内内

  3. 导入BaseGameUtils(ALT +从那里你发现code BaseGameUtils线路输入)

观测:我试了偶然和工作非常好

I know that there is many tutorials..., but for Eclipse(I don't know why Google can't provide tutorial for their own tool)... Let's start from the beginning, I want to add score board and achievements to my game. I'm using Android Studio 4.4. My project structure looks like:

    NameProject
    -> gradle
    -> Name
    ---> build
    ---> libs
    ---> src
    ---> build.gradle
    -> build.gradle //empty
    -> settings.gradle

I pasted: google-play-services.jar from

Android\android-studio\sdk\extras\google\google_play_services\libproject\google-play-services_lib\libs

to libs folder(then right click -> add as library)

After that I downloaded samples and pasted BaseGameUtils directory to libraries directory. My project tree looks like:

    NameProject
    -> gradle
    -> libraries
    ---> BaseGameUtils
    -> Name
    ---> build
    ---> libs
    ---> src
    ---> build.gradle
    -> build.gradle //empty
    -> settings.gradle

I extended MainActivity class (BaseGameActivity) and imported:

  1. import com.google.example.games.basegameutils.BaseGameActivity;
  2. import com.google.example.games.tq.R;

But Android Studio still can't see those libs...

My build.gradle looks like:

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.7.+'
        }
    }
    apply plugin: 'android'

    repositories {
        mavenCentral()
    }

    dependencies {
        compile 'com.android.support:support-v4:13.0.+'
        compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
    }

    android {
        compileSdkVersion 19
        buildToolsVersion '18.1.1'

        defaultConfig {
            minSdkVersion 9
            targetSdkVersion 16
        }
    }

    dependencies {
        compile 'com.android.support:appcompat-v7:+'
        compile 'com.google.android.gms:play-services:4.1.32+'
    }

My settings.gradle file:

    include '(:libraries):BaseGameUtils', ':Name'

Can you explain me step by step, how to add those libraries?

Thanks in advance.

解决方案

I solve this problem by doing the next:

  1. Importing BaseGameUtils directory (that that is inside the BasicSamples/libraries/) as a module on android studio.
  2. Then adding this: compile project(':BaseGameUtils') inside the dependences to my build.gradle that is inside the app directory.
  3. Import BaseGameUtils (alt+enter from the line where you find BaseGameUtils on your code)

Obs: I tried it by chance and worked very well.

这篇关于如何GooglePlayServices和BaseGameUtils库添加到Android 4.4工作室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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