Problems with importing libraries from github in android studio projects - android

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
}

Related

Module inclusion: not intended for consumption by other components - gradle:3.0.0-alpha2

Upgraded to:
Android Studio 3.0 Canary 2
com.android.tools.build:gradle:3.0.0-alpha2
I have a multi-module project (main app + sub modules)
Inclusion inside the main app:
dependencies {
implementation project(path: ':testlib', configuration: 'default')
}
The testlib is defined as a simple android library project and works normally when included with gradle 2.3.0 and via compile project(path: ':testlib')
I get the following gradle error message:
Could not resolve all dependencies for configuration ':app:devDebug_signedCompileClasspath'.
Selected configuration 'default' on 'project :testlib'
but it can't be used as a project dependency because
it isn't intended for consumption by other components.
What does "isn't intended for consumption by other components" mean in this context? The module is defined as an android library.
Here is the build.gradle of the testlib:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
What am I missing?
I also got this error. Android Studio 3.0 Canary 4 just came out. I updated to it, which also updates gradle to 4.0rc1.
The problem went away on it's own.
alter your Top-level build file (aka root gradle)
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
still not working?
update dist-url (inside gradle-wrapper.properties)
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-rc-1-all.zip

Unable to add Minim-Android library in Android Studio with jitpack

I am trying to add to my build.gradle file in Android Studio the following dependency:
https://android-arsenal.com/details/1/1883
I followed the intstructions found in package tab of this page, but when I tried to build the project I got the following message:
Error:(32, 13) Failed to resolve:
com.github.DASAR:Minim-Android:a73b596916
Anyone can help me?
I also tried to download the project code and import it in Android Studio as a module, but it wasn't recognized as a library from the wizard.
Thank you all in advance.
You can download relative API in your AS SDK Manager, then add it in build.gradle. After that, check out the compileSdkVersion, targetSdkVersion are same with appcompat. My build.gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.0.1"
defaultConfig {
applicationId "com.example.android"
minSdkVersion 9
targetSdkVersion 19
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:19.0.0'
}
my sdk is 19
Best option is to fork the project and add a Gradle build file. Then use JitPack to build the fork.
Note that the project has dependencies in a libs/ folder so these would need to be converted to dependencies in Gradle.

Problems with SlidingMenu integration

I have been trying to use the SlidingMenu library in my Android Studio project following the guide provided in this question:
How to import slidingmenu on Android Studio?
I've been able to obtain the described file structure and sync&build the project without errors. Yet, when trying to import the Sliding Menu to my apps source files, I'm getting a symbol resolve error.
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu; // Error message: Cannot resolve symbol 'SlidingMenu'
import com.jeremyfeinstein.slidingmenu.lib.BuildConfig;
The second import is the only one suggested by Android Studio but I can't even find the BuildConfig file in my project when following the given path.
What do I need to change to be able to import all the classes in com.jeremyfeinstein.slidingmenu.lib to my own classes?
My apps gradle files looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.me.appname"
minSdkVersion 17
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:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
compile project(':libraries:SlidingMenu')
}
The SlidingMenu gradle file:
buildscript {
// define the repo which is to use
repositories {
mavenCentral()
}
// define the classpath for Gradle Android Plugin
dependencies {
classpath 'com.android.tools.build:gradle:1.0.+'
}
}
// declaring that the project is a library
apply plugin: 'android-library'
// declaring all dependencies the project needs
dependencies {
compile 'com.android.support:support-v4:19.0.0'
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
// this values you can read out from the Manifest (but I add the right values for you)
minSdkVersion 17
targetSdkVersion 21
}
// because Android Studio has a different file structure than Eclipse
// you have to say Android Studio where the files are located
sourceSets{
main{
java.srcDirs = ['src/main/java']
res.srcDirs = ['src/main/res']
manifest.srcFile 'AndroidManifest.xml'
}
}
}
Project settings gradle:
include ":libraries:SlidingMenu", ':app'
Get the AAR port of the library (v1.3).
The GitHub Pages is down, so you'll have to import that AAR manually:
Top build.gradle file:
repositories {
flatDir {
dirs 'libs'
}
}
Place the AAR file in the libs folder of your module, then in your module build.gradle file:
dependencies {
compile(name:'library-1.3', ext:'aar')
}

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'
...
}

Android Studio: How to see sources for android support v4 and v7?

In Android Studio support library appcompat (for ActionBar) is defined as Gradle dependency.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
That resolves to get v4 as well.
How to see source when clicking to into classes?
e.g. android.support.v4.widget.DrawerLayout
Currently Android Studio says
// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available
For ADT it was How to add source + javadoc for android-support-v7?
Following from the above research done by Paul Verest...
IDE: Android studio 1.3.2
It is a 2-step process: Consider this sample build.gradle
1) Add the following to your build.gradle (Module:app) - search the 2 //Add comments below.
apply plugin: 'com.android.application'
apply plugin: 'idea' //Add
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.mycompany.android.myapp"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.0'
}
//Add
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
2) Rebuild project.
After this point if you want to see source in Android Studio, it will pull up the source *.java instead of decompiled *.class
Thanks to Setu for hint. As I already had all sources before, I just added in app/build.gradle
apply plugin: 'idea'
idea {
module{
sourceDirs += file("E:\\Android\\sdk\\extras\\android\\support\\v4\\src\\")
sourceDirs += file("E:\\Android\\sources\\platform_frameworks_support\\v7\\appcompat\\src")
}
}
below dependencies section and press "Sync project with Gradle Files"

Categories

Resources