Can't import Android library - android

I'm trying to use RecyclerView Helper, but can't get project work with it.
Here is the library that I'm trying to use: https://github.com/nisrulz/recyclerviewhelper
But getting this error:
Could not find method implementation() for arguments [com.android.support:appcompat-v7:{latest version}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK Manager.
This is my build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
def supportLibVersion="{latest version}"
// Required
implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "com.android.support:recyclerview-v7:${supportLibVersion}"
// RecyclerViewHelper
implementation "com.github.nisrulz:recyclerviewhelper:${supportLibVersion}"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

I think the latest version is a placeholder text. The latest version should be replaced with the latest version of SDK you need.
Please use this
def supportLibVersion="27.1.1"
instead of
def supportLibVersion="{latest version}"
Your library documentation also have this line
where {latest version} corresponds to published version in 27.1.1.

This is the project.gradle file ,you import library in wrong gradle file.please import this library on app.gradle file.
Import this on app.gradle
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.github.nisrulz:recyclerviewhelper:27.1.1'
}
Import this on project.gradle
allprojects {
repositories {
google()
jcenter()
}
}

Related

ERROR: Gradle DSL method not found: 'implementation()' But I have the newest of all Android Studio, gradle,

I just want implementation 'de.hdodenhof:circleimageview:3.0.0' to make image round. But I can't
I try update all things
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
implementation 'de.hdodenhof:circleimageview:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You edited the wrong build.gradle file. The lines right below your addition warn you against doing this:
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
If you have a typical Android Studio project, move your implementation 'de.hdodenhof:circleimageview:3.0.0' from where you have it to the dependencies closure in the app/build.gradle file.

Android Studio importing Jetbrains Exposed

I am new to Android development. I have created a new project with Android Studio and need to import jetbrains exposed library into my existing project. When I tried to follow the exposed Getting Started guide to add the following into the build.grade file:
repositories {
maven {
url "https://dl.bintray.com/kotlin/exposed"
}
}
dependencies {
compile 'org.jetbrains.exposed:exposed:0.10.2'
}
I get the following error:
Could not find method compile() for arguments [org.jetbrains.exposed:exposed:0.10.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I have been searching the internet for a couple of days now but still could not find out what's the problem.
This is the build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.40'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
repositories {
maven {
url "https://dl.bintray.com/kotlin/exposed"
}
}
dependencies {
compile 'org.jetbrains.exposed:exposed:0.10.2'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Hopefully someone could help me.
Thanking in advance.
You should put this dependency in the module level build.gradle file - by default, this is in the app folder, as opposed to the project level build.gradle file, which is in the root of your project.
Also, you should use implementation instead of compile, since you're using a newer than 3.0 version of the Android Gradle plugin:
repositories {
maven {
url "https://dl.bintray.com/kotlin/exposed"
}
}
dependencies {
implementation 'org.jetbrains.exposed:exposed:0.10.2'
}

Could not find method implemnetation() for arguments. Error

Hi i am getting the followin error on my build gradle Could not find method implemnetation() for arguments. I tried to clean the gradle cache clean project but nothing works. I have seen similliar posts but i couldnt find the answer.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'java-library'
buildscript {
repositories {
mavenCentral()
}
dependencies {
implementation 'org.hibernate:hibernate-core:3.6.7.Final'
api 'com.google.guava:guava:23.0'
testImplementation 'junit:junit:4.+'
implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.6.+#aar'
}
}
allprojects {
repositories {
jcenter()
}
}
Your project and your application module have both a build.gradle file.
Here you are mixing the top level build.gradle, which should be like this:
Project build.gradle (Top Level inside your project's folder)
//the `java-library` plugin is unnecessary here
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
//the gradle plugin version is the same as Android Studio, here v3.1.1 which is currently the latest stable
classpath 'com.android.tools.build:gradle:3.1.1'
}
}
allprojects {
repositories {
mavenCentral()
google()
}
}
App Module build.gradle (Module Level inside you app module's folder)
apply plugin: 'com.android.application'
android{...}
dependencies {
implementation 'org.hibernate:hibernate-core:3.6.7.Final'
api 'com.google.guava:guava:23.0'
testImplementation 'junit:junit:4.+'
implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.6.+#aar'
}
For more information about these 2 build.gradle files, you can refer to the documentation for the top level and the module level

Failed to resolve: android.arch.lifecycle:extensions:1.0.0-alpha1 android studio 3.0

I am building a project in android studio 3.0 with android plugin 'com.android.tools.build:gradle:3.0.0-alpha1' and gradle version gradle-4.0-milestone-1-all.zip.
Used maven repo as well:
maven {
url 'https://maven.google.com'
}
Also, Using android Room persistence and lifecycle in my project. Already declared below dependencies in my app gradle file:
compile "android.arch.lifecycle:extensions:1.0.0-alpha1"
compile "android.arch.persistence.room:runtime:1.0.0-alpha1"
annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha1"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha1"
When Sync and build the project it's showing below error:
Failed to resolve: android.arch.lifecycle:extensions:1.0.0-alpha1
Am I missing something or any other solution for this issue.
I have fixed the issue by updating my app build.gradle file like below:
// 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:3.0.0-alpha2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Actually had to remove the maven repository from buildscript repositories and added to allprojects repositories as shown above. Also you can keep the maven repository at both places but must include in allprojects repositories to fix the issue.
Add in app/gradle file
compile "android.arch.lifecycle:extensions:1.0.0-alpha4"
compile "android.arch.persistence.room:runtime:1.0.0-alpha4"
annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha4"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha4"
add maven to project based gradle
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
it will compile easily
am find solution work with me Room
Dependencies for Room, including testing Room migrations and Room RxJava
dependencies {
def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version" // use kapt for Kotlin
// optional - RxJava support for Room
implementation "android.arch.persistence.room:rxjava2:$room_version"
// optional - Guava support for Room, including Optional and ListenableFuture
implementation "android.arch.persistence.room:guava:$room_version"
// Test helpers
testImplementation "android.arch.persistence.room:testing:$room_version"
}
as the document says: https://developer.android.com/topic/libraries/architecture/adding-components
you can change "https://maven.google.com" to "https://dl.google.com/dl/android/maven2/" to solve the problem.
You require latest gradle version 'com.android.tools.build:gradle:3.0.0-alpha2' and Studio Version 3.0+ to use Room
Just add maven { url 'https://maven.google.com' } to your project gradle
open preference for mac or you can open setting for windows then search proxy setting inside the open window then unchecked proxy authentication it will work

Error:(9, 0) Could not find method compile() for arguments [io.reactivex:rxandroid:1.2.1]

When I sync my android studio project it get
Error:(9, 0) Could not find method compile() for arguments [io.reactivex:rxandroid:1.2.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
My build.gradle file is below
// 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:2.2.3'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.9'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You call this library in the wrong section. There are two kinds of build.gradle files. For more information build.gradle
In order to solve the problem, you should add required dependencies into build.gradle in the module level, to be exact app\build.gradle
Remove your dependencies from root '`build.gradle' and paste them in app\build.gradle.
android {
compileSdkVersion // YOURS
buildToolsVersion // YOURS
...........
}
dependencies {
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.9'
}
FYI
It's better to use the latest version,
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'

Categories

Resources