【问题标题】:error: strings in switch are not supported in -source 1.6 (use -source 7 or higher to enable strings in switch) in Android Studio错误:Android Studio 中的 -source 1.6 不支持 switch 中的字符串(使用 -source 7 或更高版本来启用 switch 中的字符串)
【发布时间】:2015-08-25 17:16:25
【问题描述】:

我在 Eclipse 中创建了一个项目,但现在我正在将该项目转换为 android studio 项目。但是当我尝试运行转换后的项目时,我在 android studio 的 Messeges 选项卡中收到“错误:-source 1.6 中不支持开关中的字符串(使用 -source 7 或更高版本来启用开关中的字符串)”

我的 build.gradle 文件

apply plugin: 'com.android.application'

android {
compileSdkVersion 19
buildToolsVersion "23.0.0"

defaultConfig {
    applicationId "com.pcs.sliderringtineproj"
    minSdkVersion 10
    targetSdkVersion 19

}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-rules.txt'
    }

}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dependencies {
compile project(':facebookSDK')
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:appcompat-v7:20.+'
compile files('libs/acra-4.5.0.jar')
compile files('libs/aspectjrt-1.7.3.jar')
compile files('libs/commons-io-2.4.jar')
compile files('libs/fmmr.jar')
compile files('libs/isoparser-1.0.1.jar')
compile files('libs/libGoogleAnalytics.jar')
compile files('libs/log4j-1.2.15.jar')
compile files('libs/picasso-2.4.0.jar')
compile files('libs/universal-image-loader-1.9.0.jar')
}

【问题讨论】:

    标签: android eclipse android-studio


    【解决方案1】:

    打开应用程序模块的 build.gradle 文件并将以下内容添加到名为 android 的部分:

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    

    【讨论】:

    • 先生,我已经尝试过了,但它显示无法解析符号 sourceCompatibility,同样警告 targetCompatibility
    • @SritamJagadev 发布您的 build.gradle 文件的内容。
    • 还有一个问题:您使用的是哪个版本的 Android Studio?
    • 我使用的是android studio 1.0.1版
    猜你喜欢
    • 1970-01-01
    • 2020-04-12
    • 2014-09-28
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 2014-05-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多