我在使用 gson 库时遇到了大麻烦。在构建项目时,我得到:
“无法解析符号gson”
我用谷歌搜索了几个小时,但似乎没有解决方案。这是我的 build.gradle 文件:
android {
compileSdkVersion 24
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "com.example.jasminkrhan.vaktija"
minSdkVersion 24
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.google.code.gson:gson:2.8.2'
}
还有我的 build.gradle 项目文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
repositories {
maven {
url "http://repo1.maven.org/maven2"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
repositories {
maven {
url "http://repo1.maven.org/maven2"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
有人发现我的代码有问题吗?为什么android studio找不到库?我已经尝试重新启动 Android Studio 但这无济于事。
浮云间
慕桂英546537
相关分类