4

问题是,我在使用Allatori生成签名 APK时出错。我尝试了不同的技巧,例如,通过删除构建文件夹,重建项目,甚至尝试比较包名称,类命名约定,或者但它没有用。! 也启用了。!我尝试了所有可能的解决方案,但无法生成. Java ObfuscatorInvalidate and Clear cache /RestartStringspossible jarsdeprecated methodsclassesMulti Dexsigned APK

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


ext {
    supportVersion = "25.3.1"
    googleServices = "11.4.2"
}

android {

    def version = "2.0.0"
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "removed"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 20
        versionName "${version}"
        multiDexEnabled true


        def today = new Date().format('yyyyMMdd_HHmmss').toString()
        project.ext.set("archivesBaseName", "MyApplication_Android_Build_"+ today + "_Version " + version);

    }



   
    applicationVariants.all { variant ->
        variant.javaCompile.doLast {
            runAllatori(variant)
        }
    }

    buildTypes {
        debug {
            buildConfigField "boolean", "LOG_ENABLED", "true"
            buildConfigField "boolean", "SSL_ENABLED", "true"
        
            buildConfigField "String", "SERVER_URL", "\"http:///\""
        }
        release {
            buildConfigField "String", "SERVER_URL", "\"http://\""
            buildConfigField "boolean", "LOG_ENABLED", "false"
            buildConfigField "boolean", "SSL_ENABLED", "true"
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        abortOnError false
    }

}

android {
    aaptOptions {
        cruncherEnabled = false
    }
}

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }

        maven { url "https://ensighten-mobile.bintray.com/maven" }
        mavenCentral()
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.22.1'
        classpath "com.ensighten.plugin.android:ensighten:2.0.1"
    }
}

apply plugin: 'io.fabric'

repositories {
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }
    maven { url "http://dl.bintray.com/vividadmin/maven" }
    maven { url "https://ensighten-mobile.bintray.com/maven" }
    mavenCentral()
    google()
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':williamchart')
    compile "com.android.support:appcompat-v7:${project.ext.supportVersion}"
    compile "com.android.support:design:${project.ext.supportVersion}"
    compile "com.android.support:percent:${project.ext.supportVersion}"
    compile "com.android.support:cardview-v7:${project.ext.supportVersion}"
    compile "com.android.support:recyclerview-v7:${project.ext.supportVersion}"
    compile "com.android.support:animated-vector-drawable:${project.ext.supportVersion}"
    compile "com.android.support:gridlayout-v7:${project.ext.supportVersion}"


    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }

    compile "com.google.firebase:firebase-crash:${project.ext.googleServices}"
    compile "com.google.firebase:firebase-core:${project.ext.googleServices}"
    compile "com.google.firebase:firebase-invites:${project.ext.googleServices}"
    compile "com.google.firebase:firebase-messaging:${project.ext.googleServices}"
    compile "com.google.android.gms:play-services-analytics:${project.ext.googleServices}"



    compile 'com.android.support:multidex:1.0.2'
    compile 'com.android.volley:volley:1.0.0'
    compile 'net.danlew:android.joda:2.9.2'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.scottyab:aescrypt:0.0.1'
    compile 'net.cachapa.expandablelayout:expandablelayout:2.9.1'
    compile 'com.facebook.android:facebook-android-sdk:4.23.0'
    compile 'com.ensighten.android:ensighten-core:2.4.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.code.gson:gson:2.8.1'
    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

def runAllatori(variant) {
    copy {
        from "$projectDir/allatori.xml"
        into "$buildDir/intermediates/classes/"
        expand(classesRoot: variant.javaCompile.destinationDir,
                androidJar: "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar",
                classpathJars: variant.javaCompile.classpath.getAsPath(),
                logFile: "allatori-log-${variant.name}.xml")
        rename('allatori.xml', "allatori-${variant.name}.xml")
    }

    new File("${variant.javaCompile.destinationDir}-obfuscated").deleteDir()
    javaexec {
        main = 'com.allatori.Obfuscate'
        classpath = files("$rootDir/allatori/allatori.jar")
        args "$buildDir/intermediates/classes/allatori-${variant.name}.xml"
    }
    new File("${variant.javaCompile.destinationDir}").deleteDir()
    new File("${variant.javaCompile.destinationDir}-obfuscated").renameTo(new File("${variant.javaCompile.destinationDir}"))
}

错误:

错误:将字节码转换为 dex 时出错:原因:解析错误:类名 (com/pckg/pakistan/myapplication/R) 与路径 (com/pckg/pakistan/myapplication/r.class) 不匹配 ...同时解析 com/ pckg/巴基斯坦/myapplication/r.class

错误:任务“:app:transformClassesWithDexForRelease”执行失败。com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: dex 进程返回代码 1

4

2 回答 2

0

据我所知,由于 Allatori 混淆,您正在使用大量库并使用 Allatori Java Obfuscator,您的 Java 代码没有被正确转换为字节码,这就是您无法生成签名 apk 的原因。尝试快速 hack 删除构建文件、gradle 文件并多次使您的项目无效并重新启动

希望这可以帮助你:)

于 2019-04-01T09:24:45.290 回答
-1

您添加的 Gradle 中没有签名配置,因此首先创建一个密钥库(https://developer.android.com/studio/publish/app-signing.html

然后在应用级 Gradle 中添加

signingConfigs {
    release {
        // For making app store release config below parameters
        storeFile file('path to keystore')
        storePassword "keystore password"
        keyAlias "Alias_of_keystore"         
        keyPassword "Keystore Password"   
    }
}

之后在构建类型中添加

 buildTypes {
    // For  app store release uncomment below and select release build flavor in Build Variants
    release {
...
signingConfig signingConfigs.release
}}
于 2018-04-24T08:10:45.643 回答