找不到酒店'VERSION_CODE'

时间:2015-07-22 17:08:19

标签: android gradle

我想将这个库用于我的项目,当我尝试从Github打开这个library (FloatingActionButton) 源代码时出现错误。

当我尝试打开源代码来理解它时我下载了这个项目的zip,我收到了这个错误:

Error:(10, 0) Could not find property 'VERSION_CODE' on project ':library'.

添加 build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
        versionCode Integer.parseInt(project.VERSION_CODE)
        versionName project.VERSION_NAME
    }
    buildTypes {
        release {
            minifyEnabled false
            debuggable false
        }

        debug {
            minifyEnabled false
            debuggable true
        }
    }
}

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

apply from: '../gradle-mvn-push.gradle'

4 个答案:

答案 0 :(得分:5)

将库导入为模块,将<div class="img-container" data-bg="img/intro-00.jpg" data-bg-sm="img/intro-00-sm.jpg"></div> <script> $.extend($.lazyLoadXT, { srcAttr: 'data-bkg-sm' }); </script> versionCode更改为随机值, 添加对项目的引用 - 添加到依赖项  versionName 并删除:

  

申请来自:&#39; ../ gradle-mvn-push.gradle&#39;

答案 1 :(得分:2)

要使用新设计支持库,您需要在应用程序的gradle文件中编写以下行

compile 'com.android.support:design:22.2.0'

并在layout.xml文件中写下以下行

 <android.support.design.widget.FloatingActionButton
        android:id="@+id/floating_action_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/fab_margin"
        android:src="@drawable/your_icon"
        app:borderWidth="0dp"
        app:layout_anchor="@id/coordinator_layout"
        app:layout_anchorGravity="bottom|right|end"
        />

多数民众赞成

答案 2 :(得分:1)

您下载的项目似乎没有AndroidManifest文件,因此它没有VERSION_CODE或VERSION_NAME。将代码合并到项目中时,它将从项目的Manifest文件中获取它们。或者我希望如此。

答案 3 :(得分:1)

将库导入为模块,

1. File-> New-> ImportModule-> SoureDirectory-> "your library path" -> ok.
2. Change versionCode and versionName to the same as in android-Floating-button/sample/build.gradle
  (copy that 2 from app build.gradle to library build.gradle)
  ( for example give: versionCode 1, versionName "1.0"), 
3. (CTRL+ALT+SHIFT+S) or Go to File > Project Structure > Modules --> Click on "Dependencies"
-> click on "+"(plus) -> Module Dependency -> select you lib-> "OK".
4. Remove this from build.grade in you "library"
apply from: './gradle-mvn-push.gradle'
5. Add this in you app "build.gradle" like this
dependencies {
compile project(":library")
}