I am trying to add MediaStyle notification buttons to my application. I am a bit stuck. Most guides assume access to the support library. But I think that is not a good idea for my new project and I should use androidx. I hope to have as low as possible future maintenance.
My minSdkVersion is 21 and compileSdkVersion and targetSdkVersion are 29.
Using these class mappings, I found that
The support libraries in android.support.mediacompat.R are now located in androidx.media.R
But, my androidx has no media namespace. (I think this is my main problem).
In my build.gradle I have listed
implementation 'androidx.core:core:1.1.0'
implementation 'androidx.media:media:1.1.0'
And in gradle.properties I have listed (added by android studio on new project init)
android.useAndroidX=true
android.enableJetifier=true
I hope you guys have an idea where to look. Thanks :)
Oh wow. Gradle didn't sync. A gradle sync solved it. pff
After migrating to Androidx packages using Android Studio menu option Refactor -> Refactor to Androidx...
I'm getting the following error:
Error inflating class androidx.constraintlayout.widget.ConstraintLayout
Make sure constraint layout is updated to latest version:
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
And replace your xml tag names
<androidx.constraintlayout.ConstraintLayout>
with
<androidx.constraintlayout.widget.ConstraintLayout>
in every place where it appears using this shortcut:
Windows: CTRL + SHIFT + R
Mac: COMMAND + SHIFT + R
In AndroidStudio 3.3 RC2 I got it resolved by upgrading -
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
to
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
in build.gradle (Module: app)
Note:
This solution is also valid for the release version 3.3 (as per below comment by FireZenk), 3.5.2 (as per below comment by user2350644)
Just replace
<androidx.constraintlayout.ConstraintLayout>
with
<androidx.constraintlayout.widget.ConstraintLayout>
In your project's xml files.
You can use Replace in Path shortcut in mac (⇧⌘F or ⇧⌘R) and windows (Ctrl+Shift+R)
Well in my case I've tried Solution 1 which still was not working. Then I used Solution 2 along with Solution 1.
Solution 1
Updating the current version ConstraintLayout in app level build.gradle file.
From
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
Into
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Solution 2
Invalidate Caches and Restart Android Studio (If still not working after applying Solution 1).
File → Invalidate Caches / Restart → Invalidate and Restart
I used both of them and It works fine for me.
Note: Solution 1 is important.
I've also face this issue. This issue occur only for constraintlayout dependecy version.
Use 1.1.3 version & hope your issue will be solved:
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
There are two ways to add ConstraintLayout:
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha3'
then you need to use it like this:
<android.support.constraint.ConstraintLayout
...>
</android.support.constraint.ConstraintLayout>
or using androidx:
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
then you need to use
<androidx.constraintlayout.widget.ConstraintLayout
...
>
</androidx.constraintlayout.widget.ConstraintLayout>
Do not mix those two.
Since the Android Studio is updated to 3.3 it will pop this error. I resolved it by upgrading the version for constraint layout in the build.gradle of the app level:
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
TO
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
I use an Android Studio 4.1 and this library for constraint layout:
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
which is updated on 09-Nov-20 and had the same error with inflating a Constraint Layout.
In my case on my Samsung a40 app worked but on my ZTE nubia n1 app crashed instantly.
I figured that a problem was in my layout background image because my png image was too big for an old device with a different screen resolution than the Samsung a40.
I imported a background png image through the file explorer (drawable - right-click- Show in Explorer) and there was actually the problem.
I tried to import images with Android Drawable Importer but I notice this plugin does not work anymore on Android Studio.
SOLUTION RELATED TO ANDROID DRAWABLE IMPORTER:
If you have already installed the Android Drawable Importer on your Android Studio please uninstall it before you start the process of repairing.
To repair the Android Drawable Importer you need ADI-hack-plugin which you can get by following this youtube video from Thomas Samoul.
After you repair the Android Drawable Importer just import your image with it and everything will work fine.
I ran into the same problem none of the solutions above worked. The problem, in fact , was caused by a null pointer exception thrown after I switch to NoActionBar theme while the app was using the ActionBar to setTitle(). The linked stack overflow answer helped me figure it out
Android Studio is updated version 3.3. Please remove the previous version constraintLayout
my case used this
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
Thank you
In my case i just had to update the androidx dependencies to the latest version.
EDIT In build.gradle (app) you have to look for the dependencies which contains androidx. Android studio will show you information about the latest versions of these dependencies. Using that information just the change the dependency version.
In AndroidStudio 3.4 I had to downgrade to
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
to get it working again.
Strangely, it worked for when I upgraded androidx.appcompat:...' library to
'androidx.appcompat:appcompat:1.1.0-alpha05' with constraint layout version
'androidx.constraintlayout:constraintlayout:1.1.3' on Android Studio 3.3
For those who have tried all of the above to no vain, downgrading constraintLayout worked for me (after I wrecked my head for 3 days trying everything under the sun).
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
to
implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
Hey people,
I'm having this problem about a few hours. I already tried with Invalider cache/Restart but didn't work also I downloaded the last versions of the SDK Tools. Anyone knows how to solve it?
This is my gradle
Also, I'm having this issue too
Thanks in advance.
In your app level build.gradle file, specify:
dependencies {
compile 'com.android.support:recyclerview-v7:26.0.3'
compile 'com.android.support:design:26.0.3'
...
}
The render in Layout is 26 while in the gradle the targetSdkVersion is 25
Please add constraint-layout dependency also.
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta3'
and try adding AppCompact support in dependency.
implementation 'com.android.support:appcompat-v7:27.0.0'
** Please change version names according to your build.
I use recyclerveiw in my android app,
I use firebase-ui:2.1.0 in my gradle,but I find that if my android is 6.0 or over,
my app will bug.
So I update my dependencies to firebase-ui:3.1.0.
(refer to this link )
But It happened this error message:
How could I solve this problam? plz
I had the same problem.
Just make sure your
compile 'com.android.support:appcompat-v7:26.1.0'
version is the same as
targetSdkVersion 26
Mine was different and changing just this solved the problem.
I am currently having this error. I am using API 21 and I know some folks here suggested to upgrade it to API 22 base on previous questions but the tutorial(Slidenerd of Youtube) I am following is using API 21 and did not encountered any errors like this. Weird thing also because my RecyclerView in emulator is just working fine as expected in his tutorial and I don't why this error keeps popping up. Thanks !
It is not an error. Because the constructor is getting called while viewing the layout. Normally there are some operations which are going to be executed. To avoid this there is View.isInEditMode().
Normally you would use it like this
public Constructor(){
if(View.isInEditMode())
return;
}
If I understand your question correctly you are talking about the message the preview window of your layout is giving you?
You are probably using a version of recycler view that is newer than your compile version.
In you build.gradle file where you have added recyclerview to your dependencies you can try downgrading the version you are using
Change compile 'com.android.support:recyclerview-v7:22.2.1'
to compile 'com.android.support:recyclerview-v7:21.0.3' (or change to a 21.x.x version that suits your needs