How to use module as library in android - android

I am going to use cognalys (third party library) in my app for mobile verification..I cloned that from git hub and i imported that cognalys in my app as module.How to use that module as library in my project(how to convert that as library)..I dont know how to use that..By using that only i can create a class for mobile verification of user...
Please help me to find out the solution
This is my build.gradle of cognalys project
apply plugin: 'com.android.library'
android {
compileSdkVersion 10
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.0'
}

First add the library project as module.
File->New->Import module
then add this line to your dependencies in gradle
compile project(':yourmodule')

Related

Cannot resolve symbol (after Android Studio update) but the project builds for app/library project

I have an an Android Studio project A which is an app, and a project B which is a library project. I have included project B in project A. Project B has some dependencies (android async http, and org.json) that are used in both project B and project A. I upgraded Android Studio to 2.2 Preview 2, and am now having an issue where all of my usages of android async http are saying Cannot Resolve Symbol. However, my JSON usages are just fine. When I build the project, I get no errors and can run it just fine. How can I fix the Cannot Resolve Symbol issue in Android Studio?
I have tried
cleaning & rebuilding both projects
making a change in the app's build.gradle & syncing grade
re-arranging the order of dependencies
sync project with gradle files
delete android async http.xml from .idea/libraries & sync project with gradle files
opening and closing android studio
setting minifyEnabled=true in the app & library
Is there something I am missing?
app > build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
versionCode 33
versionName "2.3"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile project(':mylibrary')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v13:21.0.3'
}
library > build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 2
versionName "1.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile files('libs/org.json-20120521.jar')
compile files('libs/android-async-http-1.4.5.jar')
}

Problems with importing libraries from github in android studio projects

I am encountering problems when trying to import libraries from github in android studio projects. Very few libraries are getting imported successfully. Here is my method of importing in android studio project:
Download zip from github.
Extract the respective library.
Import module in android studio project then import the library and adding dependencies.
Here is the error tht I am encountering when I am trying to import material drawer library whose link is:https://github.com/mikepenz/MaterialDrawer
Error:No such property: GROUP for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer
Is my method of importing libraries from github correct?
This is my module gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.works.vipul.materialdrawer"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile('com.mikepenz:materialdrawer:3.1.2#aar') {
transitive = true
}
}
You should resolve materialdrawer dependency by gradle.
Add these in your build.gradle under repositories
repositories {
mavenCentral() //add this line
}
also add this under your dependencies
compile('com.mikepenz:materialdrawer:3.1.2#aar') {
transitive = true
}

Android Studio: Add library as reference, not as import

This question is a sequel to this one.
In an existing Eclipse solution I have a library project which is used as a Android Dependency in the main app project. That means that if I edit this library, and compile, the main project is updated with the latest from that library.
I'm trying to do the same in Android Studio. That means not importing a library, but using it as a reference or dependency in the app project. I've been trying for two days now with no luck. Help is HIGHLY appreciated.
build.gradle (of the app project - there is nothing interesting her as I didn't change it much)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
You can try this steps:
Download library
File/import module
Select your library and rename :LibraryName
Go to build.gradle and write.
build.gradle
dependencies {
......
compile project(':LibraryName')
.....
}
Then if you import module you can edit library and proyect its updated
Say you have 2 projects, 1 application and 1 library project, you want to push all your external dependencies to your library project, so your application project only depends on the library project:
settings.gradle
include ':app'
include ':library'
app/build.gradle
apply plugin: 'com.android.application'
dependencies {
compile project(':library')
}
library/build.gradle
apply plugin: 'android-library'
dependencies {
compile 'external-dependencies-1'
compile 'external-dependencies-2'
...
}

Building app with library module cannot find AndroidManifest.xml

I want to build an Android App with AndroidAnnotations.
Here is a simplified version on GitHub which fails to build/pre-process: https://github.com/aiQon/androidannotationsexample
The app is composed of a main app module and a library module.
Both use AndroidAnnotations (AA). The lib module has a workaround to find the AndroidManifest.xml in debug builds (it refers to the release manifest, because gradle does not build the debug variant for libs).
However, the manifest is found for the library module but not for the main app.
The gradle file of the main app is:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
android {
compileSdkVersion 21
buildToolsVersion "21.0.1"
defaultConfig {
applicationId "de.stelle_beratung.androidannotationslibraryexample"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apt {
arguments {
androidManifestFile variant.outputs.processResources.manifestFile
resourcePackageName android.defaultConfig.applicationId
}
}
dependencies {
compile project(":mylibrary")
apt "org.androidannotations:androidannotations:3.2+"
compile 'org.androidannotations:androidannotations-api:3.2+'
}
Gradle complains with:
http://pastebin.com/QZtnHcZD
Could someone please point me in the right direction on how to build this simplified project to have a controller Bean in the lib module and reference it successfully in the main app activity by using AA?
I appreciate any help.
Since android gradle plugin 14.4, the following line does not work anymore:
variant.outputs.processResources.manifestFile orvariant.processResources.manifestFile
You have to use this one instead:
variant.outputs[0].processResources.manifestFile
Please note if you have multiple outputs (when using splits), you may want to use another output (other index than zero).
Ok I got it. Was using Android Studio from the Canary Channel. Going back to Beta solved the issue because I could use android gradle plugin 0.12.2. This solved everything.

error: package xxx does not exist . how do include packages in the build correctly?

I'm trying to use the project android-wheel from https://code.google.com/p/android-wheel/
with Android Studio.
I imported them as modules and put the dependency for 'wheel' into the build.gradle of 'wheeldemo'.
when building it with gradle it shows errors, that packages do not exist, even though the imports in the java file don't show any errors:
I'm not sure, what I'm missing here. Might be something obvious, since I'm not to familiar with android programming, yet.
edit: here is the build.gradle of the wheeldemo module:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId 'kankan.wheel.demo'
minSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile project(':wheel')
}
Make sure the build.gradle of "wheel" has correct plugin type. It should be 'android-library' instead of 'com.android.application'.

Categories

Resources