NestedScrollView breaks suggestions in Android Studio - java

Here is the strange behavior. I have this layout:
<?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"
style="#style/AppTheme.FragmentBackground.XXXX.Parent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="#+id/appbar"
layout="#layout/layout_appbar" />
<LinearLayout
android:layout_width="match_parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_height="wrap_content">
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
So far, everything seems perfect. Although, if I replace the LinearLayout with a NestedScrollView, all of a sudden, the suggestions just do not work! If I remove the nested scrollview, everything seems to work again. Here are my gradle dependencies:
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'androidx.appcompat:appcompat-resources:1.6.0'
implementation 'androidx.core:core:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment:2.5.3'
implementation 'androidx.navigation:navigation-ui:2.5.3'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.5'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'androidx.preference:preference:1.2.0'
implementation 'org.apache.commons:commons-io:1.3.2'
implementation 'androidx.fragment:fragment:1.5.5' // Forecast Charts
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0' // maps v2
implementation 'androidx.asynclayoutinflater:asynclayoutinflater:1.0.0'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.maps.android:android-maps-utils:2.4.0'
// needed for timestamps manip
implementation 'net.danlew:android.joda:2.11.2'
implementation "androidx.camera:camera-camera2:1.2.1"
implementation "androidx.camera:camera-lifecycle:1.2.1"
implementation "androidx.camera:camera-view:1.2.1"
implementation 'com.google.android.gms:play-services-mlkit-barcode-scanning:18.1.0'
//implementation 'com.google.mlkit:barcode-scanning:17.0.2'
implementation 'androidx.window:window:1.0.0'
while my gradle is gradle-7.5-bin.zip and my plugins are
plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
version '2.0.1' apply false }
Also a popup of broken IDE is appeared and here is the log:
java.lang.NullPointerException
at org.jetbrains.android.dom.AttributeProcessingUtil.registerAttributesForClassAndSuperclasses(AttributeProcessingUtil.java:315)
at org.jetbrains.android.dom.AttributeProcessingUtil.processLayoutAttributes(AttributeProcessingUtil.java:604)
at org.jetbrains.android.dom.AttributeProcessingUtil.processAttributes(AttributeProcessingUtil.java:681)
at org.jetbrains.android.dom.AndroidDomExtender.registerExtensions(AndroidDomExtender.java:56)
at org.jetbrains.android.dom.AndroidDomExtender.registerExtensions(AndroidDomExtender.java:28)
at com.intellij.util.xml.reflect.DomExtenderEP.extend(DomExtenderEP.java:91)
at com.intellij.util.xml.impl.DynamicGenericInfo.runDomExtenders(DynamicGenericInfo.java:124)
at com.intellij.util.xml.impl.DynamicGenericInfo.lambda$checkInitialized$0(DynamicGenericInfo.java:55)
at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:114)
at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:44)
at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68)
at com.intellij.util.xml.impl.DynamicGenericInfo.checkInitialized(DynamicGenericInfo.java:54)
at com.intellij.util.xml.impl.DynamicGenericInfo.getAttributeChildrenDescriptions(DynamicGenericInfo.java:231)
at com.intellij.xml.impl.dom.AbstractDomChildrenDescriptor.getAttributeDescriptor(AbstractDomChildrenDescriptor.java:184)
at com.intellij.xml.impl.dom.AbstractDomChildrenDescriptor.getAttributeDescriptor(AbstractDomChildrenDescriptor.java:195)
at org.jetbrains.android.dom.layout.LayoutElementDescriptor.getAttributeDescriptor(LayoutElementDescriptors.kt:124)
at com.intellij.psi.impl.source.xml.XmlAttributeDelegate.getDescriptionImpl(XmlAttributeDelegate.java:68)
at com.intellij.psi.impl.source.xml.XmlAttributeDelegate.lambda$getDescriptor$0(XmlAttributeDelegate.java:55)
at com.intellij.psi.util.CachedValuesManager$1.compute(CachedValuesManager.java:158)
at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:39)
at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:227)
at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:42)
at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:227)
at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:114)
at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:44)
at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68)
at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:228)
at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:28)
at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:72)
at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:155)
at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:121)
at com.intellij.psi.impl.source.xml.XmlAttributeDelegate.getDescriptor(XmlAttributeDelegate.java:53)
at com.intellij.psi.impl.source.xml.XmlAttributeImpl.getDescriptor(XmlAttributeImpl.java:191)
at com.intellij.psi.impl.source.xml.XmlAttributeReference$1.compute(XmlAttributeReference.java:23)
at com.intellij.psi.impl.source.xml.XmlAttributeReference$1.compute(XmlAttributeReference.java:20)
at com.intellij.openapi.util.NullableLazyValue.getValue(NullableLazyValue.java:20)
at com.intellij.psi.impl.source.xml.XmlAttributeReference.getDescriptor(XmlAttributeReference.java:110)
at com.intellij.psi.impl.source.xml.XmlAttributeReference.resolve(XmlAttributeReference.java:50)
at com.intellij.codeInsight.TargetElementUtilBase.getReferencedElement(TargetElementUtilBase.java:177)
at com.intellij.codeInsight.TargetElementUtilBase.doGetReferenceOrReferencedElement(TargetElementUtilBase.java:165)
at com.intellij.codeInsight.TargetElementUtilBase.getReferenceOrReferencedElement(TargetElementUtilBase.java:210)
at com.intellij.codeInsight.TargetElementUtilBase.getReferencedElement(TargetElementUtilBase.java:254)
at com.intellij.codeInsight.TargetElementUtilBase.doFindTargetElement(TargetElementUtilBase.java:233)
at com.intellij.codeInsight.TargetElementUtilBase.findTargetElement(TargetElementUtilBase.java:298)
at com.intellij.codeInsight.TargetElementUtil.findTargetElement(TargetElementUtil.java:147)
at com.jetbrains.cidr.lang.psi.impl.OCTargetElementUtil.findTargetElement(OCTargetElementUtil.java:47)
at com.intellij.openapi.fileEditor.impl.text.TextEditorPsiDataProvider.getPsiElementIn(TextEditorPsiDataProvider.java:226)
at com.intellij.openapi.fileEditor.impl.text.TextEditorPsiDataProvider.getSlowData(TextEditorPsiDataProvider.java:139)
at com.intellij.openapi.fileEditor.impl.text.TextEditorPsiDataProvider.lambda$getData$0(TextEditorPsiDataProvider.java:93)
at com.intellij.ide.impl.DataManagerImpl.getSlowData(DataManagerImpl.java:153)
at com.intellij.ide.impl.DataManagerImpl.lambda$getDataRule$2(DataManagerImpl.java:121)
at com.intellij.ide.impl.DataManagerImpl.lambda$getDataRule$4(DataManagerImpl.java:126)
at com.intellij.ide.impl.DataManagerImpl.getDataFromProvider(DataManagerImpl.java:77)
at com.intellij.openapi.actionSystem.impl.PreCachedDataContext.getData(PreCachedDataContext.java:182)
at com.intellij.openapi.actionSystem.impl.PreCachedDataContext$InjectedDataContext.getData(PreCachedDataContext.java:327)
at com.intellij.openapi.actionSystem.DataKey.getData(DataKey.java:63)
at org.jetbrains.android.quickDefinitions.AndroidImplementationViewSessionFactory.createSession(AndroidImplementationViewSession.kt:55)
at com.intellij.codeInsight.hint.actions.ShowRelatedElementsActionBase.performForContext(ShowRelatedElementsActionBase.java:86)
at com.intellij.codeInsight.hint.actions.ShowRelatedElementsActionBase.actionPerformed(ShowRelatedElementsActionBase.java:63)
at com.intellij.openapi.keymap.impl.ActionProcessor.performAction(ActionProcessor.java:65)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:579)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$doPerformActionInner$10(IdeKeyEventDispatcher.java:704)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:95)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$doPerformActionInner$11(IdeKeyEventDispatcher.java:704)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:256)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.doPerformActionInner(IdeKeyEventDispatcher.java:701)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:645)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:590)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.java:473)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:462)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:227)
at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.java:804)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:740)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:439)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:803)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:438)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:119)
at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:604)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:436)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:873)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:484)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="#style/AppTheme.FragmentBackground.XXXX.Parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/appbar"
layout="#layout/layout_appbar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
</LinearLayout>

Use Clean Project and Rebuild Project. And Sync Project with Gradle files and download the latest version of Android Studio and then it will suggest.
Sometimes, by default, Android Studio does not show the suggestion.

Related

Bottom Navigation Bar in Android Studio not Working?

bottomNavigationView.setOnNavigationItemSelectedListener{
when (it.itemId){
R.id.local1 -> make_Fragment(fragment1)
R.id.local2-> make_Fragment(fragment2)
R.id.local3 -> make_Fragment(fragment3)
}
true
}
Here bottomNavigationView is throwing error : Unresolved reference: bottomNavigationView and also i defined the id on mainactivity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".main.MainActivity">
<FrameLayout
android:id="#+id/fl_wapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/bottomNavigationView"/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:menu="#menu/bottom_nav"
/>
</RelativeLayout>
Here bottomNavigationView shows error and also when(it.itemId){
the bottomNavigationView is the id of the bottom bar.i also tried clean project and rebuild project.
tell me a solution to resolve this problem?
add these in build.gradle(:app)
id 'kotlin-android'
id 'kotlin-android-extensions'
this in dependencies
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10"
like this
dependencies {
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10" }
add this import statement in MainActivity.kt
import kotlinx.android.synthetic.main.mainactivity.*
it will work just fine :)...
Add this dependencies in build.gradle
implementation "androidx.navigation:navigation-fragment-ktx:2.3.5"
implementation "androidx.navigation:navigation-ui-ktx:2.3.5"
Add kotlin code implementation
Please refer this my github repository for better understanding.
https://github.com/meshramaravind/BottomNavigtaionApp

BottomAppBar backgrounTint is not correctly match to parent and showing in half of screen

i try my layout code and the BottomAppBar is not showing perfectly i search everywhere but found no question about it.
i tried this on Android Studio 3.4 my gradle dependencies are
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
implementation 'androidx.vectordrawable:vectordrawable:1.0.0-beta01'
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
}
Code i use in home_bottomappbar.xml
<androidx.coordinatorlayout.widget.CoordinatorLayout
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">
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottom_app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
app:backgroundTint="#color/colorPrimaryDark"
app:fabAlignmentMode="center"
app:fabAttached="true"
app:fabCradleDiameter="0dp"
app:fabCradleVerticalOffset="10dp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="#id/bottom_app_bar"
app:backgroundTint="#color/colorPrimary"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Replace the Coordinator layout with Relative or Liner Layout. It will work fine.
I was having the same problem for a while too
The solution is to change the width of the BottomAppBar to fill_parent, it should work fine now :)

Android Studio Preview Not Showing RecyclerView and Toolbar Correctly

Please find the screenshots
I searched lot for this. My android studio is updated with 3.0.1.
Here are the dependencies in my project. Is the issue with studio 3.0.1?
compile 'com.android.support:appcompat-v7:23.4.+'
compile 'com.android.support:design:23.3.0'`
Here is the xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
If resolution Strategy is present in your build.gradle file then please add updated dependency as below
configurations.all {
resolutionStrategy {
force 'com.android.support:design:27.0.1'
force 'com.android.support:support-v4:27.0.1'
force 'com.android.support:appcompat-v7:27.0.1'
}
}
In android Studio ,Go to File->Project Structure->Dependencies
Then click on green + sign and choose library dependencies.
There you can search recyclerview and include that dependency,
Build your project again
Hope this Helps
Add these dependencies in your build.gradle file (Not in project level gradle).
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
you need to update libraries to last(nearly last) versions:
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:support-v4:27.0.2'
compile 'com.android.support:design:27.0.2'
and change your compileSdkVersion to 27(nearly last version)

R cannot be resolved to a variable (different scenario)

Firstly, I have searched and seen similar questions on Stackoverflow however I'm building outside Android studio or Eclipse so mine is a bit different and I'm looking for a solution or alternative if possible.
I am building a plugin that sends messages between Java and Javascript using Cordova.
I have 3 lines to resolve:
setContentView(R.layout.main);
mPreview = (CameraSourcePreview) findViewById(R.id.preview);
mGraphicOverlay = (GraphicOverlay) findViewById(R.id.faceOverlay);
Specifically just the setContentView(R.layout.main), findViewById(R.id.preview) and findViewById(R.id.faceOverlay). The layout file is in ../../../res/layout/main.xml and ../../../res/layout-land/main.xml.
All I want is a way to access, I do not have a R.java file and I'm not very experienced with Java unlike Javascript.
Is there a way to point to those files please, thanks.
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/topLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
<com.cordovaplugincamerapreview
android:id="#+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.cordovaplugincamerapreview
android:id="#+id/faceOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.cordovaplugincamerapreview>
</LinearLayout>

Android cannot find BindingConversion in include tag

I have made a BindingConversion from boolean to visibility, however Android can't find it, but only when I use it in an include tag. It works at other elements like FrameLyout.
In my abstract ViewModel:
#BindingConversion
public static int convertBooleanToVisibility(boolean visible) {
return visible ? View.VISIBLE : View.GONE;
}
Then in my xml (TestViewModel inherits from ViewModel):
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="oliveradam.testapp.viewmodels.TestViewModel"/>
</data>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
app:theme="#style/toolbarStyleMusicView"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize">
</android.support.v7.widget.Toolbar>
<include
android:visibility="#{viewModel.isVisible}"
layout="#layout/layout_test"
app:viewModel="#{viewModel}" />
</LinearLayout>
</layout>
Error:(139, 29) error: cannot find symbol method setVisibility(boolean)
I'm working on Android Studio 2.2 RC.
I don't know why this is not working, but I think its the layout tag in include. You can't use these tags for databinding. So I deleted the includes, used a viewstub and changed the layouts programmatically.

Categories