android 消费者抛出未找到 class 定义
android consumer throws no class definintion found
我在 new android studio 2.3 项目中有以下代码。我有 1.8 和 jack 启用(见下面的构建文件)。这是我添加的唯一代码:
Consumer<Integer> consumer=new Consumer<Integer>() { // throws here a: java.lang.NoClassDefFoundError: acme.consumer.MainActivity
@Override
public void accept(Integer integer) {
System.out.println("integer: "+integer);
}
};
consumer.accept(1);
这似乎应该可行。有人有什么想法吗?
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "acme.cb2"
minSdkVersion 22
targetSdkVersion 25
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
dexOptions {
javaMaxHeapSize "4G"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
}
Consumer 是在 API 24 年引入的 - 你有 minSdkVersion 22
我在 new android studio 2.3 项目中有以下代码。我有 1.8 和 jack 启用(见下面的构建文件)。这是我添加的唯一代码:
Consumer<Integer> consumer=new Consumer<Integer>() { // throws here a: java.lang.NoClassDefFoundError: acme.consumer.MainActivity
@Override
public void accept(Integer integer) {
System.out.println("integer: "+integer);
}
};
consumer.accept(1);
这似乎应该可行。有人有什么想法吗?
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "acme.cb2"
minSdkVersion 22
targetSdkVersion 25
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
dexOptions {
javaMaxHeapSize "4G"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
}
Consumer 是在 API 24 年引入的 - 你有 minSdkVersion 22