我尝试将Firebase Analytics与我的应用程序集成,并且根据入门指南进行了所有操作。我失败了,所以我尝试在虚拟应用程序上执行此操作-Android Studio中自动生成的示例-仍然是同样的问题:
E/FA: Invalid google_app_id. Firebase Analytics disabled. See "shortened_link". provided id: XXXXX:android:XXXXX
E/FA: Uploading is not possible. App measurement disabled
“ shortened_link_that_can't_be_posted_to_SO”将您带到https://firebase.google.com/docs/android/setup,这不是很有帮助。
在构建应用时,我还会不断看到该警告:
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
我的环境:
Android Studio 3.5
Build #AI-191.8026.42.35.5791312, built on August 9, 2019
JRE: 1.8.0_202-release-1483-b49-5587405 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.6
我的gradle版本是5.4.1,我尝试同时在Android Studio和命令行以及模拟器和物理设备上运行-在物理设备上我什至无法运行,因为以前的一些剩余数据出错安装(即使没有安装)。 AS要求卸载应用->我批准->安装仍然失败。
我想这是某些东西的最新版本引起的,但是令人惊讶的是,要降级某些使用的库并不是那么容易。如果您知道该如何解决,请告诉我。
问题描述的结尾,下面仅是我从Firebase安装指南中执行的步骤,以证明我正确执行了所有操作
我之前做了几次,我对所有内容进行了三重检查,这是我的项目级build.gradle
:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
和应用级build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.firebase.test"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.firebase:firebase-analytics:17.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
apply plugin: 'com.google.gms.google-services'
在Firebase控制台中,我添加了带有“ com.firebase.test”软件包的Android应用,下载了google-services.json
并将其放入app /目录。