【问题标题】:Error while importing Eclipse project to Android Studio for support lib. v7将 Eclipse 项目导入 Android Studio 以获取支持库时出错。 v7
【发布时间】:2017-01-07 20:07:30
【问题描述】:

我是 android studio 的新手,我正在尝试在 android 中导入 eclipse 项目,而依赖的 android 项目很少。

请参阅下面的附加图片和我的消息控制台以了解错误。 我尝试通过将 API 版本更改为 24,这是最新的,没有任何反应,在 SO 的一个答案后再次返回 API 21。 梯度版本。 在包装器中我有 2.14.1,在文件中我有 2.1.3

build.gradle 文件

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "package.name"
        minSdkVersion 11
        targetSdkVersion 21
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':comtwittersdkandroid_twitter')
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:appcompat-v7:21.2.0'
    compile files('libs/httpclient-4.3.3.jar')
    compile files('libs/httpcore-4.4.1.jar')
    compile files('libs/httpmime-4.3.jar')
    compile files('libs/twitter4j-core-3.0.5.jar')
    compile files('libs/universal-image-loader-1.8.0.jar')
    compile files('libs/zxing-1.7-core.jar')
    compile files('libs/zxing-integration.jar')
}

我试过添加jar而不是编译语句,它不起作用。

任何帮助将不胜感激,在此先感谢。

【问题讨论】:

标签: android android-studio import android-gradle-plugin build.gradle


【解决方案1】:

既然你正在使用

compile 'com.google.android.gms:play-services:+'

您依赖于需要 api 24 编译的支持库 v24
你必须使用:

compileSdkVersion 24

【讨论】:

  • 是的,我也尝试过使用 API 24。它不工作。
  • @AndriodNewbie “不工作”是什么意思?发布错误。
  • 我已经为我遇到的错误类型添加了图像。它正在创建如图所示的命名空间。
【解决方案2】:

感谢您的帮助,我终于解决了我必须从我的项目中删除 com_crashlytics_export_strings.xml 文件的问题。 当我切换到 API 版本 23 时,我删除了 http jar 并将编译语句添加到 build.gradle

一个重要我观察到的事情是“如果您有依赖项目,请交叉检查所有内容,因为主项目由于使用相同库的问题而大多无法编译。在依赖项目中或不推荐使用的函数;因为我的一个类中有一个用于地图。

我的 build.gradle 文件

    apply plugin: 'com.android.application'

android {
    useLibrary 'org.apache.http.legacy'
    compileSdkVersion 'Google Inc.:Google APIs:23'
    buildToolsVersion '23.0.3'

    defaultConfig {
        applicationId "package-name"
        minSdkVersion 11
        targetSdkVersion 21
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {

    compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
    compile('org.apache.httpcomponents:httpmime:4.3.6')
    compile files('libs/universal-image-loader-1.8.0.jar')
    compile files('libs/zxing-1.7-core.jar')
    compile files('libs/zxing-integration.jar')
    compile files('libs/gcm.jar')
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.android.support:appcompat-v7:23.2.0'
}

感谢您的帮助。回答以帮助将来遇到同样问题的任何人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-21
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2017-06-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多