I'm very new to Android studio and Gradle so please be specific with your suggestions.
I downloaded this git repository because I needed a template of an app with OCR integrated into it. The project was built in Eclipse so I used the Android Studio Import tool to convert it to an Android Studio project. After attempting to build the project and resolving the first few errors by clicking on the links inside the errors, I got the "Could not find method implementation()" error which I can't seem to resolve.
NOTE - I installed Android Studio just today so I have everything updated.
This is what my build.gradle file looks like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
implementation 'com.rmtheis:tess-two:9.0.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
You need to add this
implementation 'com.rmtheis:tess-two:9.0.0'
in build.gradle app file under dependencies instead of build.gradle project file.
build.gradle
dependencies {
//...
implementation 'com.rmtheis:tess-two:9.0.0'
//...
}
Related
I am new in Android Studio. After setup, When I am trying to import an application I am getting that error So that gradle not able to build.
Error:> Could not initialize class com.android.repository.api.RepoManager
I checked that my classpath setting for Java is fine. I am running Windows OS. Does anyone know the source of the error?
I had this issue while trying to run a 5-year-old android project. Following these steps fixed the issue for me:
1- update gradle version in the project level build.gradle file from
classpath 'com.android.tools.build:gradle:2.2.2'
to
classpath 'com.android.tools.build:gradle:7.1.1'
2- add google() to the project repositories
allprojects {
repositories {
jcenter()
mavenLocal()
google()
}}
and in buildScript block as well:
buildscript {
repositories {
jcenter()
mavenLocal()
google()
} dependencies {...}}
3- update gradle version in gradle-wrapper.properties file to an up-to-date version, I updated to 7.2
4- In the app level build.gradle file, in the dependencies block, I changed compile to implementation
5- sync the project
A downgrade to Android Studio 4.0 fixed the error for me.
I'm totally new to android studio and came up to this error that says it can not download gradle-3.5.1.pom and gradle-3.5.1.jar from google or jcenter repositories. But when I tried downloading them manually it was easy and straight forward though.
Here is the error text :
ERROR: Could not find com.android.tools.build:gradle:3.5.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.pom
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.jar
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.jar
Required by:
project :
Open File
I know that this is going to make me crazy because these gradle stuff always been a problem to all.
Make sure you have google() repo in your project's level build.gradle file.
Here's an example:
build.gradle
buildscript {
repositories {
google() // check if you have this
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
}
}
allprojects {
repositories {
google() // and this
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Disable Offline Work in Android studio if you have enabled the checkbox and sync project.
Once the project is synced, you can enable the checkbox and run the app as long as you do not add another dependency manually.
It will automatically download the required dependencies.
File>Settings>Build>Gradle
I was trying to gradle build a plain Java Android project. It was an ADT project imported to Android Studio. To my astonishment, at one point Gradle tried to download the Kotlin compiler!
* What went wrong:
Execution failed for task ':app:lint'.
> Could not resolve all files for configuration ':app:lintClassPath'.
> Could not download kotlin-compiler.jar (com.android.tools.external.com-intellij:kotlin-compiler:26.2.0)
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/external/com-intellij/kotlin-compiler/26.2.0/kotlin-compiler-26.2.0.jar'.
> Read timed out
Why the heck did gradle attempt downloading a big package like the Kotlin compiler
How do I prevent that?
More generally, how do make gradle ask me before it tries to download anything or at least prevent it from downloading non-dependencies? Such things should be installed by my distro's package manager, after all!
1) Because Gradle supports linting Kotlin code, which requires parsing it, which is implemented using classes in the Kotlin compiler.
2) By not using the lint task I guess?
3) The Kotlin compiler is a dependency. Gradle requires a specific version of this dependency in a specific layout and in a specific location, and it can't use a version installed by your package manager.
change
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
to
buildscript {
repositories {
google()
maven {
url "https://maven2.google.com"
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
maven {
url "https://maven2.google.com"
}
jcenter()
}
}
Any clarification on this subject would be greatly appreciated.
I know this has been answered many times but my current issue is that I don't know where or in what file (s) to add this to:
buildscript {
repositories {
...
google() // <-- add this
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
And this:
allprojects {
repositories {
jcenter()
google()
}
}
Or if that even solves my issue, since I haven't tested it yet.
My initial problem:
The issue seemed to appear after updating both gradle and Android studio.
I'm currently working on a project using libGDX to make an Android app called CastleCrush. When I try to launch a desktop application to test it, it won't launch, and I get this error:
Error:Gradle: A problem occurred configuring root project
'CastleCrush'.
> Could not resolve all files for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
file:/Users/TrulsElg/.m2/repository/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
file:/Users/TrulsElg/.m2/repository/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
project :
When launching with a virtual Android device it launches just fine.
I'm not working on this project alone and collaboration is done via Git, if that makes any difference. None of the other project members seem to have this issue.
You add this to your Project build.gradle file. its the gradle file that is called build.gradle(Project: your project name). It is usually the first one if you are in the Android project view
Could not find com.android.tools.build:gradle:3.0.1.
Gradle trying to find Android Gradle plugin version 3.0.1 artifact from your local maven repo (inside your computer) and from your listed three remote repository (maven2, oss.sonatype and jcenter).
But not succeeded because given artifact is not available on those repository.
Artifact com.android.tools.build:gradle:3.0.1 is available on google repository.
Find build.gradle file inside your libgdx project and add google maven repo inside allprojects tag
repositories {
mavenLocal()
mavenCentral()
maven { // <-- Add this
url 'https://maven.google.com/'
name 'Google'
}
}
If you're using Android Studio 3.0 or latter version
repositories {
mavenLocal()
mavenCentral()
google() //---> Add this
}
Make sure you're proper internet connection.
Cross-check that, you've not ticked offline work in Global gradle settings.
Before proceeding further take a look on LibGdx doesn't working after updating Gradle (Android Studio 3.0)
I am trying to import an Android project in Eclipse., but after importing the project, I am getting errors which say "Missing android-support-v7-appcompat", "Missing Facebook SDK","Missing Google Play services lib" and "Missing library".
I can understand that I am missing libraries but do not have any clue how to add those libraries, as I am new in Android development environment.
Here, is a screenshot of the error http://screencast.com/t/iWXLkK8glkF
Delete the extra apply in the first line of your gradle file...
UPDATE:
You know how you have two gradle files? One for your application (The one you are working on right now) and the other one which is a top level build.gradle file? Put the below code in the top level build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}