Could not find property "VERSION_CODE"

I want to use this library for my project, and I got an error when I try to open this library (FloatingActionButton) from Github.

I load this project as a zip, when I tried to open the source code to understand it, I got this error:

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

Add 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
source share
4 answers

import the library as a module, change versionCodeit versionNameto random values, add a link to your project - add to the dependencies   compile project(":library") and delete:

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

+5
source

, gradle file

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

There is no AndroidManifest file in the downloaded project, so it does not have VERSION_CODE or VERSION_NAME. When you include code in your project, it will receive them from the manifest file in your project. Or I hope so.

+1
source

Import the library as a module,

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")
}
+1
source

Source: https://habr.com/ru/post/1599141/


All Articles