2013-08-28 64 views
3

我可以使用apktool來解碼apk然後再次爲我的正常的Android項目構建。如何使用庫項目工作apktool構建?

但是,當我對依賴庫項目(appcompat)的項目嘗試了同樣的事情時,它失敗並出現以下錯誤。

是否需要使用庫項目構建,如果有,我該如何指定?

$ apktool build apkdecode repack.apk 
I: Checking whether sources has changed... 
I: Smaling... 
I: Checking whether resources has changed... 
I: Building resources... 
/<currentdir>/apkdecode/res/values/styles.xml:59: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'. 
/<currentdir>/apkdecode/res/values/styles.xml:99: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'. 
/<currentdir>/apkdecode/res/values/styles.xml:146: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'. 
/<currentdir>/apkdecode/res/values/styles.xml:176: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'. 
/<currentdir>/apkdecode/res/values/styles.xml:192: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base.DropDownItem'. 
/<currentdir>/apkdecode/res/values/styles.xml:218: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'. 
/<currentdir>/apkdecode/res/values/styles.xml:225: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.Base'. 
/<currentdir>/apkdecode/res/values/styles.xml:242: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Base'. 
/<currentdir>/apkdecode/res/values/styles.xml:275: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'. 
/<currentdir>/apkdecode/res/values-v14/styles.xml:50: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'. 
/<currentdir>/apkdecode/res/values/styles.xml:467: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Base'. 
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 8, --target-sdk-version, 11, -F, /var/folders/6l/q11hqqj57rs0lgxcx1njdlxc0000gn/T/APKTOOL2534308390228031373.tmp, -0, arsc, -I, /<toolpath>/apktool/framework/1.apk, -S, /<currentdir>/apkdecode/res, -M, /<currentdir>/apkdecode/AndroidManifest.xml] 
    at brut.androlib.Androlib.buildResourcesFull(Androlib.java:358) 
    at brut.androlib.Androlib.buildResources(Androlib.java:283) 
    at brut.androlib.Androlib.build(Androlib.java:206) 
    at brut.androlib.Androlib.build(Androlib.java:176) 
    at brut.apktool.Main.cmdBuild(Main.java:228) 
    at brut.apktool.Main.main(Main.java:79) 
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 8, --target-sdk-version, 11, -F, /var/folders/6l/q11hqqj57rs0lgxcx1njdlxc0000gn/T/APKTOOL2534308390228031373.tmp, -0, arsc, -I, /<toolpath>/apktool/framework/1.apk, -S, /<currentdir>/apkdecode/res, -M, /<currentdir>/apkdecode/AndroidManifest.xml] 
    at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:357) 
    at brut.androlib.Androlib.buildResourcesFull(Androlib.java:336) 
    ... 5 more 
Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 8, --target-sdk-version, 11, -F, /var/folders/6l/q11hqqj57rs0lgxcx1njdlxc0000gn/T/APKTOOL2534308390228031373.tmp, -0, arsc, -I, /<toolpath>/apktool/framework/1.apk, -S, /<currentdir>/apkdecode/res, -M, /<currentdir>/apkdecode/AndroidManifest.xml] 
    at brut.util.OS.exec(OS.java:89) 
    at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:355) 
    ... 6 more 

回答

1

這是一個apktool v1(1.5.3)的問題。 有幾種方法可以解決它。

1.編輯styles.xml。 將空'父'屬性添加到錯誤行上的標記。例如:

之前

59: <style name="Widget.AppCompat.Base.ActionBar"> 

59: <style name="Widget.AppCompat.Base.ActionBar" parent=""> 

後即可生成項目。通過這種方式,您需要在每次解碼apk時編輯xml。

2.編輯apktool來源並重建它。 你必須在文件中編輯方法「serializeToResValuesXml 'Android的apktool/brut.apktool/apktool-LIB/src目錄/主/ JAVA /香檳/ androlib/RES /數據/價值/ ResStyleValue.java':

之前

if (!mParent.isNull()) { 
    serializer.attribute(null, "parent", mParent.encodeAsResXmlAttr()); 
} 

if (!mParent.isNull()) { 
    serializer.attribute(null, "parent", mParent.encodeAsResXmlAttr()); 
} else if (res.getResSpec().getName().indexOf('.') != -1) { 
    serializer.attribute(null, "parent", ""); 
} 

3.只要使用apktool V2 :)

相關問題