無法解析符號“android” - 在使用 libgdx 在 Android 應用程序中實現 Google Analytics 時 (Cannot resolve symbol 'android' - While implementing Google Analytics in Android App with libgdx)


問題描述

無法解析符號“android” ‑ 在使用 libgdx 在 Android 應用程序中實現 Google Analytics 時 (Cannot resolve symbol 'android' ‑ While implementing Google Analytics in Android App with libgdx)

我正在嘗試遵循 本教程並導入分析跟踪器。我花了幾個小時,但仍然沒有運氣。

enter image description here

我不斷收到以下錯誤:

Cannot resolve symbol 'android'

這是我在我的項目 build.grade 中放置 classpath 行的地方:

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
}

我做錯了什麼?請幫忙。

PS:它適用於 Analytics 示例。


參考解法

方法 1:

Your close you need to apply the android plugin first then apply the google‑services plugin. Then configure your android model in the closure

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:

Finally found the problem!

I needed to do a Clean build and Rebuild. That was all!

(by Z0qJBirdVegasZ0q)

參考文件

  1. Cannot resolve symbol 'android' ‑ While implementing Google Analytics in Android App with libgdx (CC BY‑SA 2.5/3.0/4.0)

#libgdx #java #android-studio #Android #google-analytics






相關問題

為什麼原生 libmpg123 在帶有 libgdx 的 android 上花費這麼長時間? (Why is native libmpg123 taking so long on android with libgdx?)

睡眠後重新加載應用程序 (Re-load the app after sleep)

獲取實際觸摸位置 LibGDX (Get actual touch position LibGDX)

LibGDX - 只有可拖動的運動 (LibGDX - only draggable movement)

無法解析符號“android” - 在使用 libgdx 在 Android 應用程序中實現 Google Analytics 時 (Cannot resolve symbol 'android' - While implementing Google Analytics in Android App with libgdx)

如何從矩形數組中刪除隨機矩形? (How to remove random rectangle from rectangle array?)

球在傾斜平面上滾動 java libgdx (Ball rolling on an incline plane java libgdx)

libgdx - Intellij 類未找到異常? (libgdx - Intellij class not found exception?)

GL_COLOR_BUFFER_BIT 再生哪個內存? (GL_COLOR_BUFFER_BIT regenerating which memory?)

libGDX - 更改屏幕後的黑色按鈕和文本 (libGDX - Black buttons and text after changing screen)

帶有 9patch 的 LibGdx 標籤背景 (LibGdx label background with 9patch)

如何從平鋪中刪除對象? (How do I remove an object from tiled?)







留言討論