3

I am running into a problem that I don't quite understand. I have an .aar file that I am building locally it is included into my main app as such:

// main app gradle
compile 'com.mycompany.mysdk:mysdk@aar'

The aar file has an activity and some widgets as below

// This code is inside the aar file (built locally)
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fatal_error);

    mLoadingIndicator = findViewById(R.id.loading_indicator);
    if (mLoadingIndicator != null) {
        mLoadingIndicator.setVisibility(View.GONE);
    }

Yet, when I run the app, my 'mLoadingIndicator' is always null. The R.layout.activity_fatal_error is valid but no widgets inside are found. The widget definitely exists and here is a snipped of the widget I am trying to fetch.

// activity_fatal_error.xml
// This id definitely exists
<ProgressBar
    android:id="@+id/loading_indicator"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="visible"/>

My issue looks exactly like the issued mentioned below:

Can't find resource identifiers from AAR in XML

but whether I spell out or not the resource Id, it never finds it. Therefore my 'mLoadingIndicator' is always null.

I tried:

    mLoadingIndicator = findViewById(com.mycompany.mysdk.R.id.loading_indicator);
    // mLoadingIndicator is still null
    if (mLoadingIndicator != null) {
        mLoadingIndicator.setVisibility(View.GONE);
    }

Anyone pointers is greatly appreciated.

Community
  • 1
  • 1
gmmo
  • 2,577
  • 3
  • 30
  • 56
  • As per the link you mentioned, this below line in your code is wrong - `mLoadingIndicator = findViewById(com.mycompany.mysdk.R.id.loading_indicator);` Just try `R.id.loading_indicator` – Dibzmania Jan 31 '17 at 03:55
  • I tired both, neither work. It does not resolve the namespace, – gmmo Jan 31 '17 at 18:46

0 Answers0