尝试在 Android Studio 中添加 Crashlytics(找不到方法...)
Trying to add Crashlytics in Android Studio (could not find method...)
我尝试将 Crashlytics 添加到我的项目中,但 Gradle 同步效果不佳。
This is my build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// These docs use an open ended version so that our plugin
// can be updated quickly in response to Android tooling updates
// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1.26.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.smartvibes.smartbeat"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.volley:volley:1.1.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.squareup.okhttp3:okhttp:3.4.1'
implementation 'com.squareup.okio:okio:1.7.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.4.0'
implementation 'org.osmdroid:osmdroid-android:6.0.3'
implementation 'io.nlopez.smartlocation:library:3.3.3'
implementation 'io.nlopez.smartlocation:rx:3.3.3'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'com.github.MikeOrtiz:TouchImageView:1.4.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.jakewharton.rxbinding:rxbinding:0.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9@aar' {
transitive = true;
}
}
这是我在清单中添加的内容:
<meta-data
android:name="io.fabric.ApiKey"
android:value="my key"
/>
我手动改的
compile ('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
transitive = true;
}
到
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9@aar' {
transitive = true;
}
因为编译不支持了
我尝试同步时出现的错误是:
错误:无法在 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象上找到参数 [build_ebny41u4h7onhh3ybv447hi4b$_run_closure3$_closure8@7d0b1f54] 的方法 com.crashlytics.sdk.android:crashlytics:2.9.9@aar()。
打开文件
我用 Google 搜索了这个问题,但找不到合适的解决方案。
有人知道如何处理吗?
你快到了。只需要用 ( ) 来写这个:
implementation ('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
transitive = true;
}
我尝试将 Crashlytics 添加到我的项目中,但 Gradle 同步效果不佳。
This is my build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// These docs use an open ended version so that our plugin
// can be updated quickly in response to Android tooling updates
// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1.26.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.smartvibes.smartbeat"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.volley:volley:1.1.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.squareup.okhttp3:okhttp:3.4.1'
implementation 'com.squareup.okio:okio:1.7.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.4.0'
implementation 'org.osmdroid:osmdroid-android:6.0.3'
implementation 'io.nlopez.smartlocation:library:3.3.3'
implementation 'io.nlopez.smartlocation:rx:3.3.3'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'com.github.MikeOrtiz:TouchImageView:1.4.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.jakewharton.rxbinding:rxbinding:0.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9@aar' {
transitive = true;
}
}
这是我在清单中添加的内容:
<meta-data
android:name="io.fabric.ApiKey"
android:value="my key"
/>
我手动改的
compile ('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
transitive = true;
}
到
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9@aar' {
transitive = true;
}
因为编译不支持了
我尝试同步时出现的错误是: 错误:无法在 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象上找到参数 [build_ebny41u4h7onhh3ybv447hi4b$_run_closure3$_closure8@7d0b1f54] 的方法 com.crashlytics.sdk.android:crashlytics:2.9.9@aar()。 打开文件
我用 Google 搜索了这个问题,但找不到合适的解决方案。 有人知道如何处理吗?
你快到了。只需要用 ( ) 来写这个:
implementation ('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
transitive = true;
}