我剛完成我的項目並且工作正常,但是當我決定通過android studios firebase助手集成Firebase時,項目不同步,我得到這些錯誤和I似乎無法弄清楚該怎麼做,我已經列出了下面的所有我的gradle文件。我曾嘗試在網絡上每一個可能的答案,但似乎沒有任何提前添加Firebase後,libGDX項目未建立(Android Studio)
**ERROR'S**
Error:(23, 34) error: package com.google.android.gms.ads does not exist
Error:(24, 34) error: package com.google.android.gms.ads does not exist
Error:(25, 34) error: package com.google.android.gms.ads does not exist
Error:(26, 34) error: package com.google.android.gms.ads does not exist
Error:(27, 34) error: package com.google.android.gms.ads does not exist
Error:(56, 15) error: cannot find symbol class AdView
Error:(58, 5) error: cannot find symbol class AdView
Error:(59, 13) error: cannot find symbol class InterstitialAd
Error:(343, 13) error: cannot find symbol class AdView
Error:(373, 35) error: cannot find symbol class AdView
Error:(129, 30) error: cannot find symbol class InterstitialAd
Error:(131, 42) error: cannot find symbol class AdListener
Error:(344, 22) error: cannot find symbol class AdView
Error:(345, 26) error: cannot find symbol variable AdSize
Error:(374, 9) error: cannot find symbol class AdRequest
Error:(374, 44) error: package AdRequest does not exist
Error:(425, 29) error: cannot find symbol class AdRequest
Error:(425, 74) error: package AdRequest does not exist
Error:Execution failed for task ':android:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
的Android gradle這個工作的感謝
android {
buildToolsVersion '23.0.3'
compileSdkVersion 23
defaultConfig {
minSdkVersion 9
targetSdkVersion 25
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4G"
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
instrumentTest.setRoot('tests')
}
}/*
// needed to add JNI shared libraries to APK when compiling on CLI
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
pkgTask.jniFolders = new HashSet<File>()
pkgTask.jniFolders.add(new File(projectDir, 'libs'))
}*/
// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/x86/").mkdirs();
configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.buzz.dodge/AndroidLauncher'
}
// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
// need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin
// ignores any nodes added in classpath.file.withXml
sourceSets {
main {
java.srcDirs "src", 'gen'
}
}
classpath {
plusConfigurations += [project.configurations.compile]
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
}
project {
name = appName + "-android"
natures 'com.android.ide.eclipse.adt.AndroidNature'
buildCommands.clear();
buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
buildCommand "org.eclipse.jdt.core.javabuilder"
buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
}
}
// sets up the Android Idea project, using the old Ant based build.
idea {
module {
sourceDirs += file("src");
scopes = [COMPILE: [plus: [project.configurations.compile]]]
iml {
withXml {
def node = it.asNode()
def builder = NodeBuilder.newInstance();
builder.current = node;
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value: "true")
}
}
}
}
}
}
}
dependencies {
compile 'com.google.android.gms:play-services-analytics:10.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
BaseGameUtils的build.gradle
apply plugin: 'com.android.library'
repositories {
mavenCentral()
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile "com.google.android.gms:play-services-games:10.0.1"
compile "com.google.android.gms:play-services-plus:10.0.1"
compile 'com.android.support:multidex:1.0.1'
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 9
targetSdkVersion 22
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4G"
}
}
躲閃建設。 gradle
buildscript {
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = 'Smove'
gdxVersion = '1.5.6'
roboVMVersion = '1.0.0'
box2DLightsVersion = '1.3'
ashleyVersion = '1.3.1'
aiVersion = '1.5.0'
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile fileTree(dir: '../libs', include: '*.jar')
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
compile project(":BaseGameUtils")
compile fileTree(dir: '../libs', include: '*.jar')
}
}
tasks.eclipse.doLast {
delete ".project"
}
評論是不適合擴展討論;這個對話已經[轉移到聊天](http://chat.stackoverflow.com/rooms/136826/discussion-on-question-by-l-kohli-libgdx-project-not-building-after-adding-fireb) 。 –