【发布时间】:2018-12-16 11:09:50
【问题描述】:
简介
我有一个应用程序,我目前开始处理一些后端代码。为了防止代码重复,我想将我的一些代码移动到库中。
这就是我所做的:
- 我为我的库创建了一个 jar 文件,使用 IntelliJ IDEA (Project 结构 - 人工制品 - 等)
- 我将 jar 文件复制到我的 Android 应用程序的 lib 文件夹中
- 我包含了依赖项(在
build.gradle中我放了implementation files('libs/numbers-lib.jar'))
问题
现在,当我尝试使用其中一个类时,我得到了Cannot resolve symbol 'Level'(另见屏幕截图)。我错过了什么?
编辑:我已经清理/重建了我的项目并使缓存失效。
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')
}
【问题讨论】:
-
@DKV:我唯一没有做的就是右键单击并单击添加为库。但是,我的 Android Studio 版本(版本 3.2.1)中没有该选项
-
可以显示你的gradle文件
-
@ZaidMirza:添加了 gradle 文件。