Not able to add a library to project in the Android Studio - android

I'm already facing this error:
"Failed to
resolve:com.github.ygorbarboza:AKParallax-Android:fce9eac521"
"Showing error :Gradle DSL method not found:'maven()' "
Here's my build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.abhishek.experiment"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.aar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.ygorbarboza:AKParallax-Android:fce9eac521'
}
I have even added the repository
repositories {
maven {
url "https://jitpack.io"
}
}

You need to add
repositories {
maven {
url "https://jitpack.io"
}
}
as mentioned here

Related

Android: Adding libraries through gradle with external repositories

I am trying to import this library:
https://android-arsenal.com/details/1/2822
The instructions say:
The following goes in your module's build.gradle file:
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
// ... other dependencies here
dependencies {
compile 'com.github.TouchBoarder:weekdays-buttons-bar:v1.0.2'
}
}
So I added to my app gradle the dependency (last line):
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.amazon.mysampleapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
lintOptions {
abortOnError false
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile fileTree(include: ['*.jar'], dir: 'app/libs')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.amazonaws:aws-android-sdk-core:2.2.18'
compile 'com.amazonaws:aws-android-sdk-cognito:2.2.18'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.18'
compile 'com.amazonaws:aws-android-sdk-mobileanalytics:2.2.18'
compile 'com.amazonaws:aws-android-sdk-lambda:2.2.18'
compile 'com.android.support:design:23.4.0'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.yarolegovich:lovely-dialog:1.0.4'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.github.TouchBoarder:weekdays-buttons-bar:v1.0.2'
}
Then added the repository to my top level all projects gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}
}
allprojects {
repositories {
jcenter()
compile 'com.github.TouchBoarder:weekdays-buttons-bar:v1.0.2'
}
}
But it is not working I am getting the error:
Could not find method compile() for arguments [com.github.TouchBoarder:weekdays-buttons-bar:v1.0.2] on repository container.
I am obviously not writing my gradle file correctly but not sure what is wrong.
Try with removing repository from top level all projects gradle file like below...
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}
}
allprojects {
repositories {
jcenter()
}
}
Also you need to add maven url inside repositories to your app gradle.
apply plugin: 'com.android.application'
repositories {
maven {
url "https://jitpack.io"
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.amazon.mysampleapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
lintOptions {
abortOnError false
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile fileTree(include: ['*.jar'], dir: 'app/libs')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.amazonaws:aws-android-sdk-core:2.2.18'
compile 'com.amazonaws:aws-android-sdk-cognito:2.2.18'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.18'
compile 'com.amazonaws:aws-android-sdk-mobileanalytics:2.2.18'
compile 'com.amazonaws:aws-android-sdk-lambda:2.2.18'
compile 'com.android.support:design:23.4.0'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.yarolegovich:lovely-dialog:1.0.4'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.github.TouchBoarder:weekdays-buttons-bar:v1.0.2'
}
I think it's a very simple error:
Try removing the v from v1.0.2
So, instead of
compile 'com.github.TouchBoarder:weekdays-buttons-bar:v1.0.2'
try this:
compile 'com.github.TouchBoarder:weekdays-buttons-bar:1.0.2'
I'm not sure if that's the issue, but you can give it a try.
EDIT: You also have to add jitpack to your repositories. If you look at the instructions, you can see it contains this:
repositories {
maven { url "https://jitpack.io" }
}
So add that to your gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.github.TouchBoarder:weekdays-buttons-bar:v1.0.2'
}
}

how does the gradle dependencies work, i can not find any function relate with it in the gradle source code

how does the gradle dependencies work, i can not find any function relate with it in the gradle source code.
please help me , I googled this but found nothing...
dependencies {
}
gradle dependencies work from build.gradle(Module:app)
buildscript {
repositories {
....
}
dependencies {
...........
}
}
apply plugin: 'com.android.application'
apply plugin: '..'
repositories {
.....
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "your pkg name"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
//Here you can add your dependencies
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
........
}

Error:(41, 13) Failed to resolve: de.codecrafters.tableview:tableview:0.9.5

I'm getting error, while building gradle in android studio.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.whyz.kitetech.mobile.cdrapp"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
repositories {
mavenCentral()
// maven { url 'http://repo1.maven.org/maven2' }
// maven { url "http://owasp-java-html-sanitizer.googlecode.com/svn/maven" }
//maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
}
buildTypes {
debug {
debuggable = true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
// NOTE: vector-compat is available on API level 14 or later
compile 'com.wnafee:vector-compat:1.0.5'
compile 'de.codecrafters.tableview:tableview:0.9.5'
compile 'com.diogobernardino:williamchart:2.0.1'
}
First of all you have to move the repository block out side android block.
apply plugin: 'com.android.library'
android {
}
repositories {
mavenCentral()
// maven { url 'http://repo1.maven.org/maven2' }
// maven { url "http://owasp-java-html-sanitizer.googlecode.com/svn/maven" }
// maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
}
Then your issue is that de.codecrafters.tableview doesn't exist on Central Maven or Jcenter.
As workaround you can use the github repo with the jitpack plugin
It is very simple.
Just add this repo tp your build.gradle
repositories {
// ...
maven { url "https://jitpack.io" }
}
and the dependency:
dependencies {
compile 'com.github.User:Repo:Tag'
}
In your case it seems to be:
compile 'com.github.ISchwarz23:SortableTableView:v0.9.5'

Crashylitcs integration with android lib

I'm debugging stuff on a lib and was trying to integrate crashlytics on it. At first, I've followed this, and after some problems, managed to build the library without errors.
The thing is: when I try to use Fabric.with(this, new Crashlytics(), new CrashlyticsNdk()) in the app which uses that lib, it gives me an "symbol cannot be resolved".
I've tried moving this line into the lib, but all I've got was a NoClassDefFoundError.
Any suggestions?
Below, my lib gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 20
buildToolsVersion '20'
defaultConfig {
minSdkVersion 9
targetSdkVersion 9
versionCode 1
versionName "1.0"
}
buildTypes {
release {
}
}
productFlavors {
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/mylib.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.0#aar') {
transitive = true
}
}
and my app gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 20
buildToolsVersion '20'
defaultConfig {
applicationId 'com.test.app'
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName '1.0'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'LICENSE.txt'
}
sourceSets {
androidTest.setRoot('src/test')
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
}
}
productFlavors {
}
splits {
abi {
enable true
reset()
include 'armeabi'
}
}
}
repositories {
flatDir { dirs 'libs' }
}
dependencies {
compile(name: 'my-framework', ext: 'aar')
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
}

Import remote library from Maven

I'm trying to add both Showcaseview by amlcurran and Android-DirectoryChooser by passy to my android app from MavenCentral, but I keep getting this error for both libraries:
Error:net.rdrei.android.dirchooser:library:2.0
This is my Project Gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
This is the inner one:
apply plugin: 'android'
android {
lintOptions {
checkReleaseBuilds false
}
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 6
versionName "1.2.2"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'org.jaudiotagger:jaudiotagger:2.0.1#jar'
compile 'com.android.support:support-v4:19.1.0'
compile 'net.rdrei.android.dirchooser:library:2.0#aar'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
How can I fix it?
The problem is that you are not specifying the repository URL. Check my answer here:
https://stackoverflow.com/a/23879736/570612

Categories

Resources