无法初始化 ACRA。方法 getPluginConfigurationBuilder 未找到



大家好!我正在尝试在我的Android项目中使用ACRA。我遵循了ACRA设置的建议。我的app.java文件与ACRA安装程序上的文件几乎相同,但安卓工作室仍然显示找不到方法生成器.getPluginConfigurationBuilder()。我已经尝试过很多次清洁/同步渐变/构建。我已经升级到AS、AGP和Gradle的最新版本,但没有成功。请帮忙。PS。不久前,我在另一个项目中使用了ACRA的earlear版本,与ADT一起使用,没有任何问题。

ACRA版本:5.9.3(与5.9.1相同)AS版本:大黄蜂2021.1.1补丁2Gradle版本:7.2AGP版本:7.1.2

这是我模块的构建。gradle

apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.all.someapp"
minSdkVersion 19
targetSdkVersion 29
versionCode 2
versionName "1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions.encoding = 'windows-1251'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//    implementation files('libs/acra-dialog-5.9.1-javadoc.jar')
//    implementation files('libs/acra-mail-5.9.1-javadoc.jar')
//    implementation files('libs/acra-core-5.9.1-javadoc.jar')
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.preference:preference:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
implementation 'androidx.activity:activity:1.2.0'
implementation "androidx.fragment:fragment:1.3.0"
implementation "androidx.recyclerview:recyclerview:1.2.0"
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
def acraVersion = '5.9.1'
implementation "ch.acra:acra-core:$acraVersion"
implementation "ch.acra:acra-mail:$acraVersion"
implementation "ch.acra:acra-dialog:$acraVersion"
annotationProcessor 'com.google.auto.service:auto-service:1.0.1'
compileOnly 'com.google.auto.service:auto-service-annotations:1.0.1'

// TEST
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
}

项目的构建.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
//maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

app.java(我的应用程序的主要模块名称是"app"):

import android.app.Application;
import android.content.Context;
import org.acra.ACRA;
import org.acra.config.CoreConfigurationBuilder;
import org.acra.config.MailSenderConfigurationBuilder;
import org.acra.data.StringFormat;
import org.acra.mail.BuildConfig;
public class app extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
CoreConfigurationBuilder builder = new CoreConfigurationBuilder();
//core configuration:
builder
.withBuildConfigClass(BuildConfig.class)
.withReportFormat(StringFormat.JSON);
//each plugin you chose above can be configured with its builder like this:
// !!!============= THIS METHOD CANNOT BE RESOLVED===============!
builder.getPluginConfigurationBuilder(MailSenderConfigurationBuilder.class)

//make sure to enable all plugins you want to use:
.withEnabled(true);
ACRA.init(this, builder);
}
}

您的代码适用于ACRA 5.8。Java:的配置在5.9中略有变化

ACRA.init(this, new CoreConfigurationBuilder()
//core configuration:
.withBuildConfigClass(BuildConfig.class)
.withReportFormat(StringFormat.JSON)
.withPluginConfigurations(
//each plugin you chose above can be configured with its builder like this:
new ToastConfigurationBuilder()
.withResText(R.string.acra_toast_text)
.build()
)
);

我还继续更新了反映变化的文档

相关内容

  • 没有找到相关文章

最新更新