every time i create a new android studio project, the layout editor will be broken because the dependency com.android.support:appcompat-v7:28.0.0-alpha3 will spoil the layout editor with:
Render problem
Failed to load AppCompat ActionBar with unknown error.
Tip: Try to refresh the layout.
thanks to user JLC answer, the problem is solved, but if i create a new project, the problem will come back
so my question is how can i change it so that every new project will use dependency com.android.support:appcompat-v7:27.1.1 instead? thanks
If you are using Android Studio 3.0 and above then make sure you are using the same content in build.gradle like-
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
And for below Android Studio 3.0 and starting from support libraries 26.+ your project build.gradle must look like this-
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
For the detailed knowledge check the below docs-
Build Dependencies
Building Android apps
Configure your build
Related
I'm trying to add a maven repository to my project by adding it to build.gradle
repositories {
maven {
url "https://XXX/"
}
}
It works fine when I build in the console. When I try to build it with Android Studio, the dependency that I use in that repository is not found.
When I add the repository to File > project structure > project > Default library Repository bam! it works.
What am I doing wrong? why do I have to duplicate the information? What is exactly the purpose of that configuration since it's already in build.gradle file?
Thank you
Aghilas, i am not sure if it is issue with https or http.
I am putting down what works for me. you can add 'maven()' in the block depending on that repo is required for buildscript functionality or for your app.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2
I see this error when I open my projectI cant install constraint-layout:1.0.2, there is some error strong text
Your project's build.gradle should have the content as below.
All the Google specific dependencies are now hosted on their own Maven Repository.
If you still find it confusing, just create a new Project from scratch using Android Studio 3.0.1 and all the dependencies would be properly configured.
buildscript {
repositories {
google() // Speficically this entry
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
First of all, make sure to update your Android Studio. Second thing, make sure you import the Google maven repository into your project gradle file. Then, you should be able to install ConstraintLayout.
Here's the solution:
repositories {
maven {
url 'https://maven.google.com'
}
}
then add this line in dependencies:
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support.constraint:constraint-layout-solver:1.0.2'
I'm getting the following error when trying to compile my app:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':myProject'.
> Could not resolve all files for configuration ':myProject:classpath'.
> Could not find org.jetbrains.trove4j:trove4j:20160824.
Searched in the following locations:
https://repo1.maven.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
https://repo1.maven.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
https://maven.fabric.io/public/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
https://maven.fabric.io/public/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
https://maven.google.com/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
https://maven.google.com/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
Required by:
project :metam > com.android.tools.build:gradle:3.0.0-beta2 > com.android.tools.build:gradle-core:3.0.0-beta2 >
com.android.tools.lint:lint:26.0.0-beta2 > com.android.tools.lint:lint-checks:26.0.0-beta2 > com.android.tools.lint:lint-
api:26.0.0-beta2 > com.android.tools.external.com-intellij:intellij-core:26.0.0-beta2
It appears a library the IDE needs is missing?
this issue can be resolved by adding jcenter() as a repository in the buildscript section.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
}
}
Additional to Snicolas' answer:
If you have something like:
allprojects {
repositories {
mavenCentral()
google()
jcenter() //also add it here!!!
}
}
In your build.gradle file; also add it there.
Since jCenter will close in May, you should change root/build.gradle so:
buildscript {
repositories {
google()
gradlePluginPortal()
}
}
allprojects {
repositories {
google()
mavenCentral()
// org.jetbrains.trove4j:trove4j:20160824.
gradlePluginPortal()
}
}
See also https://stackoverflow.com/a/66168563/2914140 to add libraries not included in Maven.
Now we can build apk without errors.
If you're seeing this error after May 1st 2021, it's probably because jcenter is shut down. It's needed by the Android Gradle Plugin (AGP). Google devs have said they're using a newer version of the library that can be got from mavenCentral() as of AGP 7 and hoping to backport that into AGP 4.2 and 4.1. So first of all, try and upgrade to AGP 7. And if I haven't edited this post with updates, check to see is it in any lower AGP versions.
But if you can't upgrade AGP, as of initial time of posting (February 2021), the only repo I could find with the trove package is on pentaho, which seems to be owned by Hitachi so I presume it's safe.
buildscript {
repositories {
maven { url "https://nexus.pentaho.org/content/groups/omni" }
}
dependencies {
classpath 'org.jetbrains.trove4j:trove4j:20160824'
}
}
This is NOT an ideal solution. This repo could be intended to be private for all I know. Look for a better answer that might be posted after me.
I solved this problem
deleting in build.gradlew
repositories {
jcenter()
}
And change the mavenCentral() to jcenter() and deleting google()
Migrating away from jcenter? jcenter will sunset on the 1st of May
You may face this issue if you are migrating away from jcenter. The issue happens because Trove4j library was being fetched from jcenter and you removed jcenter repository while migrating away from jcenter.
Solution:
Add the following to the project build.gradle:
maven { url 'https://plugins.gradle.org/m2/' }
It should be added to:
build.gradle(peoject) -> buildscript -> repositories
build.gradle(peoject) -> allprojects -> repositories
buildscript {
repositories {
google()
mavenCentral()
// ** Add this line **
maven { url 'https://plugins.gradle.org/m2/' }
}
}
allprojects {
repositories {
google()
mavenCentral()
// ** Add this line **
maven { url 'https://plugins.gradle.org/m2/' }
}
}
Since jcenter will sunset on 1st of May, 2021. jcenter repository should be removed from the project. This means that all occurrences to "jcenter()" should be removed. This can lead to an issues with the libraries hosted by jcenter. You should provide another repository that host the library such as maven. Some unmaintained libraries maybe are not moved to any other repository. In this case, you might need to consider opening an issue for the library or not using it. You will face all these issues on the 1st of May and you may be unable to build your app if you are not doing the migration now.
Just delete .idea,.gradle and gradle folder and restart your application.
Try to replace mavenCentral() with jcenter() in your build.gradle file
allprojects {
repositories {
jcenter()
//.......
}
}
Go to Help->About in Android Studio and check your version. Enter that vesion in build.gradle App Mudule & same for project build.gradle as done in the
classpath line here:
buildscript {
...
repositories {
...
}
dependencies {
...
classpath "com.android.tools.build:gradle:{THREE.DIGIT.VERSION}"
}
}
This was happening to me every time I upgraded the Gradle Plugin, so what I did and worked:
Delete your package-lock.json or yarn.lock
Run npm i or yarn to update all node modules in your project
Rename your ios project to ios_ for example
Run react-native link to link all dependencies again to your android project
Rename back ios_ to ios
Check the file (project/build.gradle) what Gradle Plugin version you're using. The version 3.4.1 worked for me.
Check your Gradle version (gradle/wrapper/gradle-wrapper.properties), the version 5.4.1 worked here.
Open your Android project using Android Studio, navigate to Build > "Rebuild project"
And finally, try sync/build again.
Hope it can help someone.
I installed the Kotlin plugin into my app (v. v1.1.1-release-Studio2.2-1) and then selected "Configure Kotlin in Project" I selected compiler and runtime version of 1.0.7. Kotlin updated my Gradle files. Now when I try to build in I get:
Error: A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7.
Required by:
MyApplication:app:unspecified
I'm not sure what I'm missing here.
replace
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
^
|
JRE = Java Runtime Environment
with
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
^
|
JDK = Java Development Kit
Since the version with jre is absolute , just replace and sync the project
Official Documentation here Thanks for the link # ROMANARMY
In Project level build.gradle use only this version
ext.kotlin_version = '1.3.31'
Remove other versions
This will only work with the latest version of android studio 3.4
UPDATE: Try to use the latest version of kotlin with latest Android studio to avoid an error.
The split of kotlin-stdlib into kotlin-stdlib-jre7 and kotlin-stdlib-jre8 was only introduced with Kotlin 1.1, that's why the dependency cannot be resolved, the package version simply does not exist.
It looks like the update to your project files failed at some point and set the Kotlin version to 1.0.7. If this is a new project and there's nothing holding you back from using 1.1.1, I'd switch to that. Your problem should be gone after doing this.
If you hereafter removing Jcenter from Gradle then add this to your gradle
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
So main point is that, add mavenCentral() and maven { url "https://jitpack.io" } in gradle
In "build.gradle" file, change current Kotlin version that line and press synk:
ext.kotlin_version = '1.1.1'
/// That will look like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.1'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
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
}
}
A new solution if you use Android Studio 3.2, I solved this issue by added mavenCentral() to build.gradle of the project:
buildscript {
ext.kotlin_version = '1.3.0'
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
You should add the line as this order, the credited is for this answer
Starting with Kotlin 1.1.2, the dependencies with group org.jetbrains.kotlin are by default resolved with the version taken from the applied plugin. You can provide the version manually using the full dependency notation like:
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
If you're targeting JDK 7 or JDK 8, you can use extended versions of the Kotlin standard library which contain additional extension functions for APIs added in new JDK versions. Instead of kotlin-stdlib, use one of the following dependencies:
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
buildscript {
**ext.kotlin_version = '1.1.1'** //Add this line
repositories {
**jcenter()** //Add this line
google()
}
dependencies {
// classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
**jcenter()** //Add this line
google()
maven { url "https://jitpack.io" }
}
}
I have solved this issue using deselection of the Offline work option in Settings
This is what worked for me:
Using Gradle 4.8.1
buildscript {
ext.kotlin_version = '1.1.1'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'}
}
allprojects {
repositories {
mavenLocal()
jcenter()
google()
maven {
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://dl.bintray.com/kotlin/kotlin-dev/'
}
}
}
If you are using Android Studio 3.2 & above,then issue will be solved by adding google() & jcenter() to build.gradle of the project:
repositories {
google()
jcenter()
}
Please check current version of your Kotlin in below path,
C:\Program Files\Android\Android Studio\gradle\m2repository\org\jetbrains\kotlin\kotlin-stdlib\1.0.5
change to that version (1.0.5) in project level gradle file.
You can see in your above path does not mentioned any Java - jre version, so remove in your app level gradle file as below,
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
build.gradle (Project)
buildScript {
...
dependencies {
...
classpath 'com.android.tools.build:gradle:4.0.0-rc01'
}
}
gradle/wrapper/gradle-wrapper.properties
...
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
Some libraries require the updated gradle. Such as:
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines"
GL
In case a (transitive) dependency still uses the jre variant of the Kotlin library, you can force the use of the jdk variant with the help of a resolution strategy:
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
details.requested.with {
if (group == "org.jetbrains.kotlin" && name.startsWith("kotlin-stdlib-jre")) {
details.useTarget(group: group, name: name.replace("jre", "jdk"), version: version)
details.because("Force use of 'kotlin-stdlib-jdk' in favor of deprecated 'kotlin-stdlib-jre'.")
}
}
}
}
}
After fixing the build.gradle version, It started working
4.0.0 to 3.5.0
Reload sdk maybe the problem is solved
Simple Steps:
Click File > Project Structure
Click Dependencies >
Find and Click org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.21 (or whatever your current version is)
Under Details > update section, click [update variable][update
dependencies]
Click Ok
In my case problem solved by adding the following lines in build.gradle file:
allprojects {
repositories {
jcenter()
google()
maven { url "https://jitpack.io" } //remember to add this line
}
}
Recently I have updated my Android Studio to latest version from Latest Android Studio Canary Build: 2.0 Preview
After updating to the new version, my current working directory stop working at all. Every single time when I am trying to clean and build a project they will give me an error like this
Blockquote
'Error:Could not find com.android.tools.build:gradle:2.0.0-alpha2.
Searched in the following locations:
file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/android/tools/build/gradle/2.0.0-alpha2/gradle-2.0.0-alpha2.pom
file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/android/tools/build/gradle/2.0.0-alpha2/gradle-2.0.0-alpha2.jar
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.0.0-alpha2/gradle-2.0.0-alpha2.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.0.0-alpha2/gradle-2.0.0-alpha2.jar
Required by:
:android 3:unspecified'
Anyone have an idea how to solve this problem. Thanks in advance.
UPDATE: I am using a Mac machine and installation directory look like
Apparently the build tools have been moved from maven to jcenter so you need to change the code from:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha2'
}
}
to this
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha2'
}
}
More details on the changes:
Android Tools Project Site
http://tools.android.com/recent
Android Developer Tools community https://plus.google.com/communities/114791428968349268860/stream/7f20992b-7d9a-4309-9d94-6fbe08f0ad6e
In the main build.gradle file, add jcenter() as main repo, just like that :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Remove other repositories or make sure jcenter is the first one.
On my side travis build failed with error message "Could not find com.android.tools.build:gradle:3.0.1".
After addeing google() as additional repository the problem was gone.
buildscript {
repositories {
jcenter()
google()
My local build did not fail because i had installed before "com.android.tools.build:gradle:3.0.1" with anddroid-sdk-manager
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
repositories block should be in buildscript.
Check to see if gradle 2.0.0-alpha1 is available on your system. Look in your android/tools/build/gradle folder. In my case, despite the confusing message "This project is using a preview version of the Gradle plugin (2.0.0-alpha2) and a newer version is available (2.0.0-alpha2) You can update to 2.0.0-alpha2." the version in my folder was 2.0.0-alpha1, and changing my build.gradle to:
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
fixed my build problem.
I removed the newest folder gradle-4.1-all in C:\Users\YOUR_USER_NAME\ .gradle\wrapper\dists\ and then I created a new project in Android Studio and the following message disappeared:
"Gradle sync failed: Could not find com.android.tools.build: Gradle:
3.0.0-beta6. "
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried something like
platfoms > android > cordova >lib > builders > Gradlebuilder.js
Downloaded zip and given path
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'file\:///C:/MyPC/Documents/softwares/gradle-2.14.1-all.zip';
and linking path is
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven{url "http://jcenter.bintray.com"}
}
}
It worked for me.
this is for Ionic developers *
This seems to be a very long issue(years on the making)...most of the hints are about settings and gradle scripts. After a few days of digging around and backing from BumbleBee to 3.4.2 I kept on getting the same issue no matter what I tried. In the end the gradle on line URLs are blocked for my location due to network ... so easy for Google to say check the access is proper and not keep us blindfolded throwing darts in the dark