Gradle error when generating signed APK in Android Studio - android

I am new to Android Studio. My build compiles successfully until I try to generate a signed APK. Here is my current build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have looked at previous Stack Overflow answers and they all recommend putting the google() repository first, which I have done. I have also tried just adding "com.android.tools.lint:lint-gradle:27.1.1" to the dependencies section, but that has not worked.
Execution failed for task ':app:lintVitalRelease'.
> Could not resolve all files for configuration ':app:lintClassPath'.
> Could not resolve com.android.tools.lint:lint-gradle:27.1.1.
Required by:
project :app
> Could not resolve com.android.tools.lint:lint-gradle:27.1.1.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle/27.1.1/lint-gradle-27.1.1.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle/27.1.1/lint-gradle-27.1.1.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve com.android.tools.lint:lint-gradle:27.1.1.
Any assistance is appreciated!

If you are not actively linting a project, it might be easier just to disable it.
android {
...
lintOptions {
checkReleaseBuilds false
}
}
That code should prevent that particular gradle task for running.

Related

> Could not resolve all files for configuration ':app:_internal_aapt2_binary'

i tried to build and i got this error
Execution failed for task ':app:mergeDebugResources'.
Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
Could not find aapt2-4.1.2-6503028-windows.jar (com.android.tools.build:aapt2:4.1.2-6503028).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/4.1.2-6503028/aapt2-4.1.2-6503028-windows.jar
Possible solution:
Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
that's my build gradle
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build gradle version: 6.4
how can i fix this?
Please check if you have an active internet connection
There was a failed download most probably
You can also try disabling the offline mode for gradle
Look Here
In the above image,Toggle offline mode sign

Could not resolve all files for configuration: ':app:debugRuntimeClasspath'

I am attempting to implement a third party SDK bundle when I ran react-native run-android I got the following error:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not resolve com.ts.auth-control-sdk:5.1.1.
Required by:
project :app
> Could not resolve com.ts:auth-control-sdk:5.1.1.
> Could not get resource 'https://www.jitpack.io/com/ts/auth-control-sdk/5.1.1/auth-control-sdk-5.1.1.pom'.
> Could not GET 'https://www.jitpack.io/com/ts/auth-control-sdk/5.1.1/auth-control-sdk-5.1.1.pom'.
> sun.security.validator.Validator.Exception: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target
Inside of my app/build.gradle file, I have the following setup:
dependencies {
...
implementation "com.ts:auth-control-sdk:5.1.1:arr"
...
}
Inside my android/build.gradle file I have the following:
allprojects {
repositories {
...
maven {
url("$rootDir/../com/ts/auth-control-sdk/5.1.1")
}
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
I am not even sure whether this third-party SDK even exists inside of Jitpack repository.
Did I err in the way I implemented the dependency?
As far as the maven directory, per the documentation I placed a folder called com/ inside the root folder of the mobile app and the folder structure of it is: com > ts > auth-control-sdk > 5.1.1
It seems as though if it's inside of maven {} it will go to Jitpack repo and look for library as opposed to just going to the root folder of the project. Am I correct in this conclusion?
By the way I placed it inside of maven {} because their documentation says to do so.
Could it be that $rootDir is what indicates to maven to go look at Jitpack since below all the libraries there is that:
maven { url 'https://www.jitpack.io' }
Am I correct in concluding that $rootDir is referencing that jitpack url and not the root directory of the application?
Well, I gave it a shot and came away with the same exact error.
I believe I am correctly notating the file in accordance with this documentation:
https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/dsl/DependencyHandler.html
I am not notating it like so: implementation ("com.ts:auth-control-sdk-5.1.1#arr") { transitive=true }
and removed the following : maven { url 'https://www.jitpack.io' }
But then I get this error:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all the files for configuration 'app:debugRuntimeClasspath'.
Could not find com.ts:auth-control-sdk-5.1.1:.
Required by
project :app
What worked for me was inside of android/build.gradle:
maven {
url("$rootDir/..")
}
I also removed:
maven {
url { www.jitpack.io/ }
}
So that it would not keep going to the Jitpack repo to look for that local directory.
Then inside of app/build.gradle:
dependencies {
...
implementation('com.ts:auth-control-sdk:5.1.1#aar') { transitive=true }
}
**go to your setting.gradle and write the below line of code for the the control
of
libraries or dependencies **
maven { url 'https://jitpack.io' }
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url 'https://jitpack.io' }
}
}
rootProject.name = "Xyz"
include ':app'
If you have facing Gradle dependencies iss> Task :app:mergeDebugNativeLibs FAILED
Error Image
FAILURE: Build completed with 6 failures.
Execution failed for task ':app:checkDebugDuplicateClasses'. Execution
failed for task ':app:desugarDebugFileDependencies'. Execution failed
for task ':app:checkDebugAarMetadata'. Execution failed for task
':app:mergeDebugAssets'. Execution failed for task
':app:mergeDebugAssets'. Execution failed for task
':app:mergeDebugNativeLibs'.ue
in android studio?
Answer:
If you using ANDROID 11 in your project then try the below options
Go to settings
Click option to Gradle, Execution, deployment
Then click build Tools
Solution Image
choose to gradle
Then disable the offline mode then Run

Could not find com.android.tools.build:gradle:3.4.2

After installing nativescript-plugin-firebase I can't build my app anynore with tns build android.
I get this error:
nativescript-plugin-firebase: running release build or change in environment detected, forcing prepare!
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'nativescript_plugin_firebase'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.4.2.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.pom
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.jar
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.jar
Required by:
project :
Here is my platforms/android/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.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is platforms/android/app/build.gradle:
Here is platforms/tempPlugin/nativescript_plugin_firebase/build.gradle
You probably have another plugin depending on Google Play Services
(Google Maps, perhaps). We need to pin to a specific play services
version to play nice with others, so open
app/App_Resources/Android/app.gradle and add:
Example
android {
project.ext {
googlePlayServicesVersion = "15.0.0" //"16.0.+
}
configurations.all {
resolutionStrategy.force "com.google.android.gms:play-services-auth:$project.googlePlayServicesVersion"
}
}
If same issue coming then use
classpath 'com.android.tools.build:gradle:3.4.1'
FYI Read Android plugin for Gradle HTTP proxy settings
defaultConfig {
...
systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=443
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.auth.ntlm.domain=domain
}

"PKIX path building failed" after updating to AS 3.3

This is what I get in Build tab:
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve com.github.chrisbanes:PhotoView:2.3.0.
Required by:
project :app
> Could not resolve com.github.chrisbanes:PhotoView:2.3.0.
> Could not get resource 'https://jitpack.io/com/github/chrisbanes/PhotoView/2.3.0/PhotoView-2.3.0.pom'.
> Could not GET 'https://jitpack.io/com/github/chrisbanes/PhotoView/2.3.0/PhotoView-2.3.0.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve com.github.yalantis:ucrop:2.2.2.
Required by:
project :app
> Could not resolve com.github.yalantis:ucrop:2.2.2.
> Could not get resource 'https://jitpack.io/com/github/yalantis/ucrop/2.2.2/ucrop-2.2.2.pom'.
> Could not GET 'https://jitpack.io/com/github/yalantis/ucrop/2.2.2/ucrop-2.2.2.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
project build.gradle:
buildscript {
repositories {
jcenter()
google()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.20.0'
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
jcenter()
google()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
So the solution is to use embedded JDK which is recommended way.
File → Project Structure → SDK Location → Use embedded JDK

Failed to build an existing application due to lack of jcenter certificate - blocked by gradle

I tried to build an andruid application using latest andruid studio
Seems that gradle is blocked due to lack of jcenter certificate in local machine certstore. My colleguee succeed to build it on his machine so the problem is in the configuration and not the application code
Configuration : andruid studio 3.0.1, gradle 3.0.0 ?, windows 7
I also tried to workaround ssl handshake by replacing jcenter() in build.gradle with
maven {
url "http://jcenter.bintray.com"
}
but it didn't solve the problem
My build.gradle below:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// 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
}
Gradle console:
Executing tasks: [assemble]
Configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'PDA'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.0.0.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.0.0.
> Could not get resource 'http://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Could not HEAD 'http://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Connect to repo.jfrog.org:80 [repo.jfrog.org/52.72.224.151, repo.jfrog.org/34.204.33.255] failed: Connection timed out: connect
The plugin v.3.x.x
classpath 'com.android.tools.build:gradle:3.0.0'
is not in jcenter.
You have to use the google maven repo.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
If you are using Android Studio 3 and gradle v.4.x you can use the google() shortcut
buildscript {
repositories {
...
google()
}
}
Besides as #GabrieleMariotti alreay said, that library will not be found at JCenter, you should not get Connection timed out: connect but a message that the library was not found.
Connection timed out: connect hints, that you cannot access that URL from your machine. My best guess is that you have to use some Proxy to access this URL that properly configured for your colleague, but not for you.

Categories

Resources