Problems with SlidingMenu integration - android

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

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

Android change build.gradle to import external library

I'm trying to use MaterialDialog in my project, but this library doesn't support my Right to Left language and I must edit that. After downloading the project and importing it into current project I get this error when building my project:
Error:(2, 0) Plugin with id 'com.novoda.bintray-release' not found.
After many searches on the web I find this link to resolve this. But that doesn't work for my project:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
/* I'm adding this below line */
classpath 'com.novoda:bintray-release:0.2.7'
}
}
allprojects {
repositories {
jcenter()
}
}
If you have downloaded the actual library and have imported it to Android studio and modified it then you want to add the dependency in your gradle.build (Module:app). The code you are showing is from gradle.build (Project: NameOfYourProject) so I would delete that line you added there.
Go to the build.gradle (Module:app) file which will look something like shown below and add the library as shown.
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.yourappname"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-project.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile project(':nameOfTheLibrary')
}
Add
dependencies {
compile 'com.afollestad:material-dialogs:0.7.7.0'
}
and press the sync button.

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
}

Can't find TabPageIndicator after adding ViewPagerIndicator library

I have added JakeWharton/ViewPagerIndicator by adding below statements to gradle.I am trying to use TabPageIndicator like this but it can't find import com.viewpagerindicator.TabPageIndicator although my gradle build fine after adding library.
Top Level Build.gradle:
buildscript {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
}
App's build.gradle:
compile 'com.viewpagerindicator:library:2.4.1#aar'
Update
Library is available here where you can download the zip
https://github.com/JakeWharton/ViewPagerIndicator
and at the website for VierPagerIndicator:
http://viewpagerindicator.com/
To add this:
Right click your Main Application ->New Module
From the More modules section ->Import Existing Project
Navigate to where you have downloaded, and extracted the zip file and select it.
This should import it and add it as a dependency for your project, unfortunately this did not get the desired project structure I wanted. So i copied the new module to the libs folder of my main module.
However this causes issues with gradle since now the project is linked incorrectly. So after i imported the new module and moved the project from a module within my main application i was prompted to add the library as a reference in settings.gradle which now looks like:
include ':app',':ViewPagerIndicator'
project(':ViewPagerIndicator').projectDir = new File('app/libs/ViewPagerIndicator')
And my Main apps build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.test.demo.myapplication"
minSdkVersion 8
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.0.0'
compile project(":ViewPagerIndicator")
}
Additionally my project structure is:
Add your library module from project structure and sync

Error:Artifact 'support-v4.jar (com.android.support:support-v4:21.0.3)' not found. Android studio 1.0.2

I did a new install of Android Studio 1.0.2. Getting the following error when opening my first existing android project:
Gradle 'MyApplication' project refresh failed
Error:Artifact 'support-v4.jar (com.android.support:support-v4:21.0.3)' not found.
Searched in the following locations: file:/C:/Users/Ntokozo/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-v4/21.0.3/support-v4-21.0.3.jar
And if I navigate to that searched location I found two jar files which are: support-v4-21.0.3-sources.jar and support-v4-21.0.3-javadoc.jar
Here is my build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Gradle file under App folder:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.ntokozo.myapplication"
minSdkVersion 15
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'
compile 'com.android.support:support-v4:21.0.3'
}
Thank you in advance, please bare in mind in responses that I'm a novice and I might not know advanced features.
After re-installing windows OS and a new Android Studio setup the problem disappeared. I don't know what was the problem at first.

Categories

Resources