[英]Android studio does not Generate Signed APK
The Problem is that , I'm getting error while generating Signed APK using Allatori Java
Obfuscator
.问题是,我在使用Allatori Java
Obfuscator
生成签名 APK 时遇到错误。 I tried different hacks like, Invalidate and Clear cache /Restart
,by deleting build folder, rebuilding project, Strings
, Even tried comparing package names ,Class Naming conventions, possible jars
, deprecated
methods
or classes
but Its of no use.!我尝试了不同的技巧,例如Invalidate and Clear cache /Restart
,通过删除构建文件夹,重建项目, Strings
,甚至尝试比较包名称,类命名约定, possible jars
, deprecated
methods
或classes
但它没有用。! Multi Dex
is enabled as well.! Multi Dex
已启用。! and I tried every possible Solution but unable to generate signed APK
.我尝试了所有可能的解决方案,但无法生成signed 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}"))
}
Error:错误:
Error:Error converting bytecode to dex: Cause: PARSE ERROR: class name (com/pckg/pakistan/myapplication/R) does not match path (com/pckg/pakistan/myapplication/r.class) ...while parsing com/pckg/pakistan/myapplication/r.class错误:将字节码转换为 dex 时出错:原因:解析错误:类名 (com/pckg/pakistan/myapplication/R) 与路径 (com/pckg/pakistan/myapplication/r.class) 不匹配 ...同时解析 com/ pckg/巴基斯坦/myapplication/r.class
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.错误:任务 ':app:transformClassesWithDexForRelease' 执行失败。 com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: dex 进程返回代码 1
As per my knowledge you are using lot of libraries and using Allatori Java Obfuscator due to Allatori obfuscation your java code is not being properly converted into byte code and thats the reason you are unable to generate signed apk.据我所知,由于 Allatori 混淆,您正在使用大量库并使用 Allatori Java Obfuscator,您的 Java 代码没有正确转换为字节码,这就是您无法生成签名 apk 的原因。 Try a quick hack delete build files ,gradle files and invalidate and restart your project more than once尝试快速 hack 删除构建文件、gradle 文件并多次使您的项目无效并重新启动
Hope this may help u :)希望这可以帮助你 :)
There is no Signing config in Gradle you have added, So first Create a Keystore ( https://developer.android.com/studio/publish/app-signing.html )您添加的 Gradle 中没有签名配置,因此首先创建一个密钥库( https://developer.android.com/studio/publish/app-signing.html )
and then add in the app level Gradle然后在应用级 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"
}
}
after that in build types add之后在构建类型中添加
buildTypes {
// For app store release uncomment below and select release build flavor in Build Variants
release {
...
signingConfig signingConfigs.release
}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.