Skip to content
This repository was archived by the owner on Apr 26, 2023. It is now read-only.
This repository was archived by the owner on Apr 26, 2023. It is now read-only.

NullPointerException in Android Studio layout preview #15

Open

Description

@jfbibeau

NullPointerException when viewing the layout in Android Studio 0.3.1. Otherwise everything works fine, so view this as an enhancement more than anything else. Thanks! (Sorry for the screenshot, seems that window of Android Studio doesn't allow copying)

2013-11-03 22_06_16-xmaslistapp - c__work_java_engapps_xmaslistappproject - xmaslistapp - _xm

Activity

  1. ghost assigned on Nov 4, 2013
  2. timroes commented on Nov 4, 2013

    @timroes
    Owner

    Not occurring for me in 0.3.2. I will try to reproduce it in 0.3.1. Does it also occur after an update to 0.3.2 for you?

  3. jfbibeau commented on Nov 4, 2013

    @jfbibeau
    Author

    Sorry I'm actually also running 0.3.2 where I see the NPE.

    Here's the EnhancedListView XML if it helps:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/parentLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
    
        <de.timroes.android.listview.EnhancedListView
            android:id="@id/android:list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/adLayout"
            android:layout_alignParentTop="true" />
    
        <TextView
            android:id="@id/android:empty"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:gravity="center"
            android:text="@string/main_no_gifts" >
        </TextView>
    
        <RelativeLayout
            android:id="@+id/adLayout"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_alignParentBottom="true" >
    
        </RelativeLayout>
    
    </RelativeLayout>
  4. Raghnall commented on Nov 28, 2013

    @Raghnall

    I also have this problem.
    Running Android Studio 0.3.6
    Loading Enhanced list view via Maven with the following gradle dependencies:

    dependencies {
        compile 'com.android.support:support-v4:18.+'
        compile 'com.nineoldandroids:library:2.4.0'
        compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
        compile 'com.viewpagerindicator:library:2.4.2-SNAPSHOT'
        compile 'de.timroes.android:EnhancedListView:0.1.2@aar'
    }
    

    Part of a list fragment so the XML is simple:

    <?xml version="1.0" encoding="utf-8"?>
    <de.timroes.android.listview.EnhancedListView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fastScrollEnabled="true" />
  5. safarious commented on Dec 16, 2013

    @safarious

    I got the same Error with Android Studio 0.3.6, Grandle 0.6+. I imported Version 0.1.2 of your library via mavencentral like this:

    dependencies {
        compile 'com.android.support:support-v4:+'
        compile 'de.timroes.android:EnhancedListView:0.1.2@aar'
    }
    

    This is the Error-Log from my layout:

    java.lang.ClassNotFoundException: de.timroes.android.listview.R$layout
        at com.intellij.util.lang.UrlClassLoader.findClass(UrlClassLoader.java:142)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at de.timroes.android.listview.EnhancedListView.init(EnhancedListView.java:361)
        at de.timroes.android.listview.EnhancedListView.<init>(EnhancedListView.java:339)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:375)
        at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:100)
        at com.android.tools.idea.rendering.ProjectCallback.loadView(ProjectCallback.java:165)
        at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
        at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
        at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755)
        at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
        at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:758)
        at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:373)
        at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:399)
        at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:336)
        at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332)
        at com.android.tools.idea.rendering.RenderService$2.compute(RenderService.java:538)
        at com.android.tools.idea.rendering.RenderService$2.compute(RenderService.java:527)
        at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:934)
        at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:527)
        at com.android.tools.idea.rendering.RenderService.render(RenderService.java:598)
        at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.compute(AndroidLayoutPreviewToolWindowManager.java:577)
        at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.compute(AndroidLayoutPreviewToolWindowManager.java:570)
        at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:945)
        at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:570)
        at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:83)
        at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6$1.run(AndroidLayoutPreviewToolWindowManager.java:518)
        at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
        at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
        at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
        at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
        at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6.run(AndroidLayoutPreviewToolWindowManager.java:513)
        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.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
        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.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
        at com.intellij.util.Alarm$Request$1.run(Alarm.java:297)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:695)
    

    Alltough I tried to compile it and get following error:

    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':activity:processDefaultFlavorDebugManifest'.
    > Manifest merging failed. See console for more info.
    
    

    Is there a fix for this Problem?

    EDIT 17.12.13:

    I did some additional research on this problem. It seems that this error encores on all three versions of this library, if you import it via MavenCentral.
    So I tried to manage the libraries with the libs folder. Also there the same error encores with all of the three versions.

  6. safarious commented on Dec 17, 2013

    @safarious

    Allright I could sort out what is the problem causing, that you can't build or run the app:

    The minSDK + targetSDK in your default Project is higher than the one in your library.

    The Library is using minSDK="8" and targetSDK="18" so you need to update your build.grandle the following way:

    android {
        compileSdkVersion 14
        buildToolsVersion '19.0.0'
    
      defaultConfig {
            minSdkVersion 8
            targetSdkVersion 18
        }
    

    The NullPointer in your Layoutfile is still there - but at least you can test your application.

  7. timroes commented on Dec 27, 2013

    @timroes
    Owner

    Null pointer exception doesn't seem to be fixed in 0.1.3 - validate this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions