Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova inAppBrowser "ResourceType" type issue for release build

i am using cordova for my application and using inAppBrowser plugin, before using this plugin cordova build android --release command was working properly but after adding this plugin it is showing error, if i am not giving --release it working properly means in the debug mode there is no issue. The error which i am getting is as follow

    /Users/mukesh/Documents/code/teamworkCordova/xyz/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:555: Error: Expected resource of type id [ResourceType]
                actionButtonContainer.setId(1);
                                            ~
/Users/mukesh/Documents/code/teamworkCordova/xyz/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:563: Error: Expected resource of type id [ResourceType]
                back.setId(2);
                           ~
/Users/mukesh/Documents/code/teamworkCordova/xyz/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:587: Error: Expected resource of type id [ResourceType]
                forward.setId(3);
                              ~
/Users/mukesh/Documents/code/teamworkCordova/xyz/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:610: Error: Expected resource of type id [ResourceType]
                edittext.setId(4);
                               ~
/Users/mukesh/Documents/code/teamworkCordova/xyz/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:633: Error: Expected resource of type id [ResourceType]
                close.setId(5);
                            ~
/Users/mukesh/Documents/code/teamworkCordova/xyz/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:679: Error: Expected resource of type id [ResourceType]
                inAppWebView.setId(6);
                                   ~

   Explanation for issues of type "ResourceType":
   Ensures that resource id's passed to APIs are of the right type; for
   example, calling Resources.getColor(R.string.name) is wrong.
like image 316
Mukesh Agarwal Avatar asked Sep 30 '15 13:09

Mukesh Agarwal


2 Answers

The latest release of the Inappbrowser plugin has several "errors" my Android Studio (version 1.4) complains about when building a release APK.

This on one of them.

The only way i found to get around this issue was to modify the content of InAppBrowser.java

I changed every occurence of object.setId(int) to object.setId(Integer.valueOf(int))

for example: inAppWebView.setId(6) -> inAppWebView.setId(Integer.valueOf(6))

Everybody who finds a better (without manipulating the source) solution is welcome.

like image 182
Andre Kreienbring Avatar answered Nov 08 '22 14:11

Andre Kreienbring


These "errors" are Lint errors, and it's because lint isn't sure that the number 6 is really the number 6, which is why you need to make sure that you do Integer.valueOf(int) on every object.setId.

I fixed this on the platform level so that it will no longer cause the compilation to fail, but to make lint happy, we will probably change the source so Integer.valueOf is used.

like image 25
Joe B Avatar answered Nov 08 '22 15:11

Joe B