我已将我的 android 应用配置为使用 java 8,如下所示
那么为什么我不能使用 java.util.regex.Pattern
例如Pattern.UNICODE_CHARACTER_CLASS
private static final Pattern PATTERN = Pattern.compile("[\\p{Punct}']", Pattern.UNICODE_CHARACTER_CLASS);
这是我的 Gradle 文件。
apply plugin: 'com.android.application'
android {
compileSdkVersion = "android-N"
buildToolsVersion = "24.0.0 rc4"
defaultConfig {
applicationId "com.software.crucifix.my.app"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
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:23.4.0'
}
最佳答案
此常量不是 Android SDK (Android - Pattern) 的一部分。好像会加在API level N里面但如描述中所述,对 Android 没有影响。
This flag has no effect on Android, unicode character classes are always used.
关于java - 为什么我不能在我的 Android 应用程序中使用 Pattern.UNICODE_CHARACTER_CLASS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37482787/