1

I get the 110 errors when Gradle is building the app.

Error:(91, 23) error: package com.google.gson does not exist
Error:(94, 31) error: package com.google.gson.reflect does not exist  
Error:(94, 31) error: package com.google.gson.... does not exist
...

It then tells me that this comes from the imports at my different activities, for example:

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

This is in my build.gradle which worked perfectly before the Studio update:

android {
  compileSdkVersion 23
  buildToolsVersion '23.0.3'

  defaultConfig {
    applicationId "xxxx.xxx"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode #
    versionName "#.#"
  }

  buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}
dependencies {
   //...
   compile files('C:/Users/Kaspar/StudioProjects/maakler.ee-app/libs/gson-2.7-sources.jar')
}

I also tried these versions which all gave the same result

compile fileTree(dir: 'libs', include: 'gson-2.7-sources.jar')
compile files('libs/gson-2.2.4-sources.jar')

The IDE does not give any warnings when I write the code. It only throws the error on Gradle build.

This all started after Android Studio update and I have no idea how to get this to work.

Fantini
  • 2,067
  • 21
  • 32
KasparTr
  • 2,328
  • 5
  • 26
  • 55
  • remove all third party gson libs and use one from Maven with Android Studio - > Project Structure -> depenecdies and search gson there. – Itzik Samara Aug 20 '16 at 18:54
  • have a look at this question here http://stackoverflow.com/questions/17913704/android-gradle-cannot-find-symbol-class-gson – Sandeep Londhe Aug 20 '16 at 18:55
  • @ItzikSamara thanks it worked! Don't understand why jars wont work but your solution did. – KasparTr Aug 20 '16 at 19:00
  • Did you try like : dependencies { compile 'com.google.code.gson:gson:2.3.1' } – Md Sufi Khan Aug 20 '16 at 19:05
  • I added the dependency from under Project Structure and then compile 'com.google.code.gson:gson:2.7' was added automatically under build.gradle. – KasparTr Aug 21 '16 at 11:18

0 Answers0