I'm having trouble with building a debuggable apk. I'm using Android Studio 0.5.4/0.5.5 and Gradle 1.11 Gradle plugin 0.9.+ and somehow the debug apk doesn't show any logcat messages with the package name anymore. I tried many different things uninstall everything Android studio/AndroidSDK. and clean installing it again, also deleted all home folder .gradle .androidstudiopreview and nothing helped. When I created a new project in android studio and follow the wizard for creating an activity everything seems fine the app is debuggable and shows normal logging output in logcat. Also when I want to selected the process for debug, Android Studio can't find it as a debuggable process. Anyone know how to fix this or what is wrong in my build.gradle file
the output from log messages is like this now:
04-15 14:09:11.066 21202-21202/? D/Tag﹕ test tag and debug messages
04-15 14:09:11.066 21202-21202/? I/Tag﹕ test tag and info messages
04-15 14:09:11.066 21202-21202/? W/Tag﹕ test tag and warn messages
04-15 14:09:11.066 21202-21202/? E/Tag﹕ test tag and error messages
04-15 14:09:11.076 21202-21202/? D/Tag﹕ is debuggable: true
build.gradle:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'crashlytics'
def gitSha() {
return 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
}
def buildTime() {
return new Date().format("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"))
}
def isTravis = "true".equals(System.getenv("TRAVIS"))
def preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
android {
final GITSHA = "${gitSha()}";
final BUILD_TIME = "${buildTime()}";
final YOUTUBE_DEV_API = "AIzaSyD0kNRnV_Il6bYx5ekWUzPWNt9XDQIPxvg"
compileSdkVersion 19
buildToolsVersion '19.0.3'
dexOptions {
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
preDexLibraries = preDexEnabled && !isTravis
}
defaultConfig {
packageName "com.test"
minSdkVersion 9
targetSdkVersion 19
versionCode Integer.parseInt(VERSION_CODE)
versionName VERSION_NAME
buildConfigField "String", "GIT_SHA", "\"${GITSHA}\""
buildConfigField "String", "BUILD_TIME", "\"${BUILD_TIME}\""
testPackageName "com.whosampled.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
testFunctionalTest true
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
signingConfigs {
debug {
storeFile file("../test.keystore")
storePassword "#2U3aD+2ASwayEwa"
keyAlias "debug"
keyPassword "gu*W5cUkUM-&5bre"
}
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable false
jniDebugBuild false
zipAlign true
buildConfigField "String", "YOUTUBE_API", "\"${YOUTUBE_DEV_API}\""
}
debug {
signingConfig signingConfigs.debug
debuggable true
jniDebugBuild true
runProguard false
zipAlign false
packageNameSuffix ".debug"
versionNameSuffix "-" + GITSHA + "-debug"
buildConfigField "String", "YOUTUBE_API", "\"${YOUTUBE_DEV_API}\""
}
android.applicationVariants.all { variant ->
println "*********" + variant.getVariantData().getVariantConfiguration().getBuildType().isDebuggable() + "**********";
}
if (false) {
// change apk off build variant.
android.applicationVariants.all { variant ->
println "*********" + variant.description + "**********";
def variants = variant.baseName.split("-");
variant.buildType
def apkName = "whosampled-";
apkName += variants[0];
apkName += "-v" + android.defaultConfig.versionName;
apkName += "-" + GITSHA;
if (!variant.zipAlign) {
apkName += "-unaligned";
}
// if created by build server or something
if (false && variant.buildType.name == "release") {
apkName += "-RELEASE.apk";
} else if (false && variant.buildType.name == "debug") {
apkName += "-SNAPSHOT.apk";
} else {
apkName += ".apk";
}
println "*********" + "$project.buildDir/apk/" + apkName + "**********";
variant.outputFile = file("$project.buildDir/apk/" + apkName)
}
}
}
}
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/groups/public/' }
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.squareup.retrofit:retrofit:1.5.0'
compile 'com.squareup.picasso:picasso:2.2.0'
compile 'com.squareup.okhttp:okhttp:1.5.3'
compile 'com.pixplicity.easyprefs:library:1.0#aar'
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'se.emilsjolander:stickylistheaders:2.3.0'
compile 'com.squareup:otto:1.3.4'
compile 'com.pixplicity:font.text.utils.library:1.2#aar'
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile 'com.squareup:fest-android:1.0.+'
}
Related
I am trying to debug my error with Proguard. My project is working fine with debug but not with Proguard. Any help will be appreciated.
I have tried with ignore warning in Proguard. However application is crashing with generated APK.
Current Proguard settings is not working. Messages console I have uploaded to Gist
Build.gradle is given below
Prodguard-project.txt in gist
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
build.gradle
apply plugin: 'com.android.application'
apply from: rootProject.file('gradle/codequality.gradle')
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
versionCode 49
versionName "1.8.8"
minSdkVersion 14
targetSdkVersion 22
buildConfigField 'String', 'BUILD_TAG', '"' + getBuildTag() + '"'
buildConfigField 'String', 'OWM_API_KEY', '"' + getOpenWeatherMapApiKey() + '"'
buildConfigField 'boolean', 'ENABLE_WEATHER', 'true'
def buildSuffix = getBuildSuffix(versionName, versionCode)
applicationVariants.all { variant ->
def file = variant.outputs[0].outputFile
variant.outputs[0].outputFile = new File(file.parent, file.name.replace(".apk", "-" + buildSuffix + ".apk"))
}
}
if (project.hasProperty('signingKeyStoreFile')) {
signingConfigs {
release {
storeFile file(signingKeyStoreFile)
storePassword signingKeyStorePassword
keyAlias signingKeyAlias
keyPassword signingKeyPassword
}
}
}
buildTypes {
release {
minifyEnabled true
proguardFile 'proguard-project.txt'
if (project.hasProperty('signingKeyStoreFile')) {
signingConfig signingConfigs.release
}
}
}
lintOptions {
abortOnError false
checkReleaseBuilds false
disable 'MissingTranslation'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
def getBuildSuffix(versionName, versionCode) {
def suffix = versionName + '-' + versionCode
if (System.getenv()['BUILD_NUMBER'] != null) {
suffix += '-b' + System.getenv()['BUILD_NUMBER']
}
return suffix
}
def getBuildTag() {
def tag = ''
if (System.getenv()['BUILD_NUMBER'] != null) {
tag += 'b' + System.getenv()['BUILD_NUMBER']
} else {
tag += 'l'
}
tag += '#' + new Date().format('yyyyMMdd')
return tag
}
def getOpenWeatherMapApiKey() {
if (project.hasProperty('owmApiKey')) {
return owmApiKey
} else {
def apiKeyFile = file('default_owm_api_key');
if (apiKeyFile.isFile()) {
return apiKeyFile.text.trim()
}
}
return 'NOKEY'
}
///////////////////////////////////////////////////
// Dependencies
repositories {
mavenCentral()
}
dependencies {
//compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
//compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'net.danlew:android.joda:2.9.4.1'
compile 'com.google.android.gms:play-services-ads:9.8.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
}
configurations {
all*.exclude group: 'com.google.firebase', module: 'firebase-core'
all*.exclude group: 'com.google.firebase', module: 'firebase-iid'
}
///////////////////////////////////////////////////
// Checkstyle
task checkstyleDebug(type: Checkstyle, dependsOn: 'compileDebugSources') {
source = fileTree('src/main/java/')
classpath = files('build/intermediates/classes/debug')
}
check.dependsOn checkstyleDebug
///////////////////////////////////////////////////
// Findbugs
task findbugsDebug(type: FindBugs, dependsOn: 'compileDebugSources') {
source = fileTree('src/main/java/')
classes = fileTree('build/intermediates/classes/debug')
classpath = files() // empty classpath!
effort = 'max'
excludeFilter = rootProject.file('config/findbugs/androidExcludeFilter.xml')
}
check.dependsOn findbugsDebug
///////////////////////////////////////////////////
// PMD
task pmd(type: Pmd) {
source = fileTree('src/main/java/')
ruleSets = ['java-basic', 'java-braces', 'java-android']
}
check.dependsOn 'pmd'
Try to add getDefaultProguardFile('proguard-android.txt') to the proguardFile 'proguard-project.txt', to get next row:
proguardFile getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
Or start to search the issues from your proguard-project.txt, like:
Add rule -keepattributes SourceFile,LineNumberTable,InnerClasses,Signature,Exceptions
Add rule -dontwarn com.google.**
And so on, by your proguard failed logs
The res/raw and res/xml resources are not included to aar files, the raw folder contains keep.xml and the xml folder contains backup_rules.xml. None of them are included in aar files, the raw and xml folder is empty in extracted aar file.
How should I include them into aar output?
Update 1, add gradle project and library gradle files.
Project gradle file
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.google.gms:google-services:4.0.1'
}
}
def versionMajor = 4
def versionMinor = 0
def versionPatch = 1
def versionBuild = 0
allprojects {
repositories {
jcenter()
google()
}
project.version = "${versionMajor}.${versionMinor}.${versionPatch}"
}
ext {
configCompileMinSdkVersion = 14
configCompileSdkVersion = 28
configTargetSdkVersion = 28
configVersionCode = versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Library gradle file
apply plugin: 'com.android.library'
android {
lintOptions {
abortOnError false
}
compileSdkVersion configCompileSdkVersion
defaultConfig {
defaultPublishConfig 'release'
publishNonDefault true
minSdkVersion configCompileMinSdkVersion
targetSdkVersion configTargetSdkVersion
versionCode configVersionCode
versionName project.version
consumerProguardFiles 'proguard-rules.pro'
project.archivesBaseName = "my_sdk"
project.version = android.defaultConfig.versionName
}
buildTypes {
debug {
debuggable true
versionNameSuffix '-debug'
buildConfigField("String", "SDK_TYPE", "\"android\"" )
}
release {
versionNameSuffix 'release'
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
buildConfigField("String", "SDK_TYPE", "\"android\"" )
}
unity {
versionNameSuffix 'unity'
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
buildConfigField("String", "SDK_TYPE", "\"unity\"" )
}
}
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def f = outputFile.name.replace(".aar", "")
if(f != null && f.contains("release")) {
f = f.replace("-release", "")
}
def fileName = "${f}-${version}.aar"
fileName = fileName.replace("_", "-")
output.outputFileName = new File("release", fileName)
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation "com.google.android.gms:play-services-gcm:16.0.0"
implementation 'android.arch.work:work-runtime:1.0.0-alpha08'
}
Update 2, add project structure.
I want to create smth like this in my project, but i'm new to gradle, so i don't know a lot of things it can do.
Here is project structure in explorer
gradle.build from app module
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7'
}
}
// Manifest version information!
def versionMajor = 1
def versionMinor = 0
def versionPatch = 0
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def date = new Date()
def buildTime = date.format("dd.MM.yy", TimeZone.getTimeZone("UTC"))
def buildTimeInternal = date.format("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"))
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
buildConfigField "String", "GIT_SHA", "\"${gitSha}\""
buildConfigField "String", "BUILD_TIME", "\"${buildTimeInternal}\""
testApplicationId "ru.ltst.u2020mvp.tests"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
debug {
storeFile file("../distribution/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
release {
storeFile file("../distribution/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
debug {
applicationIdSuffix '.dev'
versionNameSuffix '-dev'
debuggable true
signingConfig signingConfigs.debug
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-project.txt')
signingConfig signingConfigs.release
}
}
productFlavors {
internal {
applicationId 'ru.ltst.u2020mvp.internal'
}
production {
applicationId 'ru.ltst.u2020mvp'
}
}
lintOptions {
textReport true
textOutput 'stdout'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
// TODO remove eventually: http://b.android.com/162285
configurations {
internalDebugCompile
}
dependencies {
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:support-annotations:23.0.1'
compile "com.android.support:appcompat-v7:23.0.1"
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.google.dagger:dagger:2.0.1'
apt 'com.google.dagger:dagger-compiler:2.0'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
internalDebugCompile 'com.squareup.retrofit:retrofit-mock:1.9.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.jakewharton.timber:timber:2.7.1'
internalDebugCompile 'com.jakewharton.madge:madge:1.1.1'
internalDebugCompile 'com.jakewharton.scalpel:scalpel:1.1.1'
compile 'io.reactivex:rxjava:1.0.8'
compile 'io.reactivex:rxandroid:0.24.0'
internalCompile 'com.mattprecious.telescope:telescope:1.4.0#aar'
// Espresso 2 Dependencies
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.0') {
exclude module: 'support-annotations'
}
}
// change apk name
android.applicationVariants.all { variant ->
for (output in variant.outputs) {
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = "u2020-mvp-${output.name}-${buildTime}.apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
// print build finish time
gradle.buildFinished { buildResult ->
def buildFinishDate = new Date()
def formattedDate = buildFinishDate.format('yyyy-MM-dd HH:mm:ss')
println "Build finished: ${formattedDate}"
}
Can someone explain to me how it works?
When i change build Variant the java content is changed. (e.g it was main, internal,internalDebug for internalDebug variant and then it became main,internal,internalRelease for internalRelease build variants).
The reason I'm asking is that i don't see any "internalRelease" word in gradle file, so i don't understand the logic of how the build variants were created and how it defines what modules to show for different build variants
debug for test without signature and release for publish with signature;click the left-top robot ,and turn android to project , u will understand;
Error:(83, 0) Could not find property 'ANDROID_BUILD_SDK_VERSION' on com.android.build.gradle.LibraryExtension_Decorated#103ce86.
What am I missing? I cannot seem to resolve this issue.
**My Build.Gradle **
buildscript {
repositories {
mavenCentral()
mavenLocal()
maven {
name 'maven.aviary.com'
url uri("http://maven.aviary.com/repo/release")
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), \
'proguard-rules.txt'
}
}
}
allprojects {
repositories {
mavenCentral()
}
}
build.gradle that I am directed to when receiving error
apply plugin: 'android-library'
version aviarySdkVersionName + '.' + aviarySdkVersionCode
repositories {
mavenCentral()
mavenLocal()
maven {
name 'maven.aviary.com'
url uri("http://maven.aviary.com/repo/release")
}
}
ext {
aviarySdkFlavor = "Production"
aviarySdkBuildType = "Release"
aviarySdkVersionCode = "0"
aviarySdkVersionName = "0.0.0"
aviarySdkPackageName = ""
}
task checkVersion << {
if (!VERSION_NAME.equals(aviarySdkVersionName)) {
println "$VERSION_NAME != $aviarySdkVersionName";
throw new InvalidUserDataException("declared field VERSION_NAME must be eq to aviarySdkVersionName");
}
if (!GROUP.equals(aviarySdkPackageName)) {
println "$GROUP != $aviarySdkPackageName";
throw new InvalidUserDataException("field GROUP must be eq to aviarySdkPackageName");
}
}
preBuild.dependsOn(checkVersion)
def all_tasks = gradle.startParameter.getTaskNames()
gradle.startParameter.getTaskNames().each { task ->
println "current task: $task"
for( single_task in all_tasks ) {
if(all_tasks.size() == 1){
println "single_task: $single_task"
if (single_task.contains("Alpha")) {
aviarySdkFlavor = "Alpha"
} else if(single_task.contains("Beta")) {
aviarySdkFlavor = "Beta"
} else if(single_task.contains("Amazon")){
aviarySdkFlavor = "Amazon"
} else {
aviarySdkFlavor = "Production"
}
if(single_task.contains("Debug")){
aviarySdkBuildType = "Debug"
} else {
aviarySdkBuildType = "Release"
}
}
}
Properties props = new Properties()
props.load(new FileInputStream("${rootProject.projectDir}/Aviary-SDK/gradle.properties"))
aviarySdkPackageName = props.aviarySdkPackageName
aviarySdkVersionName = props.aviarySdkVersionName
aviarySdkVersionCode = props.aviarySdkVersionCode
println "****************************************************"
println "* CONFIGURATION"
println "* TASK: $task"
println "* SDK_FLAVOR: $aviarySdkFlavor"
println "* SDK_BUILD TYPE: $aviarySdkBuildType"
println "* aviarySdkPackageName: $aviarySdkPackageName"
println "* aviarySdkVersionName: $aviarySdkVersionName"
println "* aviarySdkVersionCode: $aviarySdkVersionCode"
println "*"
println "****************************************************"
}
android {
compileSdkVersion Integer.parseInt(ANDROID_BUILD_SDK_VERSION)
buildToolsVersion ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(ANDROID_BUILD_TARGET_SDK_VERSION)
versionCode Integer.parseInt(aviarySdkVersionCode)
versionName VERSION_NAME
applicationId aviarySdkPackageName
buildConfigField "String", "SDK_PACKAGE_NAME", "\"${aviarySdkPackageName}\""
buildConfigField "String", "SDK_VERSION_NAME", "\"${aviarySdkVersionName}\""
buildConfigField "int", "SDK_VERSION_CODE", "${aviarySdkVersionCode}"
buildConfigField "String", "SDK_FLAVOR", "\"${aviarySdkFlavor.toLowerCase()}\""
buildConfigField "String", "SDK_BUILD_TYPE", "\"${aviarySdkBuildType.toLowerCase()}\""
buildConfigField "boolean", "SDK_DEBUG", "${aviarySdkBuildType.toLowerCase().contains('debug')}"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
}
}
dependencies {
println "(sdk) finalFlavor: $aviarySdkFlavor - $aviarySdkBuildType"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.aviary.android.feather.sdk:sdk-library:+'
}
I had the same problem.
What resolved my problem was to define these keys in gradle.properties in the root.
ANDROID_BUILD_TARGET_SDK_VERSION=19
ANDROID_BUILD_TOOLS_VERSION=19.1.0
ANDROID_BUILD_SDK_VERSION=19
ANDROID_BUILD_MIN_SDK_VERSION=10
So Im trying to use a custom build file that generates an unsigned apk then runs a task on it and then zipaligns it. I havent gotten that working yet. However I do have it creating and properly signing the apk but when I try to just push the play button to run it in debug on a device using my custom debug set up studio/gradle generates my apk and places it in the directory I want but it fails to push it on to the device because it uses a file path that doesnt exist.
I/O Error: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Android Studio\apk\V2.5-10-debug-20140922-2335.apk (The system cannot find the path specified). Is this hard coded into the studio build because I cant find a setting to change it. Its really making the whole process a real pain lol. Infact that path doesnt exist anywhere on my machine.
EDIT heres my build.gradle file
import java.text.SimpleDateFormat
import java.util.regex.Pattern
apply plugin: 'com.android.application'
def buildTime() {
def df = new SimpleDateFormat("yyyyMMdd'-'HHmm")
df.setTimeZone(TimeZone.getDefault())
return df.format(new Date())
}
def apkName = "MyApp"
def apkLocation
task (runApkSigTool , dependsOn: android, type: JavaExec) {
classpath files('apksigtool.jar')
main 'com.widevine.tools.android.apksigtool.ApkSigTool'
args[0] = apkLocation
args[1] = 'private_key.der'
args[2] = 'my.crt'
System.out.println(apkLocation);
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
signingConfigs{
debug{
storeFile file("debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
release{
storeFile file("debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
debug{
}
release {
signingConfig signingConfigs.release
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
assembleDebug.doLast{
runApkSigTool.execute()
}
zipAlign true
}
debug{
signingConfig signingConfigs.debug
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
assembleDebug.doLast{
runApkSigTool.execute()
}
zipAlign false
}
android.applicationVariants.all { variant ->
def manifestFile = file("C:\\path\\app\\src\\main\\AndroidManifest.xml")
def pattern = Pattern.compile("versionName=\"(.+)\"")
def manifestText = manifestFile.getText()
def matcher = pattern.matcher(manifestText)
matcher.find()
def versionName = matcher.group(1)
pattern = Pattern.compile("versionCode=\"(.+)\"")
matcher = pattern.matcher(manifestText)
matcher.find()
def versionCode = matcher.group(1)
if (variant.zipAlign) {
variant.outputFile = new File("apk/"+apkName+"-V"+versionName+"-"+versionCode+"-"+variant.name+"-"+buildTime()+"-unaligned.apk");
variant.zipAlign.inputFile = variant.outputFile
variant.zipAlign.outputFile = new File("apk/"+apkName+"-V"+versionName+"-"+versionCode+"-"+variant.name+"-"+buildTime()+".apk");
} else {
apkLocation = "apk/"+apkName+"-V"+versionName+"-"+versionCode+"-"+variant.name+"-"+buildTime()+".apk";
variant.outputFile = new File("apk/"+apkName+"-V"+versionName+"-"+versionCode+"-"+variant.name+"-"+buildTime()+".apk");
System.out.println("CREATED UNSIGNED APK---------------")
}
}
}
lintOptions {
abortOnError false
ignoreWarnings true
checkAllWarnings false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:mediarouter-v7:20.0.0'
compile 'com.google.android.gms:play-services:5.0.89'
}
installDebug is calling buildTime() too when preparing the adb push command so the dates would mismatch with every minute.