問題描述
無法解析符號“android” ‑ 在使用 libgdx 在 Android 應用程序中實現 Google Analytics 時 (Cannot resolve symbol 'android' ‑ While implementing Google Analytics in Android App with libgdx)
我正在嘗試遵循 本教程並導入分析跟踪器。我花了幾個小時,但仍然沒有運氣。
我不斷收到以下錯誤:
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 Z0q、JBirdVegas、Z0q)