NavHostFragment not resolved (AndroidX) - android

For some reason I always get confronted with the following error:
Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment androidx.navigation.fragment.NavHostFragment: make sure class name exists, is public, and has an empty constructor that is public
I was following the Guide on Android Developers yet the Error above occurs right after starting the App.
nav_graph.xml
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
app:startDestination="#id/mainFragment">
<fragment
android:id="#+id/mainFragment"
android:name="projects.ferrari.rene.sken.ui.main.MainFragment"
android:label="main_fragment"
tools:layout="#layout/main_fragment" >
<action
android:id="#+id/action_mainFragment_to_takeImageFragment"
app:destination="#id/takeImageFragment" />
</fragment>
<fragment
android:id="#+id/takeImageFragment"
android:name="projects.ferrari.rene.sken.ui.takeimage.TakeImageFragment"
android:label="take_image_fragment"
tools:layout="#layout/take_image_fragment" />
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/my_nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
app:navGraph="#navigation/nav_graph"
app:defaultNavHost="true"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.kt
package projects.ferrari.rene.sken
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.navigation.findNavController
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main_activity)
}
override fun onSupportNavigateUp()
= findNavController(R.id.my_nav_host_fragment).navigateUp()
}
build.gradle (app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "projects.ferrari.rene.sken"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
def anko_version = "0.10.5"
def nav_version = "1.0.0-alpha01"
implementation "android.arch.navigation:navigation-fragment-ktx:$nav_version"
implementation "android.arch.navigation:navigation-ui-ktx:$nav_version"
implementation "org.jetbrains.anko:anko-commons:$anko_version"
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.google.android.gms:play-services-vision:15.0.2'
implementation 'androidx.core:core-ktx:1.0.0-alpha1'
implementation 'com.github.pqpo:SmartCropper:v1.1.3#aar'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-alpha1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha2'
}
Basically I am using Kotlin, AndroidX and targeting Android P. I really can't figure out where the problem lies.
EDIT There might be an issue with the import. For navigation I don't import it using AndroidX. In Build your first App with Jetpack they use implementation 'androidx.navigation:navigation-fragment:' + rootProject.navigationVersion yet I could not figure out which version they were using so I read the Architecture Component Release Notes where it says for AndroidX '2.0.0-alpha1' should be used. Unfortunately this can not be resolved.

For Java:
dependencies {
def nav_version = "2.3+"
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
}
For Kotlin:
dependencies {
def nav_version = "2.3+"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
}

Related

fragmentDirections.action() method can't find arguments specified on nav_graph

I'm trying to implement the Safe Args plugin, but my auto-generated class/method MainScreenFragmentDirections.actionMainScreenFragmentToNoteScreenFragment() can't seem to find the specified arguments from the nav_graph. I don't think the problem is with the plugin not generating the classes, since I'm able to reference the necessary class and method - my issue is with the action method not recognizing my argument and giving me a warning:
Too many arguments for public final fun actionMainScreenFragmentToNoteScreenFragment(): NavDirections defined in com.example.notelite.ui.mainscreen.MainScreenFragmentDirections
I've applied all necessary plugins and dependencies on gradle.
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'kotlin-parcelize'
id 'androidx.navigation.safeargs.kotlin'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.notelite"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
viewBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
//Navigation Components
def nav_version = "2.3.5"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
// Feature module Support
implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"
// Testing Navigation
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
//Room Database
def room_version = "2.3.0"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
//Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:$room_version"
//Test helpers
testImplementation "androidx.room:room-testing:$room_version"
//Dagger Hilt - Dependency Injection
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"
//Preferences DataStore
implementation "androidx.datastore:datastore-preferences:1.0.0-beta01"
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.30'
ext.hilt_version = '2.35'
repositories {
google()
jcenter()
}
dependencies {
def nav_version = "2.3.5"
classpath 'com.android.tools.build:gradle:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here's my nav_graph code:
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/nav_graph"
app:startDestination="#id/mainScreenFragment">
<fragment
android:id="#+id/mainScreenFragment"
android:name="com.example.notelite.ui.mainscreen.MainScreenFragment"
android:label="MainScreenFragment"
tools:layout="#layout/fragment_mainscreen">
<action
android:id="#+id/action_mainScreenFragment_to_noteScreenFragment"
app:destination="#id/noteScreenFragment" />
<argument android:name="noteid"
app:argType="integer"
android:defaultValue="0" />
</fragment>
<fragment
android:id="#+id/noteScreenFragment"
android:name="com.example.notelite.ui.notescreen.NoteScreenFragment"
android:label="NoteScreenFragment"
tools:layout="#layout/fragment_note_screen">
<action
android:id="#+id/action_noteScreenFragment_to_noteEditScreenFragment"
app:destination="#id/noteEditScreenFragment" />
</fragment>
<fragment
android:id="#+id/noteEditScreenFragment"
android:name="com.example.notelite.ui.notescreen.NoteEditScreenFragment"
android:label="NoteEditScreenFragment"
tools:layout="#layout/fragment_edit_note_screen"/>
</navigation>
Here's the code snippet I'm trying to call the method in - just defining a navigation action and trying to pass an argument parameter:
override fun onNoteClick(note: NoteEntity) {
val noteid = note.id
val action = MainScreenFragmentDirections.actionMainScreenFragmentToNoteScreenFragment(noteid)
}
"noteid" is the key value of an item in a Room database table. I've specified the type accordingly. Any ideas? Couldn't find anyone with a similar problem. I've tried clean and rebuild, restarting Android Studio, updating some plugins, updating IDE...nothing worked. What's funny is I can't seem to find the generated classes on the java(generated) folder, even though I'm able to reference them on my fragment - but that might be just me being a newbie and just really not finding them
Your <argument> needs to be associated with the <fragment> destination you are navigating to: your NoteScreenFragment:
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/nav_graph"
app:startDestination="#id/mainScreenFragment">
<fragment
android:id="#+id/mainScreenFragment"
android:name="com.example.notelite.ui.mainscreen.MainScreenFragment"
android:label="MainScreenFragment"
tools:layout="#layout/fragment_mainscreen">
<action
android:id="#+id/action_mainScreenFragment_to_noteScreenFragment"
app:destination="#id/noteScreenFragment" />
</fragment>
<fragment
android:id="#+id/noteScreenFragment"
android:name="com.example.notelite.ui.notescreen.NoteScreenFragment"
android:label="NoteScreenFragment"
tools:layout="#layout/fragment_note_screen">
<argument android:name="noteid"
app:argType="integer"
android:defaultValue="0" />
<action
android:id="#+id/action_noteScreenFragment_to_noteEditScreenFragment"
app:destination="#id/noteEditScreenFragment" />
</fragment>
<fragment
android:id="#+id/noteEditScreenFragment"
android:name="com.example.notelite.ui.notescreen.NoteEditScreenFragment"
android:label="NoteEditScreenFragment"
tools:layout="#layout/fragment_edit_note_screen"/>
</navigation>

Can't Resolve AcitivityMainBinding for DataBinding

I'm trying to use MVVM Architure Pattern, but when I typed ActivityMainBinding nothing appeared in the suggestion menu
I tried to change the XML file name and changed it back to the original name but nothing happened
here is my dependency
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.alphabet"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard- rules.pro'
}
}
dataBinding{
enabled = true
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
def lifecycle_version = "2.1.0"
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
// (see https://github.com/ReactiveX/RxJava/releases for latest 3.x.x version)
implementation 'io.reactivex.rxjava3:rxjava:3.0.0'
}
Main Activity
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
}
}
xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com /apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<data>
</data>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
.............................................................
The xml is malformed for data binding, it should be :
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewmodel"
type="com.myapp.data.ViewModel" />
</data>
<ConstraintLayout... /> <!-- UI layout's root element -->
</layout>
As per the documentation : https://developer.android.com/topic/libraries/data-binding the root element should be <layout> ... </layout>
And easy way to convert to xml data binding layout is to ALT-Enter on your standard root element view/viewgroup in existing, non data binding layouts and choose the "convert" option.

Error recognizing dataBinding class android

in one of my projects I have started to implement dataBinding in the main activity by separating the data in a class called view, in another class called viewModel and in the model class. Using these classes and the dataBinding, the application has been compiled correctly, but when I put the classes in different packages to follow the MVVM architecture, the self-generated class named ActivityLoginBinding does not recognize the class that is inside the ViewModel package. I have already done searches of different projects to see if it was my mistake at syntax level, but they are well written. I have also noticed that all the projects are divided into different packages and work correctly. Any idea why this happens and how could it be solved? Thank you.
my xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="student3"
type="com.juan97.prueba.ViewModel.Student3ViewModel"/>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".View.MainActivity">
<TextView
android:layout_marginTop="50sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:hint="#{student3.hint1}"/>
<TextView
android:layout_marginTop="50sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:hint="#{student3.hint2}"/>
</LinearLayout>
</layout>
gradle module app
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.juan97.prueba"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Different packages I have:
compile error

Unable to use barteksc PDF Viewer in my app

I tried to use [bartecksc AndroidPdfViewer][1]
[1]: https://github.com/barteksc/AndroidPdfViewer in my android app to view PDF files from the assets folder inside the app but it is not working. It shows a blank screen.
Here is what I did:
I added this dependency in the build.gradle file
implementation 'com.github.barteksc:android-pdf-viewer:3.1.0-beta.1'
(I even tried using implementation 'com.github.barteksc:android-pdf-viewer:2.8.2')
I added the following widget in activity_main.xml
<com.github.barteksc.pdfviewer.PDFView
android:id="#+id/pdfView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
I put the following code in the onCreate method
PDFView pdfView=findViewById(R.id.pdfView);
pdfView.fromAsset("sample_file.pdf");
The file that I wanted to display was located in the assets folder with the name sample_file.pdf
Following is my MainActivity.java
package com.umersoftwares.bartekscpdfview;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.github.barteksc.pdfviewer.PDFView;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PDFView pdfView=findViewById(R.id.pdfView);
pdfView.fromAsset("sample_file.pdf");
}
}
Following is my activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.github.barteksc.pdfviewer.PDFView
android:id="#+id/pdfView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</android.support.constraint.ConstraintLayout>
My build.gradle file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.umersoftwares.bartekscpdfview"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
}
The problem was that it was necessary to call the .load() method on the PDFView object to display the pdf. So, in the java file, it should be like this
pdfView.fromAsset("sample_file.pdf")
.load();
Instead of only:
pdfView.fromAsset("sample_file.pdf");
The code you posted is missing necessary permissions for reading storage.
there is a demo over github with the library that you posted. check the code for requesting read storage permission and implement it in your code.
You can refer this sample class of demo provided with library.
https://github.com/barteksc/AndroidPdfViewer/blob/master/sample/src/main/java/com/github/barteksc/sample/PDFViewActivity.java

Androidx error inflating view

I'm trying to use Androidx. The app is pretty new, so there is not much code. I did use the "Refactor to Androidx" option in android studio. But sometime after that, it stopped working. I don't know what made it stop working.
What am I supposed to do?
But it get this error
Error inflating class androidx.constraintlayout.widget.ConstraintLayout
Main activity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
pick_image.setOnClickListener {
toast("Pick image clicked")
}
}
}
XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/pick_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Pick image"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
build.gradle (app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.alvarlagerlof.blurr"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Androidx
implementation 'androidx.core:core-ktx:1.0.0-alpha3'
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.1'
// Testing
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
}
EDITED 2: Since the newer version, they've reverted back to androidx.constraintlayout.widget.ConstraintLayout.
Just keep reading if you're using constraint layout version 1.1.1
EDITED: As Arturo Mejia's answer, just press ⇧⌘R or Ctrl + Shift + R to
replace any
androidx.constraintlayout.widget.ConstraintLayout
with
androidx.constraintlayout.ConstraintLayout
in all XML file that use Constraint Layout.
That's a change since constraint layout version v1.1.1 (in v1.1.0 ConstraintLayout class is still inside ".widget" package)
Old workaround answer:
Change from
implementation 'androidx.constraintlayout:constraintlayout:1.1.1'
to
implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
I tried to press Command + Click at ConstraintLayout in
androidx.constraintlayout.widget.ConstraintLayout from XML file to
show the original class but it doesn't find any thing. After I edited
the constraint layout version to 1.1.0 then it's there.
In my case updating dependency
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
to
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
has helped
I fixed it by changing the gradle dependencies form alpha3 to alpha1

Categories

Resources