0

i have an aar file(i make that) and i want use to another project's application app moudle.

the aar have some custom views

im using android studio


1.Problem

1) CustomViewLibrary Project

  • java sources

  • resources (strings, layouts, colors ...)

  • *export to aar this project

2) In other SomethingApp Project

  • *import the CustomViewLibrary Project's ARR

  • typing that some custom view's className to in layout XML


2.Result

  • get NullPointerException in XML Editor(it displayed layout xml preiview tab)
  • the exception from CustomViewLibrary Project's AAR(in CustomView class)
  • exception message is

    Rendering Problems

    java.lang.NullPointerException at android.content.res.Resources_Delegate.getColor(Resources_Delegate.java:183) at android.content.res.Resources.getColor(Resources.java:915) at android.content.Context.getColor(Context.java:508) at com.simplier.common.util.ResourceUtils.getColor(ResourceUtils.java:19) at com.simplier.common.ui.ActionBar.setTheme(ActionBar.java:245) at com.simplier.common.ui.ActionBar.updateUi(ActionBar.java:222) at com.simplier.common.ui.ActionBar.(ActionBar.java:69) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)


i tried rebuild, clear but it not working..

The expected problem is custom view aar access the strange context's resource. (The custom view access colors and others from context(CustomViewLibrary's resources))

sorry for my english..

how can i solve this? please help me


Edit

in other somthingApp, i want to use my aar to this somthingApp project

the my aar source line when i get NPE, it use aar's resource(in this case colors.xml) from somthingApp's context

Hyuk Park
  • 1
  • 2

1 Answers1

0

it solved

before

import aar to android studio's menu(File > New > Import Projects > Module ...)

after

apply the lines to app's build gradle

repositories {
  jcenter()
  flatDir {
    dirs 'libs'
  }
}
compile(name: 'CustomViewLibrary', ext: 'aar')

Now it success to rendering in xml editor AND run

Hyuk Park
  • 1
  • 2