levibostian / levibostian/dotenv-android

Plugin does not work with library build, error: cannot find symbol Env

Open
#28 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
19
Forks
3
PR merge metrics
No merged PRs in 30d

Description

I've been using this plugin successfully before, but now I cannot get it to work on a new project.

In this project I am building an Android library that should use dotenv for configuration (in the subfolder library) , as well as a demo application that uses the library (app).

In my library/build.gradle I have:

plugins {
    id 'com.android.library'
    id 'maven-publish'
    id "earth.levi.dotenv-android" version "1.3.0"
}

dotenv {
    packageName = "com.example.library"
    sourcePath = "src/main/java/"
}

With my main code at ./library/src/main/java/com/example/library/Foo.java, which contains a reference to Env.foo.

In .env, I have:

FOO=bar

In my ./settings.gradle, I have:

// ...
rootProject.name = "library"
include ':app'
include ':library'

Now when I run:

./gradlew build

I get:

> Task :library:compileDebugJavaWithJavac FAILED
/testproject/library/src/main/java/com/example/library/Foo.java:711: error: cannot find symbol
            mFoo = Env.foo;
                       ^
  symbol:   variable Env
  location: class Builder

...

FAILURE: Build failed with an exception.

I also do not see any tasks related to dotenv when I run ./gradlew tasks.

Any idea why this would not work?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with library/build.gradle and the dotenv plugin configuration, then run ./gradlew tasks and ./gradlew build to compare the library module's tasks and compilation output. Check whether Env is generated under library/src/main/java/com/example/library and whether the library compile task sees it; done means the library builds with Foo.java resolving Env and the expected dotenv task is present.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, kotlin
Domain
build-system, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.