亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法解析符號 gson

無法解析符號 gson

翻閱古今 2021-08-25 16:17:42
我在使用 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 但這無濟于事。
查看完整描述

2 回答

?
浮云間

TA貢獻1829條經驗 獲得超4個贊

compile已經過時了。請用implementation


implementation 'com.google.code.gson:gson:2.8.5'


您在項目級build.gradle 中需要這些


buildscript {


repositories {

    google()

    jcenter()

}


.....

allprojects {

    repositories {

        google()

        jcenter()

    }

}


查看完整回答
反對 回復 2021-08-25
?
慕桂英546537

TA貢獻1848條經驗 獲得超10個贊

嘗試將所有存儲庫編寫在一起,并使用已包含在 Google 依賴項和 jcenter 中的函數,而不是提供 URL。像這樣:


buildscript {

...

    repositories {

        google()

        jcenter()

    }

}

并且:


allprojects {

    repositories {

        google()

        jcenter()

    }

}

開始使用implementation標簽而不是compile在 gradle 中也很重要,因為它已被棄用:


implementation 'com.google.code.gson:gson:2.8.5'


查看完整回答
反對 回復 2021-08-25
  • 2 回答
  • 0 關注
  • 548 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號