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.
Related
I faced the problem, more correct in gradle, when I enter the command - npx react-native run-android into the console - it gives me the following error :
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'Da'.
Could not resolve all artifacts for configuration ':classpath'.
Could not find com.android.tools.build:gradle:6.4.1.
Searched in the following locations>
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/6.4.1/gradle-6.4.1.pom -https://jcenter.bintray.com/com/android/tools/build/gradle/6.4.1/gradle-6.4.1.pom
Initially - the problem was incompatibility between gradle and android versions, but after i changed version of gradle and terminal automatically download new version into directory, first error disappeared, but i got another (current problem). I had try some advice before asking question in StackOverFlow, but they didn't work. Here some characteristics :
React-Native Doctor image
Gradle code : gradle.properties ,
gradle-wrapper.properties
Gradle Directory : Here
Path variables :Here
I appreciate all help (I think, that issue is in PATH, but not sure). By the way - does anyone know, how to add pictures without link?
You are confusing gradle with the gradle plugin.
The gradle plugin 6.4.1 doesn't exist.
Use the latest stable version:
classpath 'com.android.tools.build:gradle:4.2.2'
Check also the compatibility with the gradle version:
Plugin version Required Gradle version
4.0.0+ 6.1.1+
4.1.0+ 6.5+
4.2.0+ 6.7.1+
I have recently updated the version of the Firebase Appdistribution Gradle plugin from 1.4.0 to 2.0.1.
Since then Jenkins started giving the build time error below:
Execution failed for task app:appDistributionUpload[Variant]. Could not find the APK. Make sure you build first by running ./gradlew assemble[Variant], or set the api Path parameter to point to your APK
This is my Gradle script on Jenkins:
... ./gradlew cleanBuildCache :app:testDebugUnitTest :app:appDistributionUpload[Variant] ...
Starting with version 1.4.1 Running appDistributionUpload{Variant} no longer automatically rebuilds the app.
https://firebase.google.com/support/release-notes/android#appdistro_gradle_plugin_v1-4-1
Updating the Gradle script by adding :app:assemble[Variant] before :app:appDistributionUpload[Variant] solved the issue in my case. Hope it will help others as well.
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
We updated Android Gradle plugin from 3.4.2 to 3.5.0 (and Gradle from 5.1.1 to 5.4.1).
After that, the build started failing in a few submodules. Trying to assemble any build variant yields this (same error on the command line and in Android Studio):
> Failed to transform artifact 'bottom-navigation.aar (project :bottom-navigation)' to match attributes {artifactType=jar}.
> Execution failed for JetifyTransform: <project_root>/bottom-navigation/build/outputs/aar/bottom-navigation-release.aar.
> Failed to transform '<project_root>/bottom-navigation/build/outputs/aar/bottom-navigation-release.aar' using Jetifier.
Reason: Cannot open a library at 'FileMapping(from=<project_root>/bottom-navigation/build/outputs/aar/bottom-navigation-release.aar, to=<project_root>/bottom-navigation/build/.transforms/9b2af95a5f0e0055110660c22ff05ab5/jetified-bottom-navigation-release.aar)'. (Run with --stacktrace for more details.)
Any ideas how to fix this?
What I've tried
"Invalidate caches" in AS and also clearing all Gradle caches in ~/.gradle/caches as suggested in this answer
All the advice in this somewhat similar question
I checked that the problematic modules use apply plugin:
'com.android.library' (instead of com.android.application)
I tried updating appcompat dependency to androidx.appcompat:appcompat:1.1.0 in affected modules and also removing that dependency
Update
It starts to look like something is wrong in Gradle plugin 3.5.0; builds behave erratically for me locally and on our CI machine.
For example, clean builds are failing: ./gradlew clean assembleBetaRelease fails while ./gradlew assembleBetaRelease works!
Also, sometimes I get AAPT: error: attribute ... not found instead of the above Failed to transform artifact error.
Reverting to Gradle plugin 3.4.2, all these problems disappear.
Edit Oct 2019: Still seeing this weird behaviour with Gradle plugin 3.5.1. Edit Nov 2019 And 3.5.2. Upgrading to Gradle 5.6 didn't help either.
A bit weird, but I got it working again. Apparently just a temporary glitch in Android Gradle plugin related to caching.
This answer helped me:
The simple way to solve this is to switch between your build variants. This refreshes the cached copies and resolves the issue.
I couldn't do that in Android Studio since the project sync was failing, but on the command line I tried another variant (in my case ./gradlew assembleBetaDebug having used ./gradlew assembleBetaRelease earlier). The build passed, and after that it worked for all all other variants too, and Gradle sync in Android Studio started working as well!
Edit: actually this is not completely solved; see updated question.
Update 12/2019: bundle* commands work fine, it's only assemble* that fails—still failing with Android Gradle plugin 3.5.3. Building in Android Studio works fine. Obviously this is not a common issue, and I don't know what exactly in the particular project I'm working on is causing this.
Update 04/2020: now with Android Gradle plugin 3.6.2 (and Gradle 5.6.4) builds work for me locally and I was able to update the project. On CircleCI, the build still occasionally fails with "Failed to transform artifact" but re-running fixes it. Go figure 🤔
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.