我刚刚完成了我的项目并且工作正常但是当我决定通过android studio firebase助手将Firebase集成到它时项目没有同步,我得到这些错误,我似乎无法弄清楚该做什么我在下面列出了我的所有gradle文件。我已经在网上尝试了所有可能的答案,但事先似乎没有任何效果
**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'.
编译失败;有关详细信息,请参阅编译器错误输出。
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"
}
}
dodge build.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"
}
答案 0 :(得分:0)
版本:7.8.0低于所需的最低版本(9.0.0)
该错误很简单,您至少需要9.0.0
错误:(32,39)错误:包
com.google.android.gms.appstate
不存在
错误:(293,28)错误:找不到符号变量AppStateManager
错误:(294,30)错误:找不到符号变量AppStateManager
有AppState
,但没有AppState 经理
如果你编译这个
compile "com.google.android.gms:play-services-games:10.0.1"
事实上,这个包确实存在。
com.google.android.gms.appstate
但是,如果您打开该链接,则AppStateManager
根本不存在。因此,我认为您已经复制并使用了一些旧的或AppStateManager
是您未能从其他地方包含的类的代码。
同样,当您
时,此包存在compile "com.google.android.gms:play-services-ads:10.0.1"
如果我们在Google games Github samples上看到,此评论就证实了我的答案。
Appstate API在7.8
之后消失了
答案 1 :(得分:0)
在android build.gradle文件中添加compile 'com.google.android.gms:play-services-ads:10.0.1'
作为依赖项。
答案 2 :(得分:0)
我遇到了同样的问题,如果你尝试添加Fire base我会得到相同的错误,BasicGamesUtil是针对'8.4.0编译的。遗憾的是,我根本无法添加Fire base,并将使用较旧的Play Service Analytics。 Base Game Utils不会针对较新的Play服务进行编译,已经尝试了各种方法来编译它,当我这样做时,我会像你一样丢失项目。