Android Studio - Include ResourceBundles in Module

前端 未结 4 535
陌清茗
陌清茗 2020-12-20 19:35

I currently switched from eclipse to android studio. In eclipse I had 2 projects, one android application project and one java project which I included in the android projec

4条回答
  •  遥遥无期
    2020-12-20 20:07

    If you include the second project as a library, you might not want to create a new resource folder as suggested in a previous answer (which does work). Instead, you can simply add the library's resource folder to your resource directories in your module's build.gradle: to the android section add

    sourceSets {
        main.resources.srcDirs += 'path/to/your/libs/res'
    }
    

    If now the added res folder contains org/mypackage/Bundle.properties you can refer to it using

    ResourceBundle.getBundle("org.mypackage.Bundle")
    

    Actually adding a new resource folder does nothing more then adding it as a resource directory in build.gradle.

提交回复
热议问题