在我的项目中,我使用了流行的库retrolambda。我刚刚下载了新的AndroidStudio3.0金丝雀1。
我已经更新了我的项目,使用新版本的Gradle等,一切都很好。
Android 3中的新功能是为了支持一些Java8特性而构建的。新的AS3建议删除retrolambda并使用这些特性。

我已经删除了retrolambda,Gradle构建是成功的,但是应用程序由于这个错误而崩溃了(在有lambda的地方)
E/UncaughtException: java.lang.NoSuchMethodError: No static method lambda$replace$2我在我的项目中使用RxJava2。我不确定这是否与它有关,但在我的例子中,Java8的内置特性不起作用。也许我需要在“某个地方”放点东西?
我的项目设置

我的分级文件
根工程
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
classpath 'com.google.gms:google-services:3.0.0'
//classpath 'me.tatarka:gradle-retrolambda:3.6.1'
}App模块
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
}
}
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.hugo'
...
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-analytics:9.8.+'
compile 'com.google.firebase:firebase-crash:9.8.+'
compile 'com.google.android.gms:play-services-maps:9.8.+'
compile 'com.google.android.gms:play-services-analytics:9.8.+'
compile 'com.google.android.gms:play-services-auth:9.8.+'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
//Support Library
(...)
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile 'com.google.maps.android:android-maps-utils:0.4'
/* RXJAVA2 */
compile 'io.reactivex.rxjava2:rxjava:2.0.6'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
compile 'com.github.VictorAlbertos:ReactiveCache:1.1.0-2.x'
compile 'com.github.VictorAlbertos.Jolyglot:gson:0.0.3'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "my_app_id"
minSdkVersion 15
targetSdkVersion 25
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
(...)
dexOptions {
javaMaxHeapSize "4g"
}
lintOptions {
abortOnError false
}
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
}
debugpro {
minifyEnabled true
shrinkResources false
proguardFile file('proguard-project.txt')
proguardFile file('proguard-google-api-client.txt')
//noinspection GroovyAssignabilityCheck
signingConfig signingConfigs.debug
}
release {
minifyEnabled true
shrinkResources false
proguardFile file('proguard-project.txt')
proguardFile file('proguard-google-api-client.txt')
}
releaseci {
minifyEnabled true
shrinkResources false
proguardFile file('proguard-project.txt')
proguardFile file('proguard-google-api-client.txt')
//noinspection GroovyAssignabilityCheck
signingConfig signingConfigs.releaseci
}
(...)
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.jakewharton.butterknife'发布于 2017-07-06 14:10:06
这可能是由于在https://issuetracker.google.com/issues/62456849中跟踪的Gradle Java 8语言特性中的一个bug造成的。
desugar似乎盲目地重命名了类文件中的合成方法,如果它们的名称以lambda$ (追加所有者类名)开头,而不管字节码中是否已经存在对该方法的引用(并且引用也不会被重命名)。
当代码路径在运行时碰到这样的引用时,明显的结果是一个NoSuchMethodError,因为这个名称的方法已经不存在了。
https://stackoverflow.com/questions/44068347
复制相似问题