You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Victor Felder (JIRA)" <ji...@apache.org> on 2016/02/18 17:10:19 UTC

[jira] [Closed] (CB-10634) res/values/*.xml don't end up in apk

     [ https://issues.apache.org/jira/browse/CB-10634?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Victor Felder closed CB-10634.
------------------------------
    Resolution: Cannot Reproduce

> res/values/*.xml don't end up in apk
> ------------------------------------
>
>                 Key: CB-10634
>                 URL: https://issues.apache.org/jira/browse/CB-10634
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 5.1.1
>         Environment: * OS X 10.11.3 (El Capitan)
> * Darwin 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
> * Meteor 1.2.1
>            Reporter: Victor Felder
>
> **TL;DR:** My xml config files placed in `res/values/` are missing from the debug apk; the app tries to access these resources (eg. in `colors.xml`), fails and crashes because of this.
> * When I `ls cordova-build/platforms/android/res/values`, the files are there.
> * When I `unzip -l build/outputs/apk/android-release-unsigned.apk` to see what's in there, I see all resources **except** `res/values`, it's just not there.
> * When I `apktool d -s ./release-unsigned.apk -o ./release-unsigned-dump/`, I see them all, even the `res/values`!
> * When I jarsign the apk, they don't get signed. (Verbose mode shows each file getting signed, `res/values` is not there.)
> ---
> **Long version:**
> I wrote a Android app in Java. It spawns an activity and it works properly when used as a standalone app.
> I need to call it from Cordova, so I transformed it into a Cordova plugin. I simply added a `MyPlugin.java` to my app which extends `CordovaPlugin`, receives a JS event and spawns the activity when I click an HTML button.
> It went more or less smoothly: the plugin gets compiled, the cordova application works fine, I tap the button, the activity is spawned but immediately crashes because a resource is missing.
>     E AndroidRuntime: FATAL EXCEPTION: main
>     E AndroidRuntime: Process: com.id1x54bf32ogivwhevdd0, PID: 16617
>     E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.id1x54bf32ogivwhevdd0/com.my.awesome.plugin.MyPlugin}: android.content.res.Resources$NotFoundException: Resource ID #0x7f040007
>     E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
>     E AndroidRuntime:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
>     E AndroidRuntime:    at android.app.ActivityThread.-wrap11(ActivityThread.java)
>     E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
>     E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:102)
>     E AndroidRuntime:    at android.os.Looper.loop(Looper.java:148)
>     E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:5417)
>     E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
>     E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
>     E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
>     E AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f040007
>     E AndroidRuntime:    at android.content.res.Resources.getValue(Resources.java:1351)
>     E AndroidRuntime:    at android.content.res.Resources.getColor(Resources.java:963)
>     E AndroidRuntime:    at android.content.res.Resources.getColor(Resources.java:936)
>     E AndroidRuntime:    at com.my.awesome.plugin.SomethingResourceFactory.fromXml(SomethingResourceFactory.java:27)
>     E AndroidRuntime:    at com.my.awesome.plugin.MyPlugin.onCreate(MyPlugin.java:100)
>     E AndroidRuntime:    at android.app.Activity.performCreate(Activity.java:6251)
>     E AndroidRuntime:    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
>     E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
>     E AndroidRuntime:    ... 9 more
> Apparently a resource is missing. When I take a look at `R.java`, I find it in there:
>     public static final class color {
>         [...]
>         public static int color_myfragment_background_selected=0x7f040007;
> This color is defined in `res/values/colors.xml`:
>     <color name="color_myfragment_background_selected">#03abb4</color>
> which is included in `plugin.xml`:
>     <resource-file src="res/values/colors.xml" target="res/values/colors.xml" />
> I tried adding this in `plugin.xml`:
>     <config-file target="res/values/colors.xml" parent="/resources">
>         <color name="color_myfragment_background_selected">#03abb4</color>
> and of course, when I started paying attention to what `adb install -r thing.apk` outputs, I noticed this:
>     signing: res/layout/firstlayout.xml
>     signing: res/layout/itemlayout.xml
>     signing: res/menu/my_menu.xml
>     signing: res/xml/config.xml
>     signing: resources.arsc
>     signing: classes.dex
>     signing: NOTICE_ANDROID.txt
>     signing: VERSION
> `res/values` is nowhere to be found. Everything else is here. My own `res/layout*`s, `res/drawable*`, etc.
> * When I `ls cordova-build/platforms/android/res/values`, the files are there.
> * When I `unzip -l build/outputs/apk/android-release-unsigned.apk` to see what's in there, I see all resources **except** `res/values`, it's just not there.
> * When I `apktool d -s ./release-unsigned.apk -o ./release-unsigned-dump/`, I see them all, even the `res/values`!
> * When I jarsign the apk, they don't get signed. (Verbose mode shows each file getting signed, `res/values` is not there.)
> If you have a clue about what's going on here, it'd be much appreciated.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org