【问题标题】:Cannot resolve symbol 'android' - While implementing Google Analytics in Android App with libgdx无法解析符号“android” - 在使用 libgdx 在 Android 应用程序中实现 Google Analytics 时
【发布时间】:2016-02-20 18:28:28
【问题描述】:

我正在尝试关注 this tutorial 并导入分析跟踪器。我花了几个小时,但仍然没有运气。

我不断收到以下错误:

Cannot resolve symbol 'android'

这是我将classpath 行放入我的项目build.grade 的地方:

buildscript {
    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        jcenter()
    }
    dependencies {
        classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'org.robovm:robovm-gradle-plugin:1.9.0'
        classpath 'com.google.gms:google-services:1.5.0-beta2' // <-- HERE
    }
}

我已将这些行添加到我的 Android 模块 Gradle:

android {
    apply plugin: 'com.google.gms.google-services' // <-- HERE

和:

dependencies {
    compile 'com.google.android.gms:play-services-analytics:8.3.0' // <-- HERE
}

我做错了什么?请帮忙。

P.S.:它适用于 Analytics 示例。

【问题讨论】:

    标签: java android android-studio google-analytics libgdx


    【解决方案1】:

    您需要先应用android 插件,然后再应用google-services 插件。然后在闭包中配置你的android 模型

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.3.0'
            classpath 'com.google.gms:google-services:1.5.0-beta2'
        }
    }
    
    apply plugin: 'com.android.application'
    apply plugin: 'com.google.gms.google-services'
    
    android {
        // blah
    }
    
    dependencies {
        compile "com.google.android.gms:play-services:8.3.0"
        compile 'com.google.android.gms:play-services-analytics:8.3.0'
        // blah
    }
    

    【讨论】:

    • 感谢您的评论。但是,它仍然找不到导入。
    【解决方案2】:

    终于找到问题了!

    我需要进行干净的构建和重建。仅此而已!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-20
      • 1970-01-01
      • 2016-11-14
      • 2012-09-04
      • 1970-01-01
      • 2016-05-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多