如何导入Action Bar Sherlock?安卓工作室

时间:2015-10-27 02:35:48

标签: android android-studio gradle actionbarsherlock android-appcompat

我想导出和导入我在Android中使用Eclipse的gradle项目。

将项目导入Android Studio有关ActionBarSherlock的问题

    android {
    compileSdkVersion 'Google Inc.:Google APIs:17'
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.matetek.Hello"
        minSdkVersion 14
        android:targetSdkVersion="23"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}
    dependencies {
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.android.support:support-v4:18.0.+'
}

无法使用

导入com.actionbarsherlock.app.ActionBar

import com.actionbarsherlock.app.SherlockFragmentActivity

Error:(10, 0) Cause: startup failed:
build file 'C:\Work\Hello\build.gradle': 10: Statement labels may not be used in build scripts.
In case you tried to configure a property named 'android', replace ':' with '=' or ' ', otherwise it will not have the desired effect.
 @ line 10, column 17.
           android:targetSdkVersion="23"

帮帮我

对不起,我不擅长英语

2 个答案:

答案 0 :(得分:4)

首先,作者2年前已弃用Actionbarsherlock library
今天没有必要使用这个库。
使用 AppCompat库,这样您就可以使用所有新功能和新的支持库(作为设计支持库)。

您的问题就在这里。

defaultConfig {
        android:targetSdkVersion="23"
    }

中更改此行
defaultConfig {
        targetSdkVersion 23
    }

注意 您无法一起使用ActionbarSherlock和Appcompat库。

他们使用相同的属性。

答案 1 :(得分:1)

android:targetSdkVersion="23"更改为targetSdkVersion 23它会起作用。

有关详细信息,请访问开发者网站:Android Build Configuring

还可以使用最新的支持库

compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:23.1.0'