为什么在尝试使用库中的 class 时得到 "Cannot resolve symbol"?

Why do I get "Cannot resolve symbol" when trying to use class from library?

简介

我有一个应用程序,目前我开始使用一些后端代码。为了防止代码重复,我想把我的一些代码移到一个库中。

这是我做的:

问题

现在,当我尝试使用 类 之一时,我得到 Cannot resolve symbol 'Level'(另请参见屏幕截图)。我错过了什么?

编辑: 我已经 cleaned/rebuilt 我的项目和无效缓存。

EDIT2: 这是我的gradle(根据要求)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.my.example"
        minSdkVersion 21
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        targetSdkVersion 27
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'junit:junit:4.12'
    implementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    implementation 'postgresql:postgresql:9.0-801.jdbc4'
    implementation files('libs/numbers-lib.jar')
}

EDIT3: 这是截图。你可以看到图书馆有正确的 Class...

将您的 lib jar 文件放入 app/libs,在您的项目 gradle 文件中将此行附加到依赖项:

compile fileTree(dir: 'libs', include: ['*.jar'])

改变

implementation fileTree(include: ['*.jar'], dir: 'libs')

implementation fileTree(dir: 'libs', include: ['*.jar'])

并且不要忘记将您的 jar 放在 libs 文件夹中。

原来我必须在创建库之前将库 类 放入包中。