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

时间:2014-09-12 17:49:04

标签: java android eclipse android-studio

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

/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文件仍未编译:

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
}

}

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

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

也没有任何好处。

3 个答案:

答案 0 :(得分:4)

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

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

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

另一个首选选项是在Maven坐标中声明依赖项,如下所示(摘自app的build.gradle文件):

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

答案 1 :(得分:3)

我显然是因为项目标识符搞砸了项目。现在我完全复制了我在Eclispe中所拥有的那个,至少现在这些错误更加友好了。当然我首先要添加到build.gradle:

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

如果我无法理解新错误的原因,我会回过头来看,现在显然主要影响对R资源和GCMRegistrar的引用。无论如何,今晚,我很开心。

答案 2 :(得分:1)

缺少依赖关系{} 会导致此错误。

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

}