Android Studio: underscores in literals are not supported error

和自甴很熟 提交于 2019-12-24 19:18:18

问题


I have a problem with the drawable class in R.java file. I had drawable hdpi, mdpi, xhdpi... folders in main/res, but drawable was missing so i created it by hand. Main.xml is able to find the image declared but this code in R.java gives an error:

    public static final class drawable {
    public static final int 10_device_access_accounts=0x7f020000;
    public static final int 10_device_access_add_alarm=0x7f020001;
    public static final int 10_device_access_alarms=0x7f020002;
    public static final int 10_device_access_battery=0x7f020003;
    public static final int 10_device_access_bightness_low=0x7f020004;
    public static final int 10_device_access_bluetooth=0x7f020005;
    public static final int 10_device_access_bluetooth_connected=0x7f020006;
    public static final int 10_device_access_bluetooth_searching=0x7f020007;
    public static final int 10_device_access_brightness_auto=0x7f020008;
    ...}

When compiled gives out an error: Gradle: error: underscores in literals are not supported in -source 1.6 (use -source 7 or higher to enable underscores in literals)

I'm using android studio version 1.0.0.1 and jdk 1.7.0.250 version, i have PATH variable pointing to %JAVA_HOME%\bin and CLASSPATH pointing to %JAVA_HOME%\lib


回答1:


removing the "10_" at the beginning of your files can fix the issue. For the reason why you can't have a resource with a numeric name, read this . If theses drawable ressources are icons, you can use the common naming conventions that you can read here, and begin your icons by "ic_" or "ic_menu" if this is Menu icons and Action Bar icons.



来源:https://stackoverflow.com/questions/18702958/android-studio-underscores-in-literals-are-not-supported-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!