How to solve the issue of mixing version of support libraries in Android Studio? - android-studio

I received an update to android SDK. After the update, when I open a project, Android Studio recommends to update Android Gradle to v 2.3.0 and Gradle to v 3.3. I updated the project as recommended. After that I found an ugly red line under the appcompat-v7:25.2.0' (see pic).
The error, according to android studio, is that I am mixing versions of support libraries (v 25 and 24), but I didn’t find any support library of v24. I tried to build a signed apk, but app build failed (using V2 / full apk signature), so I searched the web and I found one solution to this problem by adding this line to the build.gradle: multiDexEnabled true. Adding that line fixed the problem of generating signed apk, although the red line of error was still there, it didn’t get rid of it.
Then I installed the signed apk on two phones, one running Android 6.0 and the other one is running Android 4.4.2. The app runs smoothly on Android 6.0 and crashes on start on Android 4.4.2 (I set minSdkVersion to 19).
My questions are: how can fix that error in the gradle permanently? Is adding the line “multiDexEnabled” to gradle really needed? How can I run my app on android 4.4.2 without crashing?

I'm had the same issue, just add these lines:
compile "com.android.support:animated-vector-drawable:${supportLibVersion}"
compile "com.android.support:mediarouter-v7:${supportLibVersion}"
In your case supportLibVersion is 25.2.0.

Related

Android Studio ArticFox compiling fine but showing red errors everywhere

I have a multi module Android Compose project. One module is an android app, others are android libraries or kotlin libraries. I'm running AS Artic Fox 2020.3.1 Beta 5 on MacOS 11.4 Big Sur.
After a library upgrade (probably AGP to use compose, I don't remember when exactly) Android Studio started to show syntax errors everywhere, both in .kts and .kt files.
Compilation and execution are working fine, only those weird JDK errors are displayed.
Here are some examples :
in a .kt file from a kotlin library module, in a .kts file from the buildSrc module
It seems that there is an error with the JDK somewhere, but I don't understand how to fix it.
I Googled/StackOverflowed before posting here and I already tried :
to check the JDK used Project Structure > SDK Location > Gradle. It is using the Embedded JDK 11.0.10
to reinstall AS using Jetbrains Toolbox
to invalidate cache and restart
to clone my project again
to delete ~/.gradle
But none of those actions helped...
Thanks in advance !
Update 22/07
I tried to create a new empty Compose project with .kts support, but no luck, everything is in red
Because of a bug preventing to update, I updated manually to RC_1. Here is my current setup.
I tried to change from Embedded JDK to a separately installed OpenJDK 11 and reimport but not luck (#alexey-belkov suggestion)
I checked the logs but found nothing obvious (#andy suggestion)
ℹ️ Finally I tried to create a new empty Android project with only .gradle support, and no errors ! Could it be a kotlin script plugin problem ?

Android Studio import Eclipse project from command line

It possible automate import Eclipse Android Project (generated by Unity 5.4.3) into Android project with command line using android sdk?
For some reasons (eg methods limit and others) i need build android project with gradle. But Unity 5.4.3 not supported build with gradle and i can't update it for new version because i have some problems with convert my unity project to the new 5.5-5.6 versions.
According to the Android Studio official document, there seems no way to import an Eclipse Android Project into Android Studio using command line (bat or sh). I know that Unity 5.5 and 5.6 are not quite stable yet, but it's still your best bet to upgrade.

Missing generated folders in Android Studio

I'm using Android Annotations in my project and I followed the instructions in this blog post http://www.jayway.com/2014/02/21/androidannotations-setup-in-android-studio/
Everything worked fine.
Today I updated Android Studio to latest version (build of 5th june). This requires an update of gradle build tools from 19.0.3 to 19.1.0. And i configured this in my build.gradle.
Annotaion processing still works. The generated files are located in build/source/apt. But this folder isn't visible any more in project explorer. And starting the build complains about the configuration.
But the project seems to run correctly.
This behavior is very annoying. Do I have to change anything in Android Studio? Has anyone a solution or is this just a bug in Android Studio?
The author of android-apt has already updated his plugin to support Gradle's new version, just change this line in your build.gradle
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2+'
To
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.3'
The Android Studio Team changed the behavior of the IDE "for better IDE integration". Therefore the output directory of the apt-plugin v 1.2 will not be recognized as generated sources folder any more.
the plugin author knows about it and will provide a fix
https://bitbucket.org/hvisser/android-apt/issue/13/compatibility-with-011-android-plugin

Android Studio: android-19 not found, but it's clearly installed

I've tried rebuilds, opening/closing android studio, switching to api level 18 and everything: I get this output:
Error:Module 'LabsCore': platform 'android-19' not found.
Error:Module 'facebook': platform 'android-19' not found.
In the sdk manager it is really all installed, I checked multiple times. Is this an issue with android studio/gradle plugin in the latest version?
I faced the same error after updrade to Android Studio 0.5.3/0.5.4. Take a look at this question. And the cholm's answer that was the solution for me.

Problems with Gradle in Android Studio

I had to reinstall Android Studio and now when I try to build my projects I get this error:
org.gradle.tooling.GradleConnectionException: Could not create an instance of Tooling API implementation using the specified Gradle distribution 'http://services.gradle.org/distributions/gradle-1.9-all.zip'.: Could not create an instance of Tooling API implementation using the specified Gradle distribution 'http://services.gradle.org/distributions/gradle-1.9-all.zip'.
I tried editing system variables and Android Studio settings but nothing has seemed to work.
Andrew
This is a problem with the Android plugin v0.7.2 and will be fixed in 0.7.3. In the meantime you can force it back to 0.7.1 following the answer here:
Android Studio fails - unsupport unsupported major minor version 51.0

Resources