How to access .java files from a directory outside

2019-09-04 07:13发布

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

project 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条回答
三岁会撩人
2楼-- · 2019-09-04 08:00

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')
}
查看更多
登录 后发表回答