作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
简介
我有一个应用程序,目前我开始使用一些后端代码。为了防止代码重复,我想将一些代码移到库中。
这就是我所做的:
build.gradle
中,我将 implementation
文件('libs/numbers-lib.jar')
)问题
现在,当我尝试使用其中一个类时,我得到无法解析符号“Level”
(另请参阅屏幕截图)。我缺少什么?
编辑:我已经清理/重建了我的项目并使缓存无效。
编辑2:这是我的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')
}
最佳答案
将你的 lib jar 文件放在 app/libs 中,在你的项目 gradle 文件中将此行附加到依赖项中:
compile fileTree(dir: 'libs', include: ['*.jar'])
关于java - 为什么我在尝试使用库中的类时收到 "Cannot resolve symbol"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53801580/
我是一名优秀的程序员,十分优秀!