Skip to main content
Participant
February 19, 2014
Question

Android R.* access and the case of the missing styleable

  • February 19, 2014
  • 2 replies
  • 4597 views

Hi,

I'm trying to use appcompat-v7 in my ANE and access it via the R.* mechanism.

The packaging step of the ANE works fine.

However, when building the final .apk using this ANE, the styleable elements disappear. The other resources (such as drawables, etc) are present just fine in the output.

The artifacts I'm using are classes.jar and the res folder from inside the .aar for appcompat-v7: \android-sdk\extras\android\m2repository\com\android\support\appcompat-v7\19.0.1\appcompat-v7-19.0.1.aar

The end result is that the generated apk contains and R file for this library, and an R.styleable, but it's empty (by comparison in a properly built non-air android app this R.styleable would contain quite a few different fields). The other R. classes seem to be properly populated with a merge of the resource ids - R.string, R.layout, etc.

Here's (a trimmed down version) of the platform.xml I'm using when packaging the ANE:

<platform xmlns="http://ns.adobe.com/air/extension/4.0">

    <packagedDependencies>

        <packagedDependency>support-v4-19.0.1.jar</packagedDependency>

        <packagedDependency>android.support.v7.appcompat-classes.jar</packagedDependency>

    </packagedDependencies>

    <packagedResources>

        <packagedResource>

            <packageName>android.support.v7.appcompat</packageName>

            <folderName>android.support.v7.appcompat-res</folderName>

        </packagedResource>

    </packagedResources>

</platform>

Here are the errors I'm seeing during install time:

D/dalvikvm﹕ DexOpt: couldn't find static field Landroid/support/v7/appcompat/R$styleable;.ActionBarLayout

D/dalvikvm﹕ DexOpt: couldn't find static field Landroid/support/v7/appcompat/R$styleable;.ActionBarWindow

D/dalvikvm﹕ DexOpt: couldn't find static field Landroid/support/v7/appcompat/R$styleable;.Theme          

...the list continues here

and at runtime:

java.lang.NoSuchFieldError: android.support.v7.appcompat.R$styleable.ActionBarWindow

So the question is: are styleable attributes supported in air native extensions?

Thanks,

Radu

This topic has been closed for replies.

2 replies

Inspiring
October 8, 2017

I've been playing with this same issue for like 15 hours this weekend. Happened with AIR 25 and AIR 27, exactly what is described with regards to the smali code of R.stylable being basically "empty".

Btw. for me this demonstrated as static field missing called "AppCompatTheme:[I" (Java error shown on adb log during runtime). Somehow the styleables from the values.xml weren't generated properly, all the other R$whatever were fine.

I was building from Adobe Animate. What helped me was to not build from that IDE but from command line. Using the same AIR version, the smali code generated is fine and the AppCompat derived Activity launches without errors from my ANE.

Participant
October 11, 2017

Hi, I have the same problem but with building directly from command line. Can you share what build command you use?

Also, what JAVA version used for this?

Thanks

Inspiring
October 11, 2017

Hey, well I might be just lucky then. I am still not 100% sure what causes this, it must be some strange random bug?

Using JDK 1.8.0_121. The command line is kind of hard to share, its a pretty complex build script with loads of variables. The most important part is here:

call %AIR_PATH%%COMPILER% -define=CONFIG::AIR,%AIR% -define+=CONFIG::FLASH_CONTAINER,"'mp4'" -target-player=24.0 -debug=true -static-link-runtime-shared-libraries=true -library-path=src/UI.swc -library-path=%FLEX_PATH% src/Document.as -library-path=src/UI.swc -library-path=%LIBRARY_PATH%%LIBRARY_FILE% -library-path=lib/androidSupport-full.ane -o bin/example.swf

(as you can notice I'm using the support libs from myflashlabs). Using AIR 27

------------------

Update: My client also got the same issue, building from IDE. After I sent him a new version of my ANE with insignificant change(added some logging into one place). I told him to remove the new version ANE / re-add the old ANE / rebuild. Then remove old ANE / re-add new ANE and rebuild. Now it works for him. It appears to be random :/

Nimisha1
Participating Frequently
February 19, 2014

Hi Radu,

Is your ANE project a "library project"? If yes then please share the resources with me so that I can repro the issue at our end.

-NImisha

Participant
June 14, 2014

Hello Nimisha1,

I'm also trying to use appcompat-v7(ActionBarActivity) with ANE and get the same error as radu_k.

At first, I was using AIR 4.0 and I thought it was related with the bug #3723876 which is said R$Styleable.class

goes missing. But It still happens after I updated the SDK to 14. So I'm wondering how appcompat-v7 can be

used with ANE.

My ANE project is a flex library project and I suppose my approach so far is the same as radu_k's.

But in my case, I can see the resources in the apk. There's a folder named 'assets' in the root of the apk

and the appcompat-v7 resources are in the hierarchy some levels down there. Is this what it's supposed

to be when you use appcompat-v7, or some other jars with resources?

I can also see a folder named 'res' in the root of the apk and looks like all the resources should be kept

here in comparison with the structure of the native apk, though.

Anyhow, It would be appreciated if you could help me. I can share more information if you like.

Thanks in advance.

middletail

Nimisha1
Participating Frequently
June 20, 2014

Hi middletail,

Please use the latest AIR beta build which is 14.0.0.125 to test you app and let us know if you still face the issue.

Note: To use the fix for this bug one has to set JAVA_HOME in machine’s path before packaging the APK.


Thanks,

Nimisha