I tried Different methods but the problem did not solved, I even reinstalled android studio but still getting same issue:
[Fatal Error] annotations-26.1.1.pom:2:1: Content is not allowed in prolog.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'myapp'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools:annotations:26.1.1.
Required by:
project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.databinding:compilerCommon:3.1.1
> Could not resolve com.android.tools:annotations:26.1.1.
> Could not parse POM https://dl.google.com/dl/android/maven2/com/android/tools/annotations/26.1.1/annotations-26.1.1.pom
> Content is not allowed in prolog.
> Could not resolve com.android.tools:annotations:26.1.1.
Required by:
project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools.build:builder-model:3.1.1
project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools:common:26.1.1
project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools.analytics-library:shared:26.1.1
project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools.analytics-library:tracker:26.1.1
project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools:sdklib:26.1.1 > com.android.tools.layoutlib:layoutlib-api:26.1.1
> Could not resolve com.android.tools:annotations:26.1.1.
> Could not parse POM https://dl.google.com/dl/android/maven2/com/android/tools/annotations/26.1.1/annotations-26.1.1.pom
> Content is not allowed in prolog.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
CONFIGURE FAILED in 34s
Content is not allowed in prolog.
app\build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.kakarot.myapp"
minSdkVersion 24
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Project (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.1.1'
// 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 added the app module build.gradle and project build.gradle.
Worked on Android Studio 3.0.1.
Close android studio if it is open already and then delete all the contents of these directories.
C:\Users\USER_NAME\.gradle\caches
C:\Users\USER_NAME\.android\build-cache
C:\Users\USER_NAME\.android\cache
Start Android Studio and and it will probably work. It may take a little bit time to load for the first time.
After a lot of struggle and searching online, i finally solve the problem.
I deleted all the cached folders in gradle and when i build my new project. It work like magic.
Thanks #ישו אוהב אותך for reply and trying to help me.
I solved this by just deleting the cache folders in .gradle folder. This was only thing that worked (it also works for the android studio canary)
Related
I have rather a curiosity than a problem which in its very own place could lead to a problem if not solved;
I've found out for building an android app you can invoke gradlew(.bat) at root dir of a project. so when I ran for instance
gradlew tasks
it generates the followings
Downloading https://services.gradle.org/distributions/gradle-4.1-all.zip
Exception in thread "main" java.net.UnknownHostException: services.gradle.org
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.wrapper.Install$1.call(Install.java:61)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
I simply can connect to internet and let it to download the necessary file,
But here my mentioned curiosity originates:
How it comes that when I build(debug) the app through android studio, android studio generates the APK with no error at all?
In android studio I defined 'local gradle distribution' to be used instead of 'default gradle wrapper' as appeared in the link below:
captured_and_std_img
Back to command-line, Afterwards I defined the environment variable GRADLE_HOME and tried one more time to build the app using gradle which is now a recognized command, as following:
gradle assembleDebug
But it also produced the followings:
Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'MyApplication2'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.0.1.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.0.1.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
> dl.google.com
> Could not resolve com.android.tools.build:gradle:3.0.1.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
> jcenter.bintray.com
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 38s
I'm not sure if assembleDebug could be used as a parameter with gradle command, I know you could use it with gradlew, but I still don't want to download the file (gradle-4.1-all.zip) and want to build the APK using 'local gradle distribution'. :))
Any possible solution would be appreciated
EDIT:
build.gradle(project) file contents:
//task wrapper(type: Wrapper) {
// gradleVersion = '4.1'
//}
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(module):
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:25.3.1'
}
Check your Android Studio has a proxy and check your gradle.properties has a proxy too
I noticed that Android Studio creates a temporary file each time I debug an app and pass that file as an argument to gradle command-line:
2022-04-03 10:37:18,658 [ thread 18] INFO - oject.common.GradleInitScripts - init script file sync.local.repo contents "allprojects {\n buildscript {\n repositories {\n maven { url 'C:\\\\Program Files\\\\Android\\\\Android Studio\\\\gradle\\\\m2repository'}\n }\n }\n repositories {\n maven { url 'C:\\\\Program Files\\\\Android\\\\Android Studio\\\\gradle\\\\m2repository'}\n }\n}\n"
the content in a normal perspective:
allprojects {
buildscript {
repositories {
maven { url 'C:\\Program Files\\Android\\Android Studio\\gradle\\m2repository'}
}
}
repositories {
maven { url 'C:\\Program Files\\Android\\Android Studio\\gradle\\m2repository'}
}
}
Passing to gradle command-line with --init-script option:
gradle --init-script path/to/file --offline assembleDebug
--init-script option prabably could be defined in gradle.properties file, I'v not tested!
I am trying to build a flutter app for Azure Notifications hub using the sample code under git and my buildgradle file is as below
build.gradle
group 'com.swiftoffice.azure_notificationhubs_flutter'
version '1.0'
buildscript {
repositories {
google()
jcenter()
maven {
url "https://dl.bintray.com/microsoftazuremobile/SDK"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
rootProject.allprojects {
repositories {
google()
jcenter()
maven {
url "https://dl.bintray.com/microsoftazuremobile/SDK"
}
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.microsoft.azure:notification-hubs-android-sdk:0.6#aar'
}
repositories {
maven {
url "https://dl.bintray.com/microsoftazuremobile/SDK"
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
}
repositories {
maven {
url "https://dl.bintray.com/microsoftazuremobile/SDK"
}
}
While trying to build I am getting TIME OUT error, but when I tried to download the jars directly from the above URL using browser, it worked.
I have no proxy enabled under settings. Please tell me where under the project structure I can place the jars manually, so the build process continues
Error
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:processDebugResources'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve com.microsoft.azure:notification-hubs-android-sdk:0.6.
Required by:
project :app > project :azure_notificationhubs_flutter
> Could not resolve com.microsoft.azure:notification-hubs-android-sdk:0.6.
> Could not get resource 'http://download.flutter.io/com/microsoft/azure/notification-hubs-android-sdk/0.6/notification-hubs-android-sdk-0.6.pom'.
> Could not HEAD 'http://download.flutter.io/com/microsoft/azure/notification-hubs-android-sdk/0.6/notification-hubs-android-sdk-0.6.pom'.
> Read timed out
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 37s
Finished with error: Gradle task assembleDebug failed with exit code 1
I was trying to add firebase auth to my android project but getting this error.
I have tried adding 'com.google.firebase:firebase-core:16.0.3' too but its taking more than 40 mins and still not syncing the gradle.
This is build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "myaid.startup"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
This is app.gradle file:
// 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.3.2'
classpath 'com.google.gms:google-services:4.1.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
}
This is the error:
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'MyAid'.
Could not resolve all artifacts for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:3.3.2.
Required by:
project :
Could not resolve com.android.tools.build:gradle:3.3.2.
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Connection reset
Could not resolve com.android.tools.build:gradle:3.3.2.
Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Connection reset
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
CONFIGURE FAILED in 2m 13s ERROR: Connection reset
I have resolved this problem by removing all my .gradle files, SDK files, .m2 files, .androidstudio files and then re-installing it.
Followed this answer: How to completely uninstall Android Studio
Please check your gradle's proxy settings. Enable it or disable it in the following file:
~/.gradle/gradle.properties
Like:
systemProp.https.proxyPort=1080
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
Advices:
If your connection to repositories is not stable, use a proxy
instead of direct connection.
If you used to use a proxy for
gradle, check if it is still working.
I checked and updated my android SDK (also react-native-image-crop-picker), but I couldn't find the version of support 27.+ all the time.
below are more information
FAILURE: Build failed with an exception.
-------------------------------------------------------
What went wrong:
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugApk'.
A problem occurred configuring project ':react-native-image-crop-picker'.
Could not resolve all dependencies for configuration ':react-native-image-crop-picker:_debugPublishCopy'.
Could not find com.android.support:appcompat-v7:27.1.0.
Searched in the following locations:
file:/D:/AndroidSDK/extras/android/m2repository/com/android/support/appcompat-v7/27.1.0/appcompat-v7-27.1.0.pom
file:/D:/AndroidSDK/extras/android/m2repository/com/android/support/appcompat-v7/27.1.0/appcompat-v7-27.1.0.jar
file:/C:/Users/***/Desktop/LastDesign/InsurAgentApp/android/sdk-manager/com/android/support/appcompat-v7/27.1.0/appcompat-v7-27.1.0.jar
Required by:
InsurAgentApp:react-native-image-crop-picker:unspecified > com.facebook.react:react-native:0.54.2
Could not find com.android.support:appcompat-v7:27.1.0.
Searched in the following locations:
file:/D:/AndroidSDK/extras/android/m2repository/com/android/support/appcompat-v7/27.1.0/appcompat-v7-27.1.0.pom
file:/D:/AndroidSDK/extras/android/m2repository/com/android/support/appcompat-v7/27.1.0/appcompat-v7-27.1.0.jar
file:/C:/Users/***/Desktop/LastDesign/InsurAgentApp/android/sdk-manager/com/android/support/appcompat-v7/27.1.0/appcompat-v7-27.1.0.jar
Required by:
InsurAgentApp:react-native-image-crop-picker:unspecified > com.github.yalantis:ucrop:2.2.2-native
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode 1
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'com.facebook.react:react-native:+'
compile 'com.github.yalantis:ucrop:2.2.2-native'
compile 'id.zelory:compressor:2.1.0'
}
It seems that Gradle is looking for the specified libraries in your local storage.
Try adding the Google's Maven repository to your top-level build.gradle file.
Check if you have offline work on.
Go to:
File > Settings > write "offline" on the search bar > under Gradle, see if Offline Work is checked. If so, uncheck it.
My android app is nearing completion, but android studio now seems to be unusable. There are red lines everywhere and the message, "Gradle project sync completed with some errors." I've googled, I've watched youtube videos, but the studio version they're using is older than mine, the UI is different.
I have tried various solutions from SO and around the internet including building the project, changing from local gradle distribution to default wrapper; changing back again; unchecking all the boxes on the android sdk mangager and rechecking them, changing the classpath so that t matches the one in settings; changing it back. Everything is making this worse.
Now, when pressing run, it's showing me an edit configuration window, with the message, "Gradle project sync failed. Please fix your project and try again."
Honestly, I'm just using android-studio to write an app. I don't know how it works or what goes on behind the scenes. I'm a little over my head here.
build.gradle code:
// 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.1.2'
// 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
}
app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.example.lp1"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.+'
compile 'com.android.support:design:24.2.0'
}
edit: changed appcompat-v7:24.+' to appcompat-v7:24.2.0'
log now reads:
Information:Gradle tasks [:app:assembleDebug]
[Fatal Error] appcompat-v7-24.2.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] recyclerview-v7-24.2.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] support-annotations-24.2.0.pom:2:1: Content is not allowed in prolog.
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve com.android.support:appcompat-v7:24.2.0.
Required by:
Lp1:app:unspecified
Lp1:app:unspecified > com.android.support:design:24.2.0
> Could not resolve com.android.support:appcompat-v7:24.2.0.
> Could not parse POM /home/david/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/24.2.0/appcompat-v7-24.2.0.pom
> Content is not allowed in prolog.
> Could not resolve com.android.support:recyclerview-v7:24.2.0.
Required by:
Lp1:app:unspecified > com.android.support:design:24.2.0
> Could not resolve com.android.support:recyclerview-v7:24.2.0.
> Could not parse POM /home/david/Android/Sdk/extras/android/m2repository/com/android/support/recyclerview-v7/24.2.0/recyclerview-v7-24.2.0.pom
> Content is not allowed in prolog.
> Could not resolve com.android.support:support-annotations:24.2.0.
Required by:
Lp1:app:unspecified > com.android.support:design:24.2.0 > com.android.support:support-v4:24.2.0 > com.android.support:support-compat:24.2.0
> Could not resolve com.android.support:support-annotations:24.2.0.
> Could not parse POM /home/david/Android/Sdk/extras/android/m2repository/com/android/support/support-annotations/24.2.0/support-annotations-24.2.0.pom
> Content is not allowed in prolog.
Information:BUILD FAILED
Information:Total time: 3.244 secs
Information:1 error
Information:0 warnings
Information:See complete output in console