shwenzhang / AndResGuard

proguard resource for Android by wechat team
Apache License 2.0
8.54k stars 1.54k forks source link

ERROR:String index out of range: -32 #63

Closed developerzhu closed 8 years ago

developerzhu commented 8 years ago
simpleton commented 8 years ago

please paste the call stack.

On Wed, Apr 27, 2016 at 3:25 PM, zhuangjh notifications@github.com wrote:

Reopened #63 https://github.com/shwenzhang/AndResGuard/issues/63.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/shwenzhang/AndResGuard/issues/63#event-642517930

developerzhu commented 8 years ago

Here is the error Log: ..... AGPBI: {"kind":"error","text":"indicate that it is not an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.bouncycastle.asn1.BERInputStream$1) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is not an inner class.","sources":[{}]}

.....

:Master:resguard FAILED

FAILURE: Build failed with an exception.

BUILD FAILED

Total time: 5 mins 14.34 secs

And Here is my build.gradle setting:

buildscript { repositories { mavenCentral() jcenter() }

dependencies {
    classpath 'com.android.tools.build:gradle:2.0.0'
    classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.1.7'
}

}

repositories { mavenCentral()

flatDir {
    dirs 'libs' //this way we can find the .aar file in libs folder
}

}

apply plugin: 'com.android.application' apply plugin: 'AndResGuard'

dependencies { compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:support-v4:23.1.1' compile fileTree(dir: 'libs', include: ['*.jar']) }

android { compileSdkVersion 23 buildToolsVersion '23.0.2'

defaultConfig {
    versionName VERSION_NAME
    versionCode VERSION_CODE
    minSdkVersion 15
    targetSdkVersion 23
    multiDexEnabled true // Enabling multidex support.

    ndk {
        abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
    }
}

lintOptions {
    abortOnError false
}

dexOptions {
    javaMaxHeapSize "4g"
}

signingConfigs {
    release {
        storeFile file('......')
        storePassword ''
        keyAlias ''
        keyPassword ''
    }

}

buildTypes {
    release {
        minifyEnabled false
        shrinkResources true
        proguardFiles 'proguard-android.txt'
        signingConfig signingConfigs.release
    }

    debug {
        minifyEnabled false
        shrinkResources true
    }
}

packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/MANIFEST.MF'
}

sourceSets {
    main {
        manifest.srcFile 'src/main/AndroidManifest.xml'
        java.srcDirs = ['src/main/java']
        resources.srcDirs = ['libs']
        aidl.srcDirs = ['src/main/aidl']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['src/main/res']
        assets.srcDirs = ['src/main/assets']
    }

    instrumentTest.setRoot('tests')
}

productFlavors {
    ......
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

}

andResGuard { mappingFile = null use7zip = true useSign = true keepRoot = false whiteList = [ "packagename.R." ] compressFilePattern = [ ".png", ".jpg", ".jpeg", "*.gif", "resources.arsc" ] sevenzip { artifact = 'com.tencent.mm:SevenZip:1.1.7' } }

simpleton commented 8 years ago

Could you run resugard with --stacktrace?

On Wed, Apr 27, 2016 at 4:31 PM, developer notifications@github.com wrote:

Here is the error Log: ..... AGPBI: {"kind":"error","text":"indicate that it is not an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.bouncycastle.asn1.BERInputStream$1) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is not an inner class.","sources":[{}]}

.....

:Master:resguard FAILED

FAILURE: Build failed with an exception.

-

What went wrong: Execution failed for task ':App-Master:resguard'.

String index out of range: -32

-

Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 5 mins 14.34 secs

And Here is my build.gradle setting:

buildscript { repositories { mavenCentral() jcenter() }

dependencies { classpath 'com.android.tools.build:gradle:2.0.0' classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.1.7' }

}

repositories { mavenCentral()

flatDir { dirs 'libs' //this way we can find the .aar file in libs folder }

}

apply plugin: 'com.android.application' apply plugin: 'AndResGuard'

dependencies { compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:support-v4:23.1.1' compile fileTree(dir: 'libs', include: ['*.jar']) }

android { compileSdkVersion 23 buildToolsVersion '23.0.2'

defaultConfig { versionName VERSION_NAME versionCode VERSION_CODE minSdkVersion 15 targetSdkVersion 23 multiDexEnabled true // Enabling multidex support.

ndk {
    abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}

}

lintOptions { abortOnError false }

dexOptions { javaMaxHeapSize "4g" }

signingConfigs { release { storeFile file('......') storePassword '' keyAlias '' keyPassword '' }

}

buildTypes { release { minifyEnabled false shrinkResources true proguardFiles 'proguard-android.txt' signingConfig signingConfigs.release }

debug {
    minifyEnabled false
    shrinkResources true
}

}

packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/MANIFEST.MF' }

sourceSets { main { manifest.srcFile 'src/main/AndroidManifest.xml' java.srcDirs = ['src/main/java'] resources.srcDirs = ['libs'] aidl.srcDirs = ['src/main/aidl'] renderscript.srcDirs = ['src'] res.srcDirs = ['src/main/res'] assets.srcDirs = ['src/main/assets'] }

instrumentTest.setRoot('tests')

}

productFlavors { ...... }

compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 }

}

andResGuard { mappingFile = null use7zip = true useSign = true keepRoot = false whiteList = [ "com.everhomes.android.master.R.

" ] compressFilePattern = [ ".png", " .jpg", ".jpeg", "*.gif", "resources.arsc" ] sevenzip { artifact = 'com.tencent.mm:SevenZip:1.1.7' } }

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/shwenzhang/AndResGuard/issues/63#issuecomment-215010460

developerzhu commented 8 years ago
developerzhu commented 8 years ago

And my whiteList setting is: whiteList = [ "my packagename.R.*" ]

developerzhu commented 8 years ago

How can I add my all Res to whiteList? if I set like this: whiteList = [ "my packagename.R.." ]

it doesn't work!

simpleton commented 8 years ago

This's the whitelist snippet in my project.

whiteList = [
            "com.xmonster.letsgo.R.drawable.icon",
            "com.xmonster.letsgo.R.string.com.crashlytics.*",
            "com.xmonster.letsgo.R.string.umeng*",
            "com.xmonster.letsgo.R.string.UM*",
            "com.xmonster.letsgo.R.string.tb_*",
            "com.xmonster.letsgo.R.layout.umeng*",
            "com.xmonster.letsgo.R.layout.tb_*",
            "com.xmonster.letsgo.R.drawable.umeng*",
            "com.xmonster.letsgo.R.drawable.tb_*",
            "com.xmonster.letsgo.R.anim.umeng*",
            "com.xmonster.letsgo.R.color.umeng*",
            "com.xmonster.letsgo.R.color.tb_*",
            "com.xmonster.letsgo.R.style.*UM*",
            "com.xmonster.letsgo.R.style.umeng*",
            "com.xmonster.letsgo.R.id.umeng*"
    ]
shwenzhang commented 8 years ago

@developerzhu , if you use "my packagename.R.*", the AndResGuard won't work. you can just use repackage mode!

QgmzCheng commented 8 years ago

请问如果想保持res不混淆,在gradle里面要怎么设置?