意想不到的字母' \'的build.gradle

时间:2017-01-02 09:48:14

标签: android eclipse android-studio

我最近将我的Eclipse项目导入Studio。我通过Eclipse的gradle导出导出它。导入后我收到此错误。

Error:(16, 0) Cause: startup failed:
build file 'D:\Android\Projects\MainDIr\Project\build.gradle': 16: unexpected char: '\' @ line 16, column 34.
               java.srcDirs = ['libs\ormlite-android','libs\ormlite-core','src']
                                    ^

1 error

build.gradle中的4行被标记为红色。这些是引用libs文件夹库路径。我的所有库都已成功导入。

main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['libs\ormlite-android','libs\ormlite-core','src']
            resources.srcDirs = ['libs\ormlite-android','libs\ormlite-core','src']
            aidl.srcDirs = ['libs\ormlite-android','libs\ormlite-core','src']
            renderscript.srcDirs = ['libs\ormlite-android','libs\ormlite-core','src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

3 个答案:

答案 0 :(得分:5)

  

意外的字符' \'

添加/代替\。然后清理重建运行

示例

 aidl.srcDirs =  ['libs/ormlite-android','libs/ormlite-core','src']

答案 1 :(得分:1)

使用双反斜杠\\来转义反斜杠

main {
    manifest.srcFile 'AndroidManifest.xml'
    java.srcDirs = ['libs\\ormlite-android','libs\\ormlite-core','src']
    resources.srcDirs = ['libs\\ormlite-android','libs\\ormlite-core','src']
    aidl.srcDirs = ['libs\\ormlite-android','libs\\ormlite-core','src']
    renderscript.srcDirs = ['libs\\ormlite-android','libs\\ormlite-core','src']
    res.srcDirs = ['res']
    assets.srcDirs = ['assets']
}

答案 2 :(得分:0)

enter image description here

使用此方法可以解决此问题。