为什么我不能在我的Android应用程序中使用Pattern.UNICODE_CHARACTER_CLASS?

时间:2016-05-27 11:50:04

标签: java android

我已将我的Android应用配置为使用java 8,如下所示

那么为什么我不能使用java.util.regex.Pattern

中的常量

e.g。 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'
}

1 个答案:

答案 0 :(得分:3)

此常量不是Android SDK(Android - Pattern)的一部分。它似乎会添加到API level N中,但对说明中所述的Android没有任何影响。

  

此标志对Android无效,始终使用unicode字符类。