Reputation: 4639
I want to use this library for my project and I got error when I try open this library (FloatingActionButton) source from Github.
I download as zip this project 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'
Upvotes: 4
Views: 4939
Reputation: 4415
Import library as a module by,
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")
}
Upvotes: 1
Reputation: 822
To use new design support library yout need to write following line in your app's gradle file
compile 'com.android.support:design:22.2.0'
and in your layout.xml file write following lines
<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"
/>
Thats it
Upvotes: 2
Reputation: 3266
import library as a module, change versionCode
and versionName
to random values,
add a reference to your project - add to dependencies
compile project(":library")
and remove:
apply from: '../gradle-mvn-push.gradle'
Upvotes: 5
Reputation: 5575
The project you downloaded doesn't seem to have an AndroidManifest file, so it doesn't have a VERSION_CODE or a VERSION_NAME. When you incorporate the code in your project, it will get them from the Manifest file in your project. Or so I would hope.
Upvotes: 1