将应用程序从Eclipse移植到Android Studio时出错

问题描述:

我正在将项目从Eclipse移植到最新的Android Studio。通过复制AS使用的目录中的所有文件,一切都很顺利,但实际上我在使用的所有库和从我自己的项目中导入时出现了大量错误:可能是什么问题?这是错误列表:(当然,未完成的符号很好并且在项目中踢。)

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)

这是我更新的build.gradle文件仍未编译:

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
}

}

和这个e是显然由Android Studio自主创建的文件:

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'
}

没有任何好处。

您必须重新添加所有依赖项,包括appcompat。

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

如果你有所有的jar,你可以把它们放在app
的libs /目录中,当在app的build.gradle中使用这样的依赖项时(projectdir / app / build.gradle):

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'])

另一个首选选项是在Maven坐标中声明依赖关系,如下所示(摘录)来自应用程序的build.gradle文件):

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.+'
}