Android Studio can not generate Binding class while use DataBinding - android-studio

Android Studio : 3.1.0, 3.1.1
Gradle : 4.4
Build Tools : 3.1.0
I am using the DataBinding library. when I add a layout file to project or add any view into the layout file, Android Studio cannot generate a Binding class for the layout, until rebuilding the project.
layout file:
<?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"
tools:context=".MainActivity">
<data>
<variable
name="viewModel"
type="com.qk365.thweeks.MainViewModel" />
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TabLayout
android:id="#+id/main_tab"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="#android:color/white"
android:elevation="5dp"
app:tabGravity="fill"
app:tabIndicatorHeight="0dp"
app:tabMode="fixed"
app:tabSelectedTextColor="#7343ea"
app:tabTextAppearance="#style/TextAppearance.Design.Tab"
app:tabTextColor="#181818" />
<android.support.v4.view.ViewPager
android:id="#+id/main_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/main_tab">
</android.support.v4.view.ViewPager>
</RelativeLayout>
</layout>
I checked Android Studio logs, when layout file changes, there always have error message.
2018-04-17 11:20:01,699 [e-1024-b02] ERROR - .intellij.psi.impl.ElementBase - Element: class com.intellij.psi.impl.source.xml.XmlFileImpl because: different providers: SingleRootFileViewProvider{myVirtualFile=file://E:/AndroidStudioProjects/thweeks/module-order/src/main/res/layout/order_fragment_pick_up_order.xml, content=VirtualFileContent{size=2845}}(5200996b); SingleRootFileViewProvider{myVirtualFile=file://E:/AndroidStudioProjects/thweeks/module-order/src/main/res/layout/order_fragment_pick_up_order.xml, content=VirtualFileContent{size=2845}}(398a3993)
invalidated at: see attachment
com.intellij.psi.PsiInvalidElementAccessException: Element: class com.intellij.psi.impl.source.xml.XmlFileImpl because: different providers: SingleRootFileViewProvider{myVirtualFile=file://E:/AndroidStudioProjects/thweeks/module-order/src/main/res/layout/order_fragment_pick_up_order.xml, content=VirtualFileContent{size=2845}}(5200996b); SingleRootFileViewProvider{myVirtualFile=file://E:/AndroidStudioProjects/thweeks/module-order/src/main/res/layout/order_fragment_pick_up_order.xml, content=VirtualFileContent{size=2845}}(398a3993)
invalidated at: see attachment
at com.intellij.psi.util.PsiUtilCore.ensureValid(PsiUtilCore.java:502)
at com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl.createSmartPsiElementPointer(SmartPointerManagerImpl.java:78)
at com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl.createSmartPsiElementPointer(SmartPointerManagerImpl.java:69)
at com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl.createSmartPsiElementPointer(SmartPointerManagerImpl.java:64)
at com.intellij.psi.impl.ElementBase$ElementIconRequest.<init>(ElementBase.java:183)
at com.intellij.psi.impl.ElementBase$ElementIconRequest.<init>(ElementBase.java:178)
at com.intellij.psi.impl.ElementBase.computeIcon(ElementBase.java:110)
at com.intellij.psi.impl.ElementBase.getIcon(ElementBase.java:86)
at com.intellij.codeInsight.lookup.DefaultLookupItemRenderer._getRawIcon(DefaultLookupItemRenderer.java:79)
at com.intellij.codeInsight.lookup.DefaultLookupItemRenderer.getRawIcon(DefaultLookupItemRenderer.java:48)
at com.intellij.codeInsight.completion.JavaMethodCallElement.renderElement(JavaMethodCallElement.java:444)
at com.intellij.codeInsight.completion.JavaCompletionUtil$4.renderElement(JavaCompletionUtil.java:468)
at com.intellij.codeInsight.completion.JavaCompletionUtil$4.renderElement(JavaCompletionUtil.java:465)
at com.intellij.codeInsight.lookup.LookupElementDecorator$VisagisteDecorator.renderElement(LookupElementDecorator.java:179)
at com.intellij.codeInsight.lookup.LookupElementDecorator.renderElement(LookupElementDecorator.java:83)
at com.intellij.codeInsight.lookup.impl.LookupCellRenderer.getListCellRendererComponent(LookupCellRenderer.java:150)
at com.intellij.ui.ExpandedItemListCellRendererWrapper.getListCellRendererComponent(ExpandedItemListCellRendererWrapper.java:38)
at javax.swing.plaf.basic.BasicListUI.paintCell(BasicListUI.java:209)
at com.intellij.ui.components.WideSelectionListUI.paintCell(WideSelectionListUI.java:56)
at javax.swing.plaf.basic.BasicListUI.paintImpl(BasicListUI.java:317)
at javax.swing.plaf.basic.BasicListUI.paint(BasicListUI.java:240)
at com.intellij.ui.components.WideSelectionListUI.paint(WideSelectionListUI.java:32)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
at javax.swing.JComponent.paintComponent(JComponent.java:780)
at com.intellij.ui.components.JBList.paintComponent(JBList.java:186)
at javax.swing.JComponent.paint(JComponent.java:1056)
at com.intellij.ui.components.JBList.paint(JBList.java:118)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JViewport.paint(JViewport.java:728)
at com.intellij.ui.components.JBViewport.paint(JBViewport.java:236)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1579)
at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1502)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:306)
at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
at javax.swing.JComponent._paintImmediately(JComponent.java:5158)
at javax.swing.JComponent.paintImmediately(JComponent.java:4969)
at javax.swing.RepaintManager$4.run(RepaintManager.java:831)
at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:822)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:650)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:366)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
2018-04-17 11:20:01,699 [e-1024-b02] ERROR - .intellij.psi.impl.ElementBase - Android Studio 3.1.1 Build #AI-173.4697961
2018-04-17 11:20:01,699 [e-1024-b02] ERROR - .intellij.psi.impl.ElementBase - JDK: 1.8.0_152-release
2018-04-17 11:20:01,699 [e-1024-b02] ERROR - .intellij.psi.impl.ElementBase - VM: OpenJDK 64-Bit Server VM
2018-04-17 11:20:01,699 [e-1024-b02] ERROR - .intellij.psi.impl.ElementBase - Vendor: JetBrains s.r.o
2018-04-17 11:20:01,699 [e-1024-b02] ERROR - .intellij.psi.impl.ElementBase - OS: Windows 10
2018-04-17 11:20:01,699 [e-1024-b02] ERROR - .intellij.psi.impl.ElementBase - Last Action: EditorChooseLookupItem

I had the same problem. No matter what I tried it was not able to generate binding class. The trick was that you have to rename your layout xml file. Say you have a xml file my_layout.xml then rename it to my_layout_temp.xml. Now the binding class will be generated with name MyLayoutTempBinding. If you don't like the name then you can rename it back to my_layout.xml. At the end it will solve the binding class generate issue.

Note: For initial debugging steps see Khemraj's answer here Data Binding class not generated
Android Studio : 3.1.4
Gradle : 4.4
Build Tools : 28.0.0
I can see the auto-generated binding classes momentarily after issuing a
File > Invalidate Caches / Restart
but only while the indexing is paused, immediately after Android Studio restarts (I should probably use something other than "databinding" for a test project name):
While paused, ActivityMain2Binding will be recognized by compiler, however the build and make operations are not available. Shortly after resuming the indexing the associated binding classes are removed and the IDE error mentioned in the OP is logged.
Update (2018.09.11)
Using a tip found in the bug post commented above (https://issuetracker.google.com/issues/77607040), I changed the Data Binding setting to
I then added a reference to the generated class

I have the same error in the same environment as you.
But unfortunately, I could not resolve this problem with Android Studio 3.1.1.
For now, I'm using Android Studio 3.2 Canary11 and it works fine.

The radical solution
You should add this in the build.gradle(Module) file to make the data binding enabled and press Sync
android {
...
buildFeatures {
dataBinding true
}
}

This is a bug of Android Studio. Fixed in Android Studio 3.2.1.

Related

Android Studio: Not showing preview after adding TextInputLayout in a module

I am learning android development. I have setup a simple app with defaults. In the main app, I have 1 fragment. When I add the com.google.android.material.textfield.TextInputLayout, the preview is displayed without any problem.
However, I added another library module, with another fragment. When I add a com.google.android.material.textfield.TextInputLayout, the preview stops showing. Below is the stacktrace.
java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).
at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:241)
at com.google.android.material.internal.ThemeEnforcement.checkAppCompatTheme(ThemeEnforcement.java:211)
at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:146)
at com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(ThemeEnforcement.java:75)
at com.google.android.material.textfield.TextInputEditText.<init>(TextInputEditText.java:70)
at com.google.android.material.textfield.TextInputEditText.<init>(TextInputEditText.java:63)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:325)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:174)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:135)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:294)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:417)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:428)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:332)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1127)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
at android.view.LayoutInflater.inflate(LayoutInflater.java:505)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:359)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:436)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:121)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:717)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$9(RenderTask.java:873)
at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$3.run(RenderExecutor.kt:192)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
I looked around for other similar SO questions and everyone saying to change the app theme.
My question is that, why does android studio shows the preview when I add the TextInputLayout to a fragment in main app and why does it not show changes after adding in module.
Android Studio details -
Android Studio Dolphin | 2021.3.1 Beta 5
Build #AI-213.7172.25.2113.8774922, built on June 27, 2022
Runtime version: 11.0.13+0-b1751.21-8125866 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.15.0-46-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Registry:
external.system.auto.import.disabled=true
ide.text.editor.with.preview.show.floating.toolbar=false
Non-Bundled Plugins:
wu.seal.tool.jsontokotlin (3.7.4)
indent-rainbow.indent-rainbow (2.0.2)
com.intellij.plugins.macoskeymap (213.5744.3)
izhangzhihao.rainbow.brackets (6.25)
com.nbadal.ktlint (0.10.0)
Current Desktop: ubuntu:GNOME
Can someone please help me fix the issue?

Error in inflating a ConstraintLayout when doing a test Android Studio

I´m trying to do a test in android studio, and the fragment i´m trying to launch has a ConstraintLayout, I've seen other responses of this type of error but none of them were useful. The error I get is this one:
android.view.InflateException: Binary XML file line #2 in com.example.museosgijon:layout/fragment_list_museum: Binary XML file line #2 in com.example.museosgijon:layout/fragment_list_museum: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
Caused by: android.view.InflateException: Binary XML file line #2 in com.example.museosgijon:layout/fragment_list_museum: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:858)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
at android.view.LayoutInflater.inflate(LayoutInflater.java:663)
at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
at com.example.museosgijon.databinding.FragmentListMuseumBinding.inflate(FragmentListMuseumBinding.java:56)
at com.example.museosgijon.ui.ListMuseumFragment.onCreateView(ListMuseumFragment.kt:54)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2995)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:523)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1840)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1758)
at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1670)
at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:317)
at androidx.fragment.app.testing.FragmentScenario$Companion.internalLaunch$lambda-2(FragmentScenario.kt:628)
at androidx.fragment.app.testing.FragmentScenario$Companion.$r8$lambda$qQn68eFQCuWOFZCsJdZ7z8QDNvM(Unknown Source:0)
at androidx.fragment.app.testing.FragmentScenario$Companion$$ExternalSyntheticLambda0.perform(Unknown Source:13)
at androidx.test.core.app.ActivityScenario.lambda$onActivity$2$ActivityScenario(ActivityScenario.java:660)
at androidx.test.core.app.ActivityScenario$$Lambda$4.run(ActivityScenario.java:652)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.app.Instrumentation$SyncRunnable.run(Instrumentation.java:2296)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7842)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 18: TypedValue{t=0x2/d=0x7f030004 a=-1}
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:783)
at android.view.View.<init>(View.java:5567)
at android.view.ViewGroup.<init>(ViewGroup.java:702)
at android.view.ViewGroup.<init>(ViewGroup.java:698)
at android.view.ViewGroup.<init>(ViewGroup.java:694)
at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:567)
When I run the aplication I dont get any error and it launches.
The dependencie of the constraintlayout is like this:
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
And in the xml its defined in this way:
<?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"
android:layout_gravity="center_horizontal"
tools:context=".ui.ListMuseumFragment"
android:paddingBottom="?attr/actionBarSize">
Thanks.
You have some error on line #2 in XML file "fragment_list_museum".
Please paste fragment_list_museum.xml for more help.
• In XML it looks all good. I don't know, what's wrong...
Maybe try updating implementation to 2.1.4, but it wouldn't help, I think. Maybe someone else will find answer.

Android Studio 3.2.1 - Cannot sync project with gradle files: Argument for #NotNull parameter 'message' of ... must not be null

I have a problem using AndroidStudio. I freshly installed it on my Kubuntu 18.04 machine and wanted to create my frist project. Everyhting worked fine and the project opened. The only problem: I can't run my apps. I can't even look at the activities in the design view - It waits forever for the build to finish. When I want to run the apps, it doesn't have any modules.
After searching for a while on the web I tried syncing my project with the gradle files, because that seems to resolve similar issues, but once I do that, the following error occurs:
Argument for #NotNull parameter 'message' of com/android/tools/idea/gradle/project/sync/GradleSyncState.syncFailed must not be null
java.lang.IllegalArgumentException: Argument for #NotNull parameter 'message' of com/android/tools/idea/gradle/project/sync/GradleSyncState.syncFailed must not be null
at com.android.tools.idea.gradle.project.sync.GradleSyncState.$$$reportNull$$$0(GradleSyncState.java)
at com.android.tools.idea.gradle.project.sync.GradleSyncState.syncFailed(GradleSyncState.java)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.doPopulateProject(IdeaSyncPopulateProjectTask.java:135)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.populate(IdeaSyncPopulateProjectTask.java:97)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.access$000(IdeaSyncPopulateProjectTask.java:39)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask$1.run(IdeaSyncPopulateProjectTask.java:86)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:750)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:395)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:305)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
After doing it once, the button for syncing is disabled and I can't do it again. I have to restart the IDE to do that.
I looked into the idea.log file to better track down the issue and I found the following there:
2018-10-22 22:38:32,254 [d thread 3] INFO - xecution.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: -Didea.version=3.2 -Djava.awt.headless=true -Pandroid.injected.build.model.only=true -Pandroid.injected.build.model.only.advanced=true -Pandroid.injected.invoked.from.ide=true -Pandroid.injected.build.model.only.versioned=3 -Pandroid.injected.studio.version=3.2.1.0 -Pandroid.builder.sdkDownload=false --init-script /tmp/ijinit.gradle --offline
2018-10-22 22:38:43,063 [d thread 3] INFO - e.project.sync.GradleSyncState - Started setup of project 'TestApp'.
2018-10-22 22:38:43,065 [e-1136-b06] INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender activation event: SETUP_STARTED
2018-10-22 22:38:43,263 [e-1136-b06] INFO - ule.android.SdkModuleSetupStep - Set Android SDK 'Android API 28 Platform (1)' (/home/myusername/Android/Sdk) to module 'app'
2018-10-22 22:38:43,567 [d thread 3] WARN - ea.IdeaSyncPopulateProjectTask - Sync failed: null
java.lang.RuntimeException: java.lang.NullPointerException
at com.intellij.openapi.application.impl.LaterInvocator.invokeAndWait(LaterInvocator.java:179)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:651)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:656)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdt(ExternalSystemApiUtil.java:480)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:469)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.dispose(ProjectDataManagerImpl.java:442)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:163)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:221)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:228)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.doPopulateProject(IdeaSyncPopulateProjectTask.java:120)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.populate(IdeaSyncPopulateProjectTask.java:97)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.access$000(IdeaSyncPopulateProjectTask.java:39)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask$1.run(IdeaSyncPopulateProjectTask.java:86)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:750)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:395)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:305)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at com.intellij.openapi.extensions.Extensions.disposeArea(Extensions.java:171)
at com.intellij.openapi.module.impl.ModuleImpl.dispose(ModuleImpl.java:146)
at com.intellij.openapi.util.Disposer$1.execute(Disposer.java:48)
at com.intellij.openapi.util.Disposer$1.execute(Disposer.java:44)
at com.intellij.openapi.util.objectTree.ObjectTree.executeActionWithRecursiveGuard(ObjectTree.java:169)
at com.intellij.openapi.util.objectTree.ObjectTree.executeUnregistered(ObjectTree.java:181)
at com.intellij.openapi.util.objectTree.ObjectTree.executeAll(ObjectTree.java:140)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:129)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:125)
at com.intellij.openapi.module.impl.ModuleManagerImpl$ModuleModelImpl.dispose(ModuleManagerImpl.java:895)
at com.intellij.openapi.externalSystem.service.project.AbstractIdeModifiableModelsProvider.dispose(AbstractIdeModifiableModelsProvider.java:476)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl$3.execute(ProjectDataManagerImpl.java:445)
at com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange.run(DisposeAwareProjectChange.java:36)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1010)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.lambda$executeProjectChangeAction$6(ExternalSystemApiUtil.java:469)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:315)
at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:156)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:447)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:431)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:415)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:822)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:763)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:423)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
2018-10-22 22:38:43,570 [e-1136-b06] ERROR - intellij.openapi.progress.Task - Argument for #NotNull parameter 'message' of com/android/tools/idea/gradle/project/sync/GradleSyncState.syncFailed must not be null
java.lang.IllegalArgumentException: Argument for #NotNull parameter 'message' of com/android/tools/idea/gradle/project/sync/GradleSyncState.syncFailed must not be null
at com.android.tools.idea.gradle.project.sync.GradleSyncState.$$$reportNull$$$0(GradleSyncState.java)
at com.android.tools.idea.gradle.project.sync.GradleSyncState.syncFailed(GradleSyncState.java)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.doPopulateProject(IdeaSyncPopulateProjectTask.java:135)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.populate(IdeaSyncPopulateProjectTask.java:97)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.access$000(IdeaSyncPopulateProjectTask.java:39)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask$1.run(IdeaSyncPopulateProjectTask.java:86)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:750)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:395)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:305)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2018-10-22 22:38:43,572 [e-1136-b06] ERROR - intellij.openapi.progress.Task - Android Studio 3.2.1 Build #AI-181.5540.7.32.5056338
2018-10-22 22:38:43,572 [e-1136-b06] ERROR - intellij.openapi.progress.Task - JDK: 1.8.0_152-release
2018-10-22 22:38:43,572 [e-1136-b06] ERROR - intellij.openapi.progress.Task - VM: OpenJDK 64-Bit Server VM
2018-10-22 22:38:43,572 [e-1136-b06] ERROR - intellij.openapi.progress.Task - Vendor: JetBrains s.r.o
2018-10-22 22:38:43,572 [e-1136-b06] ERROR - intellij.openapi.progress.Task - OS: Linux
2018-10-22 22:38:43,572 [e-1136-b06] ERROR - intellij.openapi.progress.Task - Last Action: Android.SyncProject
It seems like the project can't be synced to my gradle files. Probably the actual problem of running my app is based upon this one. Has anyone had this issue before or can help me by telling me how to tackle this?
I am completely new to AndroidStudio and also to Gradle.
Ok, I was finally able to figure out the reason.
The problem was, that my project folder resided on a different hard disk partition, than my home folder. The folder containing my android projects was linked to my home folder with a symbolic link.
I can't tell whether its the symbolic link, or the other partition, that is causing the problem. I haven't checked that. Maybe it works if you have it on the same partition but linked with a symbolic link. Maybe it works when used on another partition without symbolic links. But for anyone experiencing this problem -> Check if one of these might be your cause as well.
Some extra information: My android project folder resided on a hard disk partition formatted with ZFS.
I saw a version of this with just now on Android Studio 3.4: the only error message I saw in the IDE was that Gradle sync failed, but in idea.log there was a NullPointerException and its traceback originated at com.intellij.openapi.extensions.Extensions.disposeArea and was just like the one in the question.
The fix that worked for me:
rm .idea/modules.xml
Then try Gradle sync again.
This also caused that file to get automatically regenerated. The new version had exactly the same entries as the old, plus some additional ones for various library dependencies. Not sure if those entries being absent was the cause of the issue, or an unrelated accident.
Before that, I tried "Invalidate Caches / Restart...", and it didn't work in my case. Also double-checked and there are no symbolic links in my project path, or the paths to Android Studio or the Android SDK.
Had a similar problem after renaming the project folder and adding the renamed folder as new project.
solved this by the infamous "Invalidate Caches / Restart" option
(before I removed the old project link which was not enough)
check this :
Argument for #NotNull parameter 'module' of com/intellij/openapi/roots/ModuleRootManager.getInstance must not be null
by the way , i usually delete .idea and .gradle folders inside my project folder after updating android studio , almost works for all new bugs after updating .
Faced same issue, wasted a day reinstalling everything and figured out just now. It happens if you create a symbolic link to your project and specify the path through that symbolic link. Just specify the project path by going the long way and everything will work just fine.
I had the same problem. I move the ~/Android/Sdk folder to a different partition and placed a symbolic link!!!
Solution for me:
Delete .android , .AndroidStudio3.2 , .gradle folders
Start studio.sh again and let it initialize things as for the first time. Then go to File->settings->System Settings->Android SDK and give the new location to the Android SDK folder as an absolute path (not symbolic links).
After this, it worked like charm.
I solved the problem by rename the project folder and then reopen android studio , android studio will tell you that it can not find the project , then remove the project from the android studio current open list . rename project folder back and open it by android studio again .
I got same issue in Android Studio 3.4.
I managed to fix it by restoring my previously deleted app-name.iml file.
I also had the same problem and simply resolved it by closing android studio, deleting .idea and .gradle files located on the project folder and then reopening android studio.

Can't edit/review layout files in Android Studio

When I double click to open an android layout *.xml file in android studio i get an AssertionError: null in Event Log from Android studio and the layout editor doesn't open.
This doesn't happen in every project, and started to happen in projects there were already working fine, here the log error
null
java.lang.AssertionError
at com.android.tools.idea.rendering.MultiResourceRepository.setChildren(MultiResourceRepository.java:47)
at com.android.tools.idea.rendering.MultiResourceRepository.<init>(MultiResourceRepository.java:43)
at com.android.tools.idea.rendering.ModuleResourceRepository.<init>(ModuleResourceRepository.java:57)
at com.android.tools.idea.rendering.ModuleResourceRepository.create(ModuleResourceRepository.java:87)
at com.android.tools.idea.rendering.ProjectResources.create(ProjectResources.java:174)
at org.jetbrains.android.facet.AndroidFacet.getProjectResources(AndroidFacet.java:996)
at com.android.tools.idea.rendering.ProjectResources.get(ProjectResources.java:163)
at com.android.tools.idea.rendering.ProjectResources.get(ProjectResources.java:154)
at com.android.tools.idea.rendering.ModuleSetResourceRepository.create(ModuleSetResourceRepository.java:43)
at com.android.tools.idea.rendering.ProjectResources.create(ProjectResources.java:172)
at org.jetbrains.android.facet.AndroidFacet.getProjectResources(AndroidFacet.java:991)
at com.android.tools.idea.rendering.ProjectResources.get(ProjectResources.java:163)
at com.android.tools.idea.rendering.ProjectResources.get(ProjectResources.java:154)
at com.android.tools.idea.configurations.ConfigurationManager.create(ConfigurationManager.java:120)
at com.android.tools.idea.configurations.ConfigurationManager.getConfiguration(ConfigurationManager.java:99)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowForm.setFile(AndroidLayoutPreviewToolWindowForm.java:234)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:322)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2003)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:266)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:289)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:347)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:672)
at java.awt.EventQueue.access$400(EventQueue.java:81)
at java.awt.EventQueue$2.run(EventQueue.java:633)
at java.awt.EventQueue$2.run(EventQueue.java:631)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:642)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:701)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:526)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:349)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Now I can't edit/review layout files in Android studio, does anybody knows how to fix this problem?
Just delete this line from your activity:
tools:showIn="#layout/activity_splash"
Android Studio
Issue 124715
Solutions :
You do that by editing the "studio.exe.vmoptions" file in this path: Program Files\Android\Android Studio\bin. Remove the line that says "-ea".
You can refer this link

Android Studio , Google MapFragment - mapv2

i know there are many question about this but it's about 2 days i work on this and i was unable to find a correct solution (i'm new to android). I need to create an app that can handle a map and draw some markers. I can't even show a map on my device :( Nexus4
This is what i have done :
i copy the google-play-services.jar into my libs dir and change the gradle.build to handle the new library :
dependencies {
compile files('libs/android-support-v4.jar' , 'libs/gcm.jar', 'libs/google-play-services.jar')
}
i already signed my app and enabled the mapv2 api and change the android manifest like this :
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
...
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<permission
android:name="com.metu.xxx.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.metu.xxx.permission.MAPS_RECEIVE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="SIGNATURE_HERE -> ^_^"/>
...
my java class looks like this :
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class AtmActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_atm);
}
}
my xml layout looks like this :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
compiling this code is ok but when i tap on the button to show the activity the app crash :(
This is the error log :
06-16 13:34:30.957 523-535/? E/qcom_sensors_hal: hal_process_time_resp: Resetting rollover count from 0 to 0
06-16 13:34:39.716 28726-28726/com.metu.xxx E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
at android.app.Activity.setContentView(Activity.java:1881)
at com.metu.xxx.AtmActivity.onCreate(AtmActivity.java:11)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Somebody can help me ?
or maybe can link a good how to to solve this ?
Thanks and sorry for my poor english :)
UPDATE :
it seems i completly wrong with this.
following this tutorial and everything went fine : http://android.rzeszow.net/?p=79
(there is a part missing in the copy files, you need to copy the jar and the settings to the libs file of the module)
You need to reference google play services project and not only the jar.

Resources