Can't find TabPageIndicator after adding ViewPagerIndicator library - android

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

Related

Android Studio Gradle does not download maven depedencies

I am quite new to Android development and trying to write some test code. I have downloaded Android Studio 1.3 version and created testapp. I am trying to add com.facebook.android:facebook-android-sdk:4.1.0 depedency but somehow it's not getting downloaded.
Here is Project level build.gradle file.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}
Here is Module level build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.testapp"
minSdkVersion 19
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.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:appcompat-v7:22.2.1'
}
After reading other posts on similar topics I also confirmed that Gradle > Global Gradle settings > Offline work is not checked. Still somehow facebook depedency is not getting downloaded.
Any suggestions what could be the issue? Appreciate any pointers.
Thanks.
In your build.gradle you have to add
repositories {
jcenter()
}
It this way gradle knows where are the dependencies to download.
It is somenthing different from the repositories inside the buildscript block.
Otherwise you can add in the top-level build.gradle file:
allprojects {
repositories {
jcenter()
}
}
In this case, the repository block is valid for all modules in the project.
Could you post the error AndroidStudio is showing? (check on the Gradle Console, on the Run section and Android Monitor section)
One possible option that comes to my mind is that you don't have the lastest Android Support repository / Google repository installed: Check for updates on your Android SDK Manager.

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.

Cannot add CircularReveal library by ozodrukh in Android studio

I am using Android Studio 1.1.0 and am trying to add CircularReveal library .I have followed the instructions mentioned there.
my build.gradle(Module: app) is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.geronimo.myapplication"
minSdkVersion 18
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.github.ozodrukh:CircularReveal:(latest-release)#aar'
}
I have added the repository in `build.gradle(Project: MyApplication3)`
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
}
The error that I am getting is
D:\Workspaces\AndroidStudio\Studio1.0\MyApplication3\app\build.gradle
Error:(24, 13) Failed to resolve: com.github.ozodrukh:CircularReveal:(latest-release)
Show in File<br>Show in Project Structure dialog
I have tried variations of the dependency too ie:
compile 'com.github.ozodrukh:CircularReveal:(latest-release)#aar'
compile 'com.github.ozodrukh:CircularReveal:(v1.0.4)#aar'
compile 'com.github.ozodrukh:CircularReveal-v1.0.4 #aar'
The error always remains as Failed to resolve...
Is there any other way to import a remote aar file and to add this dependency?
Copy #aar file to the libs directory manually. Then by going to
Files>Project Structure>Dependency
on the right red cross choose library dependency. This will prompt you a dialog where you can search for your dependency and add them.
or
download circularReveal library from github and import it as Module Dependency from Files>Project Structure>Dependency
You need to put only version number without brackets and 'v' char
com.github.ozodrukh:CircularReveal:1.0.4#aar
I had the same problem before. After I checked, I saw that the problem was the miniSDKversion which was lower than 15. Once I changed it to 15, it worked.
minSdkVersion 14 (change it to 15 or above)
targetSdkVersion 26
Then paste this to your library dependency
implementation ('com.github.ozodrukh:CircularReveal:2.0.1#aar') {
transitive = true;
}
Also add remote maven url
repositories {
maven {
url "https://jitpack.io"
}
}

Share external dependencies between modules in Android Studio

I'm trying to share 2 external dependencies between 2 modules in Android Studio.
The 2 dependencies are Twitter Core and Twitter4j (a Twitter library extension I'm experimenting with).
Here is the project structure:
Root project 'cineios-test'
+--- Project ':app'
\--- Project ':cineio-broadcast-android-sdk'
I set up the dependencies in my app build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.lgorse.cineios_test"
minSdkVersion 18
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions{
exclude 'META-INF/LICENSE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':cineio-broadcast-android-sdk')
//compile project(':cineio-broadcast-android')
//compile 'io.cine:cineio-broadcast-android-sdk:0.0.9'
compile ('org.twitter4j:twitter4j-stream:4.0.2'){
transitive = true;
}
compile('com.twitter.sdk.android:twitter:1.1.1#aar') {
transitive = true;
}
}
Here is the build.gradle file for the module, which is cineios-android-sdk:
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
// applicationId 'io.cine.android'
minSdkVersion 18
targetSdkVersion 19
versionCode 11
versionName '0.0.11'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile 'com.google.guava:guava:16.0'
compile 'com.loopj.android:android-async-http:1.4.5'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:support-v4:20.0.0'
}
Finally here is settings.gradle:
include ':app', ':cineio-broadcast-android-sdk'
project(':cineio-broadcast-android-sdk').projectDir = new File('cineio-broadcast-android/cineio-broadcast-android-sdk')
I know there are answers on SO but they refer adding local libraries as modules - but since these dependencies are remote I'm not sure how to adapt the hints to this situation.
I did try adding the dependencies to the other module (cineios-android) but a) it seems ridiculous to double them up like that and b)that would imply registering a new app in the Twitter API, which will probably lead to errors.
The correct approach really is to specify the dependencies in both the main app and the module.
I did try adding the dependencies to the other module (cineios-android) but a) it seems ridiculous to double them up like that and
There's really nothing ridiculous about it. Don't think of it as trying to "share" the dependency between the main app and the module. Look at it this way: your module depends on Twitter4j and Twitter Core. If you were to reuse that module in a different application, the module should be self-contained and should be able to specify its own dependencies without the parent project needing to set them up. Making all its dependencies explicit does this.
If the parent app also depends on Twitter4j and Twitter Core, and if you use the Maven Coordinate-style remote dependency specs as you have, the build system will ensure that only one copy actually gets linked into the app, so everything will be okay.
b)that would imply registering a new app in the Twitter API, which will probably lead to errors.
I'm not familiar with how that works, so I can't comment on it other than to say that if their API is well designed, hopefully just including the library shouldn't imply something like that. If you're having problems, clarify your question or ask a new one.
In your build.gradle add dependency like below:
dependencies {
compile 'org.openimaj:twitter:1.3.1'
}
You can also use belowed link for more reference :
Gradle Please

debug: file not found in Android 1.0

Today I updated to Android Studio v 1.0 and I'm getting the following error when trying to compile whatever project.
....\app\build\intermediates\classes\debug: file not found
The thing is that before updating it I had no problems. Here is the code I'm actually trying to compile.
build.grade
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "razvitrance.testnavdrawerplz"
minSdkVersion 16
targetSdkVersion 20
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:support-v13:21.0.3'
}
build.gradle (for the project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
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()
}
}
And the activity code is a simple Navigation Drawer.
Thank you for helping.
This is the erorr i'm getting.
http://gyazo.com/bdf375a160b1662ce4eb0d4e9aed8f30
Check this and this answers.
Generally, you will need to delete your grandle file and let Android Studio generate the one it thinks that it is correct, as it is being mentioned in the given posts. Happened to me too when i upgrated to newer version and that solved my problem.
It seems that Android Studio does not recognize non-alphanumeric symbols in path (cyrillic, for example). I had the same problem, and it was solved with creating project in another folder not containing cyrillic symbols in its path. In your case it may be '#' synmbol that makes a trouble

Categories

Resources