Flutter-Execution failed for task ':app:preDebugBuild' - android

I'm starting developing apps with flutter, and I encounter with this error when I clone a project from GitHub:
What went wrong?
Execution failed for task ':app:preDebugBuild'.
Android dependency 'androidx.appcompat:appcompat' has different version for the compile (1.0.0) and runtime (1.0.2) classpath. You should manually set the same version via DependencyResolution
I'm running Android Studio 3.2.2 and Flutter SDK 1.2.1

You need to migrate the project to Android X. You can only do this through Android studio 3.3.
Follow the procedures here to Migrate your Project to Android X

Finally i found a solution for the problem.
Only need to add the following code on the build.gradle file:
configurations.all {
resolutionStrategy {
force 'androidx.media:media:1.0.0'
}
}
Then, the app runs without any error.

Related

How to upgrade React Native project after upgrading Android Studio

I have upgraded React Native from version 0.68.1 to version 0.70.2, and react from 17.0.2 to 18.1.0. That has worked fine, but I have also upgraded Android Studio to version 2021.3.1. I updated configuration files with the React Native CLI, npx react-native upgrade. Then I attempted to upgrade the android directory according to the React Native Upgrade Helper and manual edits that are necessary to sign an android app. That failed, so I have tried a backup copy but now that fails too despite the fact that the android directory is unchanged from when the app was building correctly. I used Git to revert to a known working copy.
I don't see any procedures to upgrade the Android files after upgrading Android Studio from React Native. Is there any available guidance for the version of Android Studio I use? How can I upgrade the Android project to get it to build with the new version of Android Studio? I'm guessing that Gradle versioning has a lot to do with the errors but I haven't found any explanation or advice to upgrade the project after upgrading Android Studio.
The error I get from PowerShell after running .\gradlew bundleRelease is
Task :app:signReleaseBundle FAILED
w: Detected multiple Kotlin daemon sessions at build\kotlin\sessions
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
> java.lang.OutOfMemoryError (no error message)
When I open the Android folder in Android Studio I notice errors in MainApplication.java and AsyncStoragePackage.java: Cannot resolve symbol 'BuildConfig'. Invalidating the cache, clean, and rebuild have not changed the results.
The answer was found earlier on GitHub. In my instance, there are other messages and the relevant error message is Detected multiple Kotlin daemon sessions at build\kotlin\sessions. Simply adding the code to android/build.gradle as follows fixed the issue for me. I expect the version will need to be updated periodically and I'm now sure how to get the version info as my Kotlin REPL will not start.
belbuildscript {
ext {
// ...
kotlin_version = '1.6.10' // <- add this line
}
dependencies {
// ...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // <- add this line
// ...
}
}
I'm guessing that this sort of problem can be avoided by uninstalling Android Studio before installing a more recent version, and other software may need the same treatment.

What is navigation.json in Android Studio 4.1?

I just tried out Android Studio 4.1 today. I started the Android Studio and created empty activity and I run it using the android virtual device. Then it was failed and this error is shown:
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':app:processDebugManifest' (type 'ProcessMultiApkApplicationManifest').
> File 'E:\Project\AndroidLayout\app\build\intermediates\merged_manifest\debug\out\AndroidManifest.xml' specified for property 'mainMergedManifest' does not exist.
When I rebuild the project, the error message is shown here:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> com.android.manifmerger.ManifestMerger2$MergeFailureException: java.io.FileNotFoundException: E:\Project\AndroidLayout\app\build\intermediates\navigation_json\debug\navigation.json (The system cannot find the path specified)
Note that this is fresh install and fresh project without any modification in the code.
UPDATE 1:
Youtube: https://www.youtube.com/watch?v=g4w_NOA_UVQ
Bug Report: https://issuetracker.google.com/issues/170720311
UPDATE 2:
After I downgrade the Android Gradle Plugin version from 4.1.0 to 4.0.2 and the Gradle version from 6.5 to 6.4.1 now it is working.
So my conclusion is there is a bug in the Android Gradle Plugin 4.1.+ and Gradle 6.5.+.
I find a temporary solution:
After I downgrade the Android Gradle Plugin version from 4.1.0 to 4.0.2 and the Gradle version from 6.5 to 6.4.1 now it is working. So my conclusion is there is a bug in the Android Gradle Plugin 4.1.+ and Gradle 6.5.+.
In order to downgrade, just go to File -> Project Structure.
Had same issue. Moving project files to ntfs drive fixed it.
Downgrading the Android Gradle Plugin version from 4.1.0 to 4.0.2 and the Gradle version from 6.5 to 6.4.1 now it is working; works for me as well. Now app is no longer experiencing building errors.Thanks.
Error message was :
A problem was found with the configuration of task ':app:processDebugManifest' (type 'ProcessMultiApkApplicationManifest').
File 'F:\NietsPastApp\app\build\intermediates\merged_manifest\debug\out\AndroidManifest.xml' specified for property 'mainMergedManifest' does not exist.
Thanks for help, downgrade it's ok. just for other who search the file :
gradle 4.0.2 change here : /build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
gradle 6.4.1 : gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
File -> Project Structure. reduce your build tools version to 29
i tried it's work
In my case and for kotlin I have downgraded kotlin version from 1.4.32 to 1.4.31

Unsupported method: AndroidArtifact.getBuildConfigFields()

I have just updated to Android Studio 4.0 and trying to build my project. I keep on getting the below error
Unsupported method: AndroidArtifact.getBuildConfigFields().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
I am already using the latest version of Gradle and Gradle Plugin
Gradle version:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-milestone-1-all.zip
Gradle plugin tools version:
classpath 'com.android.tools.build:gradle:4.1.0-alpha10'
Any solution or fix for this problem would be helpful. Thanks in advance.
Use Android studio 4.1 preview
or
classpath 'com.android.tools.build:gradle:4.0.0'
This is usually due to a mismatch between your Android Studio versions and the Android Gradle plugin.
You can find the version of Android Studio on the project selection window when you first open it (or in "Android Studio > About Android Studio" on Mac, and similar location on other platforms). For example, you might be using Android Studio 4.0.1.
You can find the Android Gradle plugin version for your project in the top-level build.gradle file.
You should find something like the following:
buildscript {
[...]
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
[...]
}
[...]
}
You need to make sure that the two version numbers match (in this case they do).

Downgrade Gradle from 3.3 to 2.14.1

Long story short: My android phone keeps disconnecting from ADB. I was told to update android studio, did that. I open my project in Intellij and try to run on android and I get an error:
BUILD FAILED
Total time: 48.986 secs
Error: /Users/me/Desktop/comp/Development/comp-ionic/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> java.lang.NullPointerException (no error message)
My first thought is that my gradle is the wrong version. For this specific app, I need to use gradle version 2.14.1.
When I type gradle -v I'm getting version 3.3.
Is there a way to delete/downgrade gradle from 3.3 to 2.14.1?
Or is this another problem?
If you're using the gradle wrapper, then there'll be a folder in your project named "gradle" with a subfolder named "wrapper", inside that, there are 2 files:
- gradle-wrapper.jar
- gradle-wrapper.properties
Open "gradle-wrapper.properties" and change the place where it says "3.3" to "2.14.1". Then sync gradle, and it will automatically download 2.14.1.
If you're using the new 2.3 Android Studio, you HAVE to use gradle wrapper 3.3, as its the minimum supported gradle wrapper version. If so, then you'll have to download Android Studio 2.2, or fix whatever issue you have in your project that needs gradle wrapper version 2.14.1.
To get more information about whatever the issue is, try running this:
./gradlew clean assemble -stacktrace
That will clean your project, try and compile it, and if/when it fails, it will show you a stacktrace of the error.
What you should do is to change the gradle build tools version to the one that matches your gradle version. According to here you can set the gradle to 2.14.1 by changing build tools to lower than 1.0.0.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'// For gradle 2.2.1 - 2.3
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Notice: if you keep checking the mentioned link you'll see Higher is better for gradle.
For me, Android Studio > File > Invalidate Caches / Restart did the trick.
I got the same problem when upgrading to Android Studio 2.3.1. There is something funky about Gradle 3.3 (It fails by "java.lang.NullPointerException: null value in entry: destinationDir=null at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:33)").
Good news: seems like the current most recent version (3.5) works.
Go to File|Project Structure|Project, and use these versions:
Gradle version=3.5
Android Plugin version=2.3.1
I update the Android Studio version to 3.3 Canary 4, then update the gradle plugin, and the project stops working.
I do not know how to restore my AS to the previous state, nighter the gradle plugin.
But just with this command, the project now works, for me: gradlew clean assemble -stacktrace, in terminal tab in AS.

Android Plugin for Gradle 2.2.2 and Gradle version 2.14.1 together failed to download android support v4

Android application build fails with Android Plugin for Gradle 2.2.2 and Gradle version 2.14.1.
But build successful with Android Plugin for Gradle 1.2.3 and Gradle version 2.3
Expected Behavior:
Android application should successfully build in command line with Android Plugin for Gradle 2.2.2 and Gradle version 2.14.1
Current Behavior:
Android application build fails with Android Plugin for Gradle 2.2.2 and Gradle version 2.14.1. Because it fails to find a symbol in the com.android.support:support-v4:23.2.1.
Also build fails in the Android Studio with the same reason.
Context:
I had to updated the Android Studio to 2.2.2(Latest) and this must use at least Android Plugin for Gradle 2.2.2. Therefore I had to update gradle as well. (Tried both gradle 2.14.1 and gradle 3.2) But build fails with the same reason.
Steps to Reproduce
Have the following settings in the application gradle.build file
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
Also
dependencies {
compile 'com.android.support:support-v4:23.2.1'
}
Android SDK is uptodate
enter image description here
enter image description here
And run the gradle build.
Build fails and out put's following errors
error: cannot find symbol
import android.support.v4.app.DialogFragment;
^
error: cannot find symbol
import android.support.v4.app.FragmentActivity;
When you try to update Gradle by yourself sometimes does not work, the best way y let android studio do it.
Step 1:
Close Your project
Step 2:
Reopen your project.
Step 3:
Click on update button
Step 4:
Wait update
Thats all!
Have you try to Invalidate Caches of Android Studio after upgrade gradle?
To do that you have to go:
File -> Invalidate caches / restart... -> Invalidate and Restart

Categories

Resources