I'm trying to use the layoutopt (from the SDK) on the layouts in my project.
Every time I'm running the layoutopt on a layout which has in it 'android:layout_weight' somewhere, I get this exception:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.lang.String.substring(Unknown Source)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroovyMethods.java:2794)
at org.codehaus.groovy.runtime.dgm$213.doMethodInvoke(Unknown Source)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:44)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at Script5.run(Script5.groovy:15)
at com.android.layoutopt.uix.rules.GroovyRule$1.call(GroovyRule.java:50)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:105)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:212)
at com.android.layoutopt.uix.rules.GroovyRule.run(GroovyRule.java:65)
at com.android.layoutopt.uix.LayoutAnalyzer.applyRules(LayoutAnalyzer.java:246)
at com.android.layoutopt.uix.LayoutAnalyzer.analyze(LayoutAnalyzer.java:233)
at com.android.layoutopt.uix.LayoutAnalyzer.analyze(LayoutAnalyzer.java:238)
at com.android.layoutopt.uix.LayoutAnalyzer.analyze(LayoutAnalyzer.java:221)
at com.android.layoutopt.uix.LayoutAnalyzer.analyze(LayoutAnalyzer.java:153)
at com.android.layoutopt.uix.LayoutAnalyzer.analyze(LayoutAnalyzer.java:128)
at com.android.layoutopt.cli.Main.analyze(Main.java:61)
at com.android.layoutopt.cli.Main.analyzeFiles(Main.java:53)
at com.android.layoutopt.cli.Main.main(Main.java:46)
Any one has i开发者_JAVA技巧dea why this is happening?
Sorry, but I found my problem.
In the layout I had 2 schemes pointing to the same place:
<LinearLayout android:layout_height="59dp"
android:layout_width="321dp" android:background="@android:color/transparent"
xmlns:android1="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal">
</LinearLayout>
I don't know how did it happen, probably bug or something, I didn't write it. Anyway, This caused the layoutopt to fail.
Thank you for trying helping
精彩评论