bingshi / android-apktool

Automatically exported from code.google.com/p/android-apktool
Other
0 stars 0 forks source link

Custom android attribute - Recompile Fail #666

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1.Decompile and Recompile Apk file

What is the expected output? What do you see instead?
When using custom library attribute , need to recompile apk file without error 

What version of the product are you using? On what operating system?
Windows 8 
Apktool version: 2.0.0-dirty (Builded from git)

Please provide any additional information below.

Issue 1 With PagerSlidingTabStrip :

    <LinearLayout android:orientation="vertical" android:clipChildren="false" style="@style/Match">
        <com.astuetz.PagerSlidingTabStrip  android:pstsShouldExpand="false"  />
        <android.support.v4.view.ViewPager android:id="@id/pager" style="@style/Match" />
    </LinearLayout>

SNAPSHOT\res\layout\content_pager.xml:5: error: No resource identifier found 
for attribute 'pstsShouldExpand' in package 'android'

Issue 2 : With custom view 

    <com.myapp.android.app.widget.AspectRatioLayout  android:aspectRatio="@dimen/thumbnail_aspect_ratio">

\res\layout-sw600dp\list_item_single.xml:4: error: No resource identifier found 
for attribute 'aspectRatio' in package 'android'

Issue 3: oak library

<oak.widget.TextViewWithFont android:id="@id/title" 
android:oakFont="@string/font_light" style="@style/Font.Item" />

\res\layout\list_item_search.xml:5: error: Noresource identifier found for 
attribute 'oakFont' in package 'android'

Exception:

brut.androlib.AndrolibException: brut.androlib.AndrolibException: 
brut.common.BrutException: could not exec command: [C:
\Users\testuser\AppData\Local\Temp\brut_util_Jar_123662913771692459.tmp, p, 
--forced-package-id, 127, --min-sdk-version,
14, --target-sdk-version, 20, --version-code, 1017, --version-name, 
1.0-SNAPSHOT, -F, C:\Users\testuser\AppData\Local\Tem
p\APKTOOL335103424956595181.tmp, -0, arsc, -I, 
C:\Users\testuser\apktool\framework\1.apk, -S, C:\Users\testuser\Desktop\HB
O Nordic-com.hbo.android.app-1017-v1.0-SNAPSHOT\res, -M, 
C:\Users\testuser\Desktop\TestApp
.0-SNAPSHOT\AndroidManifest.xml]
        at brut.androlib.Androlib.buildResourcesFull(Androlib.java:439)
        at brut.androlib.Androlib.buildResources(Androlib.java:367)
        at brut.androlib.Androlib.build(Androlib.java:290)
        at brut.androlib.Androlib.build(Androlib.java:262)
        at brut.apktool.Main.cmdBuild(Main.java:236)
        at brut.apktool.Main.main(Main.java:88)

Note :
unfortunately I cannot send the apk file due to Non-disclosure agreement. 

Original issue reported on code.google.com by openapp...@gmail.com on 9 Aug 2014 at 8:32

GoogleCodeExporter commented 9 years ago
I believe this might be a declare-styleable bug. Apktool's attr decoder doesn't 
handle these at all it seems.

This simple patch breaks the unit-tests by only adding 2 custom attributes 
within a <declare-styleable> block. I assume this is what those issues were 
using since they were custom attributes.

Needs more investigation, but confirmed with this patch since APK cannot be 
shared. 

Original comment by connor.tumbleson on 12 Aug 2014 at 12:33

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Connor.tumbleson,

I deployed your patch file standards in our project. The issues still persists. 
There is not much changes to the issue. We are currently experiencing the 
following, after deploying the patch file:

Attribute "oakFont" has already been defined
No resource identifier found for attribute 'oakFont' in package 'android'

I am also experiencing Absence of resource identifier, that is to be found in 
attributes such as 'aspectRatio', 'pstsShouldExpand','font' etc.

Please provide your inputs to the above technicalities.

Original comment by rahmanre...@gmail.com on 13 Aug 2014 at 2:02

GoogleCodeExporter commented 9 years ago
The patch had nothing to do with fixing anything. The patch file created 
failing unit-tests since you could not provide an APK. The patch allows this 
bug to be reproducible for anyone so other devs can investigate if they wish.

I have not researched the problem or investigated further. PRs are welcome 
though. I would start my research in the AttrDecoder. 

Original comment by connor.tumbleson on 13 Aug 2014 at 2:10

GoogleCodeExporter commented 9 years ago
Custom attributes defined in <declare-styleable> are just moved to global 
status. IE

Original
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="MyCustomView">
        <attr name="custom0" format="string" />
        <attr name="custom1" format="boolean" />
    </declare-styleable>
</resources>

Decoded
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <attr name="custom0" format="string" />
    <attr name="custom1" format="boolean" />
</resources>

The type/name of the custom attributes are maintained. They just go from a 
scoped access to global, while this isn't a perfect 100% match from original to 
rebuilt, it still gets the job done. Since there is no APK due to NDA I believe 
the rest of the bug is a duplicate of 660 or close to that. 

Maybe we will revisit this when we have less major bugs.

Original comment by connor.tumbleson on 16 Aug 2014 at 7:10

GoogleCodeExporter commented 9 years ago
As mentioned before, we cant share the APK due to confidentiality reasons. 

However, we can walk through the source code through a web ex session.
Please provide your available date & time, along with your time zone you work 
in.

Note: I have sent you an email with the Resources folder attached to it. But, 
still I would want to discuss this issue with you over the webex session

Thanks

Original comment by rahmanre...@gmail.com on 18 Aug 2014 at 9:49

GoogleCodeExporter commented 9 years ago
Hi canon,

When we decompile apk with latest apk-tool, the above schemas are removed from 
apk manifest itself.any reason behind this?

StaticXmlSerializerWrapper MSYS Prefix::
StaticXmlSerializerWrapper MSYS Type::CDATA
StaticXmlSerializerWrapper MSYS AttributeName::style
StaticXmlSerializerWrapper MSYS Value::@style/Font.Item
StaticXmlSerializerWrapper MSYS NameSapce::
StaticXmlSerializerWrapper MSYS Prefix::
StaticXmlSerializerWrapper MSYS Type::CDATA
StaticXmlSerializerWrapper MSYS AttributeName::font
StaticXmlSerializerWrapper MSYS Value::@string/font_light
StaticXmlSerializerWrapper MSYS NameSapce::http://oak/oak/scheme
StaticXmlSerializerWrapper MSYS Prefix::oak
StaticXmlSerializerWrapper MSYS Type::CDATA
########################################################################
--------------------- ###3###---------------------------------------------
StaticXmlSerializerWrapper MSYS pp.getText () ::null:oak.widget.TextViewWithFont
########################################################################
--------------------- ###2###---------------------------------------------
StaticXmlSerializerWrapper MSYS pp.getText () ::null:oak.widget.TextViewWithFont
StaticXmlSerializerWrapper MSYS AttributeName::id
StaticXmlSerializerWrapper MSYS Value::@id/title

Original comment by rahmanre...@gmail.com on 22 Aug 2014 at 8:52