4

I am in the process of porting a project from Eclipse to the latest Android Studio. All went fine by copying all the files in the directory used by AS but I get a host of errors practically on all the libraries I use and the imports from my own project: what may be the problem? This is the list of errors: (of course the unfound symbols are fine and kicking in the project).

/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/LoginActivity.java
Error:(10, 30) error: package com.google.android.gcm does not exist
Error:(29, 73) error: interface expected here
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/NearStatus.java
Error:(8, 33) error: cannot find symbol class BookingStatus
Error:(8, 58) error: cannot find symbol class UrlConnectionDelegate
Error:(10, 17) error: cannot find symbol class BookingStatus
Error:(11, 2) error: cannot find symbol class Dashboard
Error:(13, 16) error: cannot find symbol class BookingStatus
Error:(23, 12) error: cannot find symbol class BookingStatus
Error:(44, 12) error: cannot find symbol class Status
Error:(48, 2) error: cannot find symbol class BookingStatus
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/Reservation.java
Error:(38, 37) error: cannot find symbol class UrlConnectionDelegate
Error:(70, 10) error: cannot find symbol class Status
Error:(87, 9) error: cannot find symbol class Status
Error:(91, 31) error: cannot find symbol class Status
Error:(94, 2) error: cannot find symbol class Line
Error:(95, 2) error: cannot find symbol class Line
Error:(97, 13) error: cannot find symbol class SimpleGeofence
Error:(101, 13) error: cannot find symbol class SimpleGeofenceStore
Error:(343, 2) error: cannot find symbol class Status
Error:(366, 18) error: cannot find symbol class Status
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/ReservationManager.java
Error:(6, 9) error: cannot find symbol class Reservation
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/RunningStatus.java
Error:(18, 3) error: interface expected here
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/ServerUtilities.java
Error:(14, 43) error: cannot find symbol class CommonUtilities
Error:(14, 1) error: static import only from classes and interfaces
Error:(15, 43) error: cannot find symbol class CommonUtilities
Error:(15, 1) error: static import only from classes and interfaces
Error:(16, 43) error: cannot find symbol class CommonUtilities
Error:(16, 1) error: static import only from classes and interfaces
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/Taximeter.java
Error:(27, 62) error: interface expected here
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/AccountInformation.java
Error:(12, 58) error: interface expected here
Error:(182, 24) error: incompatible types: AccountInformation cannot be converted to UrlConnectionDelegate
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/BackgroundLocationService.java
Error:(42, 67) error: interface expected here
Error:(118, 22) error: incompatible types: BackgroundLocationService cannot be converted to UrlConnectionDelegate
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/DashboardActivity.java
Error:(5, 46) error: package com.example.taxiprofessional.Taximeter does not exist
Error:(45, 34) error: interface expected here
Error:(427, 3) error: cannot find symbol class Reservation
Error:(440, 4) error: cannot find symbol class Reservation
Error:(440, 34) error: cannot find symbol class Reservation
Error:(455, 22) error: incompatible types: DashboardActivity cannot be converted to UrlConnectionDelegate
Error:(462, 3) error: cannot find symbol class Reservation
Error:(462, 33) error: cannot find symbol class Reservation
Error:(487, 21) error: incompatible types: DashboardActivity cannot be converted to UrlConnectionDelegate
Error:(522, 3) error: cannot find symbol class Reservation
Error:(622, 2) error: method does not override or implement a method from a supertype
Error:(628, 2) error: method does not override or implement a method from a supertype
Error:(683, 66) error: cannot find symbol variable NearStatus
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/PollService.java
Error:(29, 53) error: interface expected here
Error:(60, 48) error: cannot find symbol class Dashboard
Error:(106, 27) error: incompatible types: PollService cannot be converted to UrlConnectionDelegate
Error:(101, 15) error: package Dashboard does not exist
Error:(123, 30) error: cannot find symbol variable Dashboard
Error:(130, 51) error: cannot find symbol class Dashboard
Error:(140, 21) error: package NotificationCompat does not exist
Error:(140, 62) error: package NotificationCompat does not exist
Error:(189, 64) error: cannot find symbol class Reservation
Error:(246, 69) error: cannot find symbol variable NearStatus
Error:(217, 14) error: package Dashboard does not exist
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/Line.java
Error:(117, 50) error: cannot find symbol variable Dashboard
Error:(143, 29) error: package Dashboard.dashboard does not exist
Error:(146, 28) error: package Dashboard.dashboard does not exist
Error:(161, 47) error: package Dashboard.dashboard does not exist
Error:(220, 34) error: package Dashboard does not exist
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/BusyStatus.java
Error:(12, 58) error: interface expected here
Error:(15, 2) error: cannot find symbol class Dashboard
Error:(15, 21) error: cannot find symbol variable Dashboard
Error:(39, 22) error: incompatible types: BusyStatus cannot be converted to UrlConnectionDelegate
Error:(93, 32) error: package Dashboard does not exist
Error:(85, 58) error: cannot find symbol variable Dashboard
Error:(86, 33) error: package Dashboard does not exist
Error:(106, 21) error: package Dashboard does not exist
Error:(106, 65) error: package Dashboard does not exist
Error:(110, 37) error: package Dashboard does not exist
Error:(119, 37) error: package Dashboard does not exist
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/ConfirmedLocalStatus.java
Error:(10, 3) error: cannot find symbol class Dashboard
Error:(10, 22) error: cannot find symbol variable Dashboard
Error:(43, 60) error: cannot find symbol variable NearStatus
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/ConfirmedRemoteStatus.java
Error:(9, 2) error: cannot find symbol class Dashboard
Error:(9, 21) error: cannot find symbol variable Dashboard
Error:(35, 3) error: cannot find symbol class Reservation
Error:(73, 59) error: cannot find symbol variable NearStatus
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/FreeStatus.java
Error:(7, 58) error: interface expected here
Error:(10, 2) error: cannot find symbol class Dashboard
Error:(10, 21) error: cannot find symbol variable Dashboard
Error:(39, 22) error: incompatible types: FreeStatus cannot be converted to UrlConnectionDelegate
/Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main/java/info.inarrivo.taxiprofessional/GCMIntentService.java
Error:(11, 43) error: cannot find symbol class CommonUtilities
Error:(11, 1) error: static import only from classes and interfaces
Error:(12, 43) error: cannot find symbol class CommonUtilities
Error:(12, 1) error: static import only from classes and interfaces
Error:(14, 39) error: cannot find symbol class GCMBaseIntentService
Error:(19, 12) error: cannot find symbol variable SENDER_ID
Error:(25, 2) error: method does not override or implement a method from a supertype
Error:(28, 6) error: cannot find symbol method displayMessage(Context,String)
Error:(36, 2) error: method does not override or implement a method from a supertype
Error:(39, 30) error: cannot find symbol method getString(int)
Error:(46, 2) error: method does not override or implement a method from a supertype
Error:(51, 6) error: cannot find symbol method displayMessage(Context,String)
Error:(59, 2) error: method does not override or implement a method from a supertype
Error:(62, 23) error: cannot find symbol method getString(int,int)
Error:(63, 6) error: cannot find symbol method displayMessage(Context,String)

and this is my updated build.gradle file still not compiling:

buildscript {

dependencies {
    classpath 'com.android.tools.build:gradle:0.11.1'
}
}

apply plugin: 'android'
dependencies {
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.google.android.gms:play-services:4.2.42'
    compile 'org.apache.commons:commons-lang3:3.2.+'
}
android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"
    defaultConfig {
    minSdkVersion 19
    targetSdkVersion 19
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

}

and this one is the file apparently created by Android Studio autonomously:

apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "20.0.0"
defaultConfig {
    applicationId 'com.inarrivo.info.taxiprofessional'
    minSdkVersion 15
    targetSdkVersion 20
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-annotations:20.0.0'
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:support-v13:20.0.0'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:gridlayout-v7:20.0.0'
compile 'com.google.android.gms:play-services:5.2.08'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services:5.2.08'
compile 'com.google.code.gson:gson:2.2.4'
}

with no benefit either.

Fabrizio Bartolomucci
  • 4,948
  • 8
  • 43
  • 75
  • post your build.gradle – Gabriele Mariotti Sep 12 '14 at 21:39
  • I think I posted it in the question. What else should I post and where to find it? – Fabrizio Bartolomucci Sep 14 '14 at 18:09
  • You posted your errors, not the build.gradle. You can find this file in the folder of your project. – Gabriele Mariotti Sep 14 '14 at 19:58
  • I am presently away from my development machine. Could you please tell me the exact path to this file? and I'll post it tonight. Thanks. – Fabrizio Bartolomucci Sep 15 '14 at 08:32
  • this is my build.gradle file. I hope it helps in understanding the problem. // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:0.12.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } – Fabrizio Bartolomucci Sep 15 '14 at 20:34
  • I also copied the file in the question to keep its formatting. – Fabrizio Bartolomucci Sep 15 '14 at 20:37
  • It is the top level file. You should have another build.gradle inside the module folder (not root folder) – Gabriele Mariotti Sep 16 '14 at 04:53
  • Ok, I will have a look at that too. Certainly, as a iOS developer, already the manifest was excessive, now I need yet another file to configure in order for the project to compile. The irony is that I switched to AS from Eclipse with the hope of finding a frindlier environment. Ok, tonight I will look for the file, if it exists. – Fabrizio Bartolomucci Sep 16 '14 at 08:10
  • I have not other build.gradle elsewhere. That could be the source of the problem as I added none. Where should it be, and what should it contain? – Fabrizio Bartolomucci Sep 16 '14 at 17:31
  • The structure usually is root/myModule. In root you should have the top level file. In myModule the file referred to the module. – Gabriele Mariotti Sep 16 '14 at 18:35
  • Could not you post an example file? I have really no idea how to compose it. – Fabrizio Bartolomucci Sep 17 '14 at 13:30

3 Answers3

4

You'll have to re-add all your dependencies, including appcompat.

If you have all the jars, you can put them in the libs/ directory of the app when using a dependency like this in the app's build.gradle (projectdir/app/build.gradle):

compile fileTree(dir: 'libs', include: ['*.jar'])

The other and preferred option is to declare dependencies in Maven-coordinates, like below (excerpt from the app's build.gradle file):

dependencies {
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.google.android.gms:play-services:4.2.42'
    compile 'org.apache.commons:commons-lang3:3.2.+'
}
Per Christian Henden
  • 1,514
  • 1
  • 16
  • 26
  • I am really sorry but I am quite new to Android development and so much that to AS and Gradle, and a total stranger to Maven. Could you please be a little clearer on what I should do. For instance, where do I find the jar files, the app's build.gradle, and where to copy the dependency string you mentioned. Also, once found that, should I put in that dependency list the library the compiler does not find, or where do I find the list? Thanks for your time and kind help. – Fabrizio Bartolomucci Sep 14 '14 at 18:07
  • What is also strange is that files are no longer able to find the classes in the other files. – Fabrizio Bartolomucci Sep 14 '14 at 18:24
  • @FabrizioBartolomucci Your best choice may then to be read some tutorials for AS and Gradle, or watch some instructional videos for them on Youtube. Your jar files, if you have them, will be in your old project directory, typically in the lib/ folder. Commonly, projects use Maven to download dependencies automatically. If your project does that, you'll find a list of dependencies in the pom.xml file(s). The app's build.gradle is put by default in the projectdir/app/ folder by AS. The dependencies block I posted should go in that file. Add dependencies to fix the class not found error. – Per Christian Henden Sep 15 '14 at 18:15
  • The point is that I spent quite a lot of bucks for learning Android programming after having spent a few years just on iOS and the teacher decided to use Eclipse. I followed suite and now I find myself with a code whose includes do not work. I even bought a new book about Android Studio, but I have really no idea about how that would solve my problems. On the reverse I started writing a new simple program following the book without new anything about gradle either, but it works. – Fabrizio Bartolomucci Sep 15 '14 at 20:32
  • Alright, you'll get there! You might want to look into dependency management and the android gradle plugin a bit, http://tools.android.com/tech-docs/new-build-system/user-guide. A good book on build automation, dependency management and gradle is "Gradle in Action". – Per Christian Henden Sep 17 '14 at 07:28
  • I have startedreading the documentation, thanks for that. Yet most of the issue to go in this file seem the same as those in the manifest, and in fact they are saying the manifest is automatically generated. Does it mean all the things that were going into the manifest are to go to the buld.gradle file now? – Fabrizio Bartolomucci Sep 17 '14 at 13:38
  • Excuse me: could you confirm I just need: buildscript { dependencies { classpath 'com.android.tools.build:gradle:0.11.1' } } apply plugin: 'android' android { compileSdkVersion 19 buildToolsVersion "19.0.0" } for my project following all conventions. That tool seems to allow things I do not really need. – Fabrizio Bartolomucci Sep 17 '14 at 13:54
  • Or perhaps: buildscript { dependencies { classpath 'com.android.tools.build:gradle:0.11.1' } } apply plugin: 'android' dependencies { compile files('whatever to put here, I do not know') } android { compileSdkVersion 19 buildToolsVersion "19.0.0" defaultConfig { minSdkVersion 19 targetSdkVersion 19 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } } – Fabrizio Bartolomucci Sep 17 '14 at 14:03
  • I added my updated build.gradle file I set in the java directory, hoping it belongs there, with no benefit, in the question. – Fabrizio Bartolomucci Sep 17 '14 at 20:15
  • Also when I try to build my build.gradle file I get error: Error:Cause: java.io.FileNotFoundException: /Users/fbartolom/Documents/Android/TaxiProfessional/src/main/AndroidManifest.xml (No such file or directory) /Users/fbartolom/Documents/Android/TaxiProfessional/src/main/AndroidManifest.xml (No such file or directory) where the manifest is (of course?) at /Users/fbartolom/Documents/Android/TaxiProfessional/app/src/main Where do I set this path? – Fabrizio Bartolomucci Sep 17 '14 at 20:31
  • I also suspect the problem might be in the application id. What should it be? I have several of them in the manifest, files and build.gradle. Also, perhaps after having insert the new build.gradle file, I seem no longer to be able to compile the app: instead, when I press the green trinagle, it executes one of the tasks in the very long gradle list, no one of them seeming to be the good old "compile and run". – Fabrizio Bartolomucci Sep 18 '14 at 07:43
  • @FabrizioBartolomucci Make sure to use the latest version of the Android plugin, 0.12.2, as well as the latest version of AS, 0.8.10. Move your AndroidManifest.xml to the expected location. Another strategy for you to consider is to create a new project using AS, and then just copy your resource and java files over to the new directory structure. Yes build.gradle overrides AndroidManifest.xml. Please create a new Stackoverflow question for your new questions, and post your build.gradle as part of the question! – Per Christian Henden Sep 18 '14 at 07:49
  • Once I understand what to ask, I will be happy to open a new question, presently I am moving in the dark with a project and 101 errors... As for the manifest location, which I am not sure if it is needed or not, the point is that my directory tree does not encompass that directory, the android project seems to automatically add directory 'app' in the middle of the path. As for your suggestion, I found myself in this situation properly after having created a new empy project and imported all the files, to the point I was thinking of reverting to the import process I once tried with no success. – Fabrizio Bartolomucci Sep 18 '14 at 08:00
  • Sounds like you're in the wrong build.gradle file - there is one in the top level by default and one in the app directory. You want the latter one. – Per Christian Henden Sep 18 '14 at 12:12
  • Yes, but what should be in that? That is my original question. Should I move the outside one inside the java directory, the app one or what else should I do? – Fabrizio Bartolomucci Sep 18 '14 at 14:27
  • This forum is not suited for back and forth questions and answers like this. I recommend you rather try #android on irc.freenode.net As for the top-level build.gradle it can be empty, there are no specific requirements. There is no need to move around the AndroidManifest.xml or build.gradle in the AS-generated project file structure. – Per Christian Henden Sep 19 '14 at 06:26
  • At any rate now it works everything, but notifications. I will post a question about it soon thanking you and everyone else for the precious support. – Fabrizio Bartolomucci Sep 19 '14 at 09:08
  • If you want to have a look at the other question, the address is: http://stackoverflow.com/questions/25930533/replacing-gcmbaseintentservice-for-remote-notifications-while-switching-to-andro – Fabrizio Bartolomucci Sep 19 '14 at 14:07
  • How may I do it? Also I would be happy if you helped me to fix the issue about notifications in Android Studio in the other thread. – Fabrizio Bartolomucci Sep 21 '14 at 09:26
  • Click the arrow above the large "0" to the left of my answer :) – Per Christian Henden Sep 22 '14 at 08:49
  • I think I managed it. Could you please also check my other issue as it seems to receive much less attention than this? – Fabrizio Bartolomucci Sep 22 '14 at 09:18
3

I apparently screwed up the project perhaps because of the project identifier. Now I copied exactly the one I had in Eclispe and at least now the errors are a bit friendlier. Of course I first had to add to build.gradle:

dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     compile 'com.google.android.gms:play-services:+'
     compile 'com.android.support:appcompat-v7:20.+'
}

I will be back at you if I am not able to understand the reason for the new errors, now apparently mostly affecting the references to R resources and the GCMRegistrar. For tonight, anyway, I am happy enough.

Fabrizio Bartolomucci
  • 4,948
  • 8
  • 43
  • 75
1

Missing dependencies{} causes this error.

dependencies {
compile "com.android.support:support-v4:23.1.1"
compile 'com.android.support:support-annotations:23.1.1'

}

Abhijeet
  • 8,561
  • 5
  • 70
  • 76