How to access .java files from a directory outside of a package in android-studio?

一个人想着一个人 提交于 2019-12-12 04:56:16

问题


I try to solve this problem for hours now and didn't find a solution on the internet. my project looks like this:

I want to access the files in the marked directory in the de.MayerhoferSimon.Vertretungsplan package. (yes, I know packages should be lowercase.)

Is this possible and when yes, how?

I tried some things with the dependencies in the .gradle file of the :app module but nothing worked.


回答1:


In this case you should create a library module for your webuntisaccessor code instead of putting this in the libs folder.

root
  settings.gradle
  app
    build.gradle
  webuntisaccessor
    src
      main    
        java
    build.gradle

In settings.gradle:

include ':webuntisaccessor' , ':app'

In webuntisaccessor/build.gradle

apply plugin: 'com.android.library'

In app/build.gradle add:

dependencies {
    compile project(':webuntisaccessor')
}


来源:https://stackoverflow.com/questions/28681353/how-to-access-java-files-from-a-directory-outside-of-a-package-in-android-studi

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