Android Studio fail generate signed apk - android

I'm installed Android Studio 3.5 and started to use it with my old project (gradle 2.14 and I want save this version).
Build in debug and release mode work fine. But when I try generate signed APK an error message are appeared:
"The project is using an unsupported version of Gradle.
Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)"
How it can be? Why I can't just asign APK?

I'm downgrade to Android Studio 3.4.1 and signing worked fine.

Please make a change in the last line as follows:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
and try to Rebuild your project again.

In your project inside gradle-wrapper.properties file.
Change this line..
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
In your project level build.gradle..
buildscript {
repositories {
jcenter() // or mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0' // change to this version
}
}

Related

Upgrade to AndroidStudio 3.4 and now can´t run my app

I updated my Android Studio to Android Studio 3.4 and I'm trying to run one of my apps but it gives me an error.
com.android.tools.idea.run.ApkProvisionException: No outputs for the main artifact of variant: debug
Session 'app': Install failed.
Installation failed
Rerun
Solved it by going to Run => Edit Configuration => app (or your project name)
In the Before Launch section, I added Gradle-aware Make.
The hint came from comparing my project with the example screenshot available at https://developer.android.com/studio/run/rundebugconfig#opening
Try running your app after reloading your gradle project
Right click over your project under Gradle tab
You may be using an incompatible Gradle and Android Gradle plugin version.
Upgrade Gradle to version 4.1 at least
in gradle/wrapper/gradle-wrapper.properties
use:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
and in root build.gradle
modify the following lines (add Google maven repository and update plugin to 3.0.1):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
I had the same problem.
On the left there is a pane where all the files are displayed called "Build Variants"
I selected that and my main app module was set to debug-x86. I changed that to debug-x86-64 and it worked]1
In my case, delete Signed Bundle files you were created.

Could not find gradle 3.1

The latest version of gradle is 3.1 enter link description here
but Android Studio is only using 2.2?
enter link description here
This seems likes a huge discrepancy. My configuration:
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2'
classpath 'de.felixschulze.gradle:gradle-hockeyapp-plugin:3.2'
classpath 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
}
}
allprojects {
repositories {
jcenter()
}
}
When I try to find gradle 3.1, I get an error that it cannot find it. Same now with 2.2 > Could not find com.android.tools.build:gradle:2.2.
But gradle -v shows
gradle -v
------------------------------------------------------------
Gradle 2.2
how do I resolve this?
You are confusing Gradle with the Android gradle plugin, which generally matches the version of Android Studio. The latest version (at time of writing) is 2.2.2. It is generally set in your project's base build.gradle as you have shown above.
The Gradle wrapper is what you're looking for. You can change the wrapper's settings in your project's gradle/wrapper/gradle-wrapper.properties file.
Change
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-all.zip
Again, this is separate from the Android gradle plugin, which simply marries Gradle with Android Studio.
Find all distributions here
Here is the Gradle Version Compatibility for Android Studio
Gradle
refer to link
A problem occurred research project ': sample'.
Failed to apply plugin [id 'com.android.application']
Minimum supported Gradle version is 3.3. Current version is 3.2.1.
The current gradle configuration is also changed to 3.3. The project is running without problems, but can not use the command line (gradle and ./gradlew).
Refer to the online program:
1. Modify gradle-wrapper.properties, and Invalidate Caches / Restart ..., or do not work.
Later in the gradle forum to find a program: Thank you Henry
As new release with the fix not available yet, the former walk-around works fine.
Buildscript {
System.properties ['com.android.build.gradle.overrideVersionCheck'] = 'true'
...
}
. So mark what.
Correction statement : I later found that I installed the sdkman tool,
the tool installed 3.2.1 version, and this should be related (⊙ o ⊙)!
. At the beginning of the show gradle version, will show 3.2.1
version (I am still very depressed, change or show 3.2.1), I have
changed to the environment variable 3.3. I set the gradle environment
variable first, the following is set sdkman environment variable (this
order may also affect). So the final reason is still installed 3.2.1
version.

Gradle build failing after update to 3.0

I've recently updated the gradle version of my project from 2.14.1 to 3.0. Since then the gradle build is failing every time with this error:
Error:Cause: org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I've searched google and found some solutions like this one but nothing is working. Does anyone know how to fix it?
Upgrade your gradle build tools to the latest version.
One easy way to do this is to add the latest version of the build tools as a dependency in your build.gradle file, for example:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
}
You can then run gradle tasks and gradle will download everything you need.
After Android Studio 2.2 stable released on Sep 19 2016 , the latest version of the build tools is 2.2.0 . So you can fix it by :
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
}
As Android Studio 2.4 stable is not ready to release yet (May 4 2017), the latest stable version of build tools is 2.3.1 .
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
}
If you update this build tools version to 2.3.* , you should also update gradle wrapper version to 3.3 in /yourProjectRoot/gradle/wrapper/gradle-wrapper.properties file. (i know it is not matching question Gradle build failing after update to 3.0, but i strongly suggest you to use latest build tool as google recommended)
BTW: version 2.3.1 of build tool is only exist on jCenter, not MavenCentral, so if you run into error below when run gradlew command line in terminal
Could not find com.android.tools.build:gradle:2.3.1.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.3.1/gradle-2.3.1.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.3.1/gradle-2.3.1.jar
just replace mavenCentral() with jcenter() like
repositories {
jcenter()
//mavenCentral()
}
For latest update of Android Studio 3.0
In gradle-wrapper.properties(File Name) change URL of distributionUrl to the following:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
If you use gradle plugin 2.1.3,
It's simple to solve:
update your gradle plugin to version 2.2.0-beta1
Notes: this is a beta version, maybe you can get any other issues.
https://discuss.gradle.org/t/classcastexception-in-gradle-nightly-3-0-20160609/17979
Happy coding :)
Okay I got it working. For anyone facing the same problem the way it worked for me is as follows:
Go to your external .gradle folder (for me it was C:\Users\drilon.gradle). Inside caches and daemon folder delete all the version folder (they look like this "2.14.1", or "3.0"). Also go to wrapper -> dists -> delete everything there.
Inside your project root (for me it was C:\Users\drilon\AndroidStudioProjects\PorjectName) go to the .gradle folder and delete everything there.
Rebuild the project
EDIT:
Turns out this solution was setting the gradle version back to 2.14.1. ending0421's solution is the working one.
For latest update of Android Studio 3.3.1 below code work.
1) gradle-wrapper.properties add below line.
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
2)build.gradle in project level add below classpath
dependencies
{
classpath 'com.android.tools.build:gradle:3.1.0'
}
if your gradle version is: 3.0.1 then use below code in your gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
if 3.1.2 then use below code in your gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
After 1 hour R&D No Solution as worked for me...
But still i have solution follow this its work 100%
step 1: upgrade your build.gradle(Project:<your project name>)
Example : classpath 'com.android.tools.build:gradle:2.1.3' // old gradle file
classpath 'com.android.tools.build:gradle:2.3.1' // upgraded file
OR
classpath 'com.android.tools.build:gradle:3.1.0'
Step 2 : Upgrade compileSdkVersion buildToolsVersion
Example : compileSdkVersion 23 buildToolsVersion "23.0.3 // old api's
compileSdkVersion 25 buildToolsVersion "25.0.2" // upgraded api's
Step 3: upgrade gradle-wrapper.properties
Example : distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip // old or any version
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip // new or any version
Step 4 : finally goto build>rebuild project...
Still You face some problem commit or inbox me....
......End #Ambilpura
You should check your Gradle Plugin version and Gradle version before updating.
Check Gradle Plugin Version in your project level build.gradle file-
buildscript {
repositories {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:gradle.plugin.version'
}
}
Check Gradle Version in your gradle-wrapper.properties-
distributionUrl=https\://services.gradle.org/distributions/gradle-gradle.version.zip
At the time of this answer, below were the latest versions. You can match your versions on this page.
Simply delete everything inside gradle folder in main project folder and Rebuild the
project. It will start working.
If your gradle plugin 3.0.0 for studio version 3.0, Add this in gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
simple answer try this...
goto build.gradle(PROJECT) and check the gradle version as shown below
'com.android.tools.build:gradle:2.1.3' or 3.0 or 3.1 or xx.xx
now open gradle-wrapper.properties see this line of code if gradle version is 2.x this the code below...
distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip
gradle-2.14.1-all.zip line of code must be same as gradle version
example:
example:
mine is 2.x so...
classpath 'com.android.tools.build:gradle:2.1.3' in build.gradle so
distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip
in gradle-wrapper.properties.
if gradle version is 3.x then
classpath 'com.android.tools.build:gradle:3.1.0' in build.gradle then
distributionUrl=https://services.gradle.org/distributions/gradle-3.14.1-all.zip
in gradle-wrapper.properties.
check this it will works
if Android Studio Android Studio 3.0 below code work.
gradle-wrapper.properties add below line.
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
if Android Studio Android Studio 3.1.2 below code work.
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
if Android Studio 3.3.1 below code work.
1) gradle-wrapper.properties add below line.
distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip
2) build.gradle in project level add below
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
}
Android Gradle dependencies are not working in new update of Android
Studio
Most important thing if you are face a lot of problems :
It is applicable on plugin 7.1 or new update version
Please Try this:
Go To -> settings.gradle inside of repositories { } :
add two files as :
maven{ url("https://repo.gradle.org/gradle/libs-releases/") }
maven { url "https://jitpack.io" }
The complete structure in
settings.gradle
file as given below :
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven{ url("https://repo.gradle.org/gradle/libs-releases/") }
maven { url "https://jitpack.io" }
}
}
rootProject.name = "MyApp"
include ':app'
And last step, it is must be added into gradle.properties files.
android.useAndroidX=true
android.enableJetifier=true

Android Gradle build-info.xml not found

When i try to start an old App with the InstantRun it says that:
Gradle build-info.xml not found for module app. Please make sure that you are using gradle plugin '2.0.0-alpha4' or higher.
How can i solve this?
With the recent release of Android Studio 2.0, there is a new Android gradle plugin 2.0.0. You can apply that in your top-level build.gradle buildscript block by changing the version of the plugin to look like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
}
}
EDIT: Some projects that were previously managed by Android Studio 1.5 may exhibit strange problems like this. To clear these problems, it may be required to delete the project's .idea directory and re-import it into AS 2.0.
It happend after updated to Studio 2.0,
I disable Instant Run function fix this issue
Update
After I upgrade android studio to version 2.1.1, enable instant run function. it works
Update2
It seems when I build release version, enable instant run is OK, not for debug version build. so strange.

Gradle version 2.2 is required. Current version is 2.10

I am trying to use gradle build. It gives me error saying that
Failed to apply plugin [id 'com.android.library']
Gradle version 2.2 is required. Current version is 2.10. If using the gradle wrapper, try editing the distributionUrl in /home/sanjeewa/workspace/Android/UVCCamera/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip
But my gradle-wrapper.properties includes gradle-2.4-all.zip. I have changed it to gradle-2.2-all.zip
Still same problem.
When I run gradle -version in terminal Gradle 2.10 shows as version.
How to solve that error??
my build gradle file is
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Open gradle-wrapper.properties
Change this line:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
Go to build.gradle (Project: your_app_name)
Change this line
classpath 'com.android.tools.build:gradle:XXX'
to this
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
or
classpath 'com.android.tools.build:gradle:1.5.0'
Don't click Sync Now
From menu choose File -> Invalidate Caches/Restart...
Choose first option: Invalidate and Restart
Android Studio would restart. After this, it should work normally
Hope it help
Current work around is to overrideVersionCheck: In your build.gradle
buildscript {
System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'
...
}
Check this link for more Details
Just Change in build.gradle file
classpath 'com.android.tools.build:gradle:1.3.0'
To
classpath 'com.android.tools.build:gradle:2.0.0'
Now GoTo -> menu choose File -> Invalidate Caches/Restart...
Choose first option: Invalidate and Restart
Android Studio would restart.
After this, it should work normally.
Based on
https://developer.android.com/studio/releases/gradle-plugin.html ...
The following table lists which version of Gradle is required for each version of the Android plugin for Gradle.
For the best performance, you should use the latest possible version of both Gradle and the Android plugin.
So, the Plugin version with Required Gradle version should be match.
Here's what I did to fix this:
1) Create a new project
2) open the gradle-wrapper.properties file and copy the distributionUrl to your project e.g.:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2-all.zip
3) open the build.gradle (Project) and copy the gradle dependency to your project e.g.:
classpath 'com.android.tools.build:gradle:2.3.0-beta1'
4) File --> Invalidate Caches / Restart (I think a re-sync may have sufficed, but didn't try it)
5) Delete that project you made (optional)
Look, this is a silly way to do things, but Android Studio is free so who am I to complain...
Use ./gradlew instead of gradle to resolve this issue.
The android studio and Gradle version looks like very bad managed. And there's tons of version in-capability issues. And the error message is mostly clueless. For this particular issue. The closest answer is from "Jitendra Singh". Change the version to:
classpath 'com.android.tools.build:gradle:2.0.0'
But in my case: Android studio 2.2 RC, I still get another error:
Could not find matching constructor for: com.android.build.gradle.internal.LibraryTaskManager(org.gradle.api.internal.project.DefaultProject_Decorated, com.android.builder.core.AndroidBuilder, android.databinding.tool.DataBindingBuilder, com.android.build.gradle.LibraryExtension_Decorated, com.android.build.gradle.internal.SdkHandler, com.android.build.gradle.internal.DependencyManager, org.gradle.tooling.provider.model.internal.DefaultToolingModelBuilderRegistry)
So I went to the maven central to find the latest com.android.tools.build:gradle version which is 2.1.3 for now. So after change to
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}
}
Solved my problem eventually.
I Had similar issue. Every project has his own gradle folder, check if in your project root there's another gradle folder:
/my_projects_root_folder/project/gradle
/my_projects_root_folder/gradle
If so, in every folder you'll find /gradle/wrapper/gradle-wrapper.properties.
Check if in /my_projects_root_folder/gradle/gradle-wrapper.properties gradle version at least match /my_projects_root_folder/ project/ gradle/ gradle-wrapper.properties gradle version
Or just delete/rename your /my_projects_root_folder/gradle and restart android studio and let Gradle sync work and download required gradle.

Categories

Resources