5

I have the following project structure which I want to convert to a instant apps. The installed project works fine, but when I want to runt the instant app version, the base feature module loads perfectly, but when it comes to the feature module, then it fails to find the resources from its module. When I move the resources from feature module to base module, then it recognizes them with the full package name of the base feature module.

The project structure is the following: - app module - instant app module
- base feature module - com.app.base.feature - feature module - com.app.feature.

in feature module when the resource is located in feature module itself the resources are not found, but they are found when I move the resource into the base feature module and reference them as following com.app.base.feature.R.layout.sample_layout.

EDIT: No known package when getting value for resource number 0x80060009.

Any kind of help would be appreciated :)

X-HuMan
  • 1,488
  • 1
  • 17
  • 37

4 Answers4

2

When you modularise your app, the base feature module cannot access any classes or resources present in the feature module. However the vice versa is possible.

It might so happen that when you create the fragment, the R class might be pointing to the base module. Try specifying the full path to the feature module R class while accessing the layout and check if it solves your issue. Just go through all your R class references and specify full paths to base and feature R classes wherever necessary.

Vishy
  • 548
  • 7
  • 17
1

It is actually a bug of the canary version. We already discussed it here: stackoverflow question

We opened a bug on the official Android Studio tracker in which I provided more informations: bug tracker

Please do not hesitate to star it to make Google prioritize the fix (currently P2).

With further experimentation I noticed that: So if we have a project with 4 modules:

base
f1
f2
f3

f3 instant module (the last one in alphabetical order) will works correctly and will link all of its own resources correctly. f1 and f2, on the other hand, will use resources from f3 module instead of their own and hence either they crash or their layout / images / strings got really messed up.

Finally problem occurs only for resources to resources references trough XML (i.e. reference a drawable from a layout or establish a constraint between two elements of a layout). Hence:

  • <ImageView android:src="@drawable/icon"/> --> will shows the problem
  • But in java image.setDrawable(R.drawable.icon) --> will work correctly

ALSO, concerning your EDIT 1: there is a second bug that I also reported in a second tracker here: bug tracker. In this case if you add a XML tag in your layout or a fragment that use an XML TAG in their layout. Instant app will crash. Please star the bug if you find out this is also the cause for you.

gbaccetta
  • 4,449
  • 2
  • 20
  • 30
1

The latest build-tools have been patched in with a fix for this issue.

  • Please update your Android SDK Build-Tools to 27.0.2 version.
  • Ensure you are on Android Studio 3.0.1 or newer.

The Google issue tracker post regarding the Android Instant Application error crash has also been updated.


Note: Bug link: issuetracker.google.com/issues/62935326 might also be resolved in the latest Android Build-Tools 27.0.2 roll-out, since it is also related to missing/misreferenced resources.

ManmeetP
  • 801
  • 7
  • 17
0

I found this problem similar problem when I created a project with Instant App and Kotlin support without Support Library. The Android Studio intellisense din't add the correct import for the Resources. So, I changed that import:

import com.company.awesomeapp.feature.R

For this:

import com.company.awesomeapp.R

And everything worked fine. My thought is: for modular apps, the intellisense doesn't know what is the correct reference, so, the project broken in the compile time.

Ângelo Polotto
  • 8,463
  • 2
  • 36
  • 37