Repository: ibotpeaches/apktool
Issue: Error decompiling Hangouts v.20+

### Information
1. 2.2.4-acb004-SNAPSHOT (and 2.2.3)
2. Mac
3. Play Store

### Stacktrace/Logcat

```
I: Using Apktool 2.2.4-acb004-SNAPSHOT on Hangouts.apk
I: Loading resource table...
Exception in thread "main" brut.androlib.AndrolibException: Could not decode arsc file
	at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:52)
	at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:562)
	at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:72)
	at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:64)
	at brut.androlib.Androlib.getResTable(Androlib.java:68)
	at brut.androlib.ApkDecoder.setTargetSdkVersion(ApkDecoder.java:207)
	at brut.androlib.ApkDecoder.decode(ApkDecoder.java:109)
	at brut.apktool.Main.cmdDecode(Main.java:166)
	at brut.apktool.Main.main(Main.java:81)
Caused by: java.io.IOException: Expected: 0x00000008, got: 0x00000202
	at brut.util.ExtDataInput.skipCheckShort(ExtDataInput.java:56)
	at brut.androlib.res.decoder.ARSCDecoder.readValue(ARSCDecoder.java:309)
	at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:241)
	at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:226)
	at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:156)
	at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:118)
	at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:80)
	at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:47)
	... 8 more
```

### Steps to Reproduce
1. apktool d Hangouts.apk

Changed files:
brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java

diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java
index 1888e954..95c5610b 100644
--- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java
+++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java
@@ -156,7 +156,7 @@ public class ARSCDecoder {
             readTableType();
             
             // skip "TYPE 8 chunks" and/or padding data at the end of this chunk
-            if(mCountIn.getCount() < mHeader.endPosition) {
+            if (mCountIn.getCount() < mHeader.endPosition) {
                 mCountIn.skip(mHeader.endPosition - mCountIn.getCount());
             }
             
@@ -238,6 +238,12 @@ public class ARSCDecoder {
         short flags = mIn.readShort();
         int specNamesId = mIn.readInt();
 
+        // If we are here, we probably already inserted any remaining dummy resources. No need to parse
+        // any resources that doesn't have type information
+        if (mCountIn.getCount() == mHeader.endPosition) {
+            return;
+        }
+
         ResValue value = (flags & ENTRY_FLAG_COMPLEX) == 0 ? readValue() : readComplexEntry();
 
         if (mTypeSpec.isString() && value instanceof ResFileValue) {
@@ -519,6 +525,8 @@ public class ARSCDecoder {
     private HashMap<Integer, ResTypeSpec> mResTypeSpecs = new HashMap<>();
 
     private final static short ENTRY_FLAG_COMPLEX = 0x0001;
+    private final static short ENTRY_FLAG_PUBLIC = 0x0002;
+    private final static short ENTRY_FLAG_WEAK = 0x0004;
 
     public static class Header {
         public final short type;