I keep on failing to upload the signed APK file generated from Android Studio, even though I have tried many different solutions to solve it.
This is what I get when uploading:
I have also seen some solutions to write zipalign commands, but I always get the "command not found" message when entering the command in my mac's terminal.
And this is my configuration in the build.gradle (Module: app) file inside the project:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.name.product"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
}
repositories {
flatDir {
dirs 'libs'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.squareup.okhttp3:okhttp:3.0.1'
compile(name:'material-search', ext:'aar')
}
I found this solution and it solved my problem:
https://stackoverflow.com/a/37842438/4846301
It was all about changing 1 line in the build.gradle file to this:
'com.android.tools.build:gradle:2.1.2'
Related
Can Anyone explain me what is Version Tag for git in this, I am getting error while importing this.
apply plugin: 'com.android.application'
buildscript {
repositories {
maven { url 'https:example.com' }
jcenter()
mavenCentral()
mavenLocal()
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.jatinder.bdugame"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'org.bitbucket.5elements:SmartTones-SDK:VERSION_TAG'
}
Error:
Error:(45, 13) Failed to resolve: org.bitbucket.5elements:SmartTones-SDK:VERSION_TAG
Show in File<br>Show in Project Structure dialog
What does you question have to do with Git or Maven?
It does not even have anything to do with Android, besides coming from an Android project.
You declared the compile time dependency org.bitbucket.5elements:SmartTones-SDK:VERSION_TAG which means group org.bitbucket.5elements, artifact SmartTones-SDK, version VERSION_TAG. This combination is not found in any of your declared repositories, so it fails to be resolved, just as the error tells you.
i tring to run my app but the gradle give me this error
:app:transformClassesWithJarMergingForDebug FAILED Error:Execution
failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/inject/Inject.class
Information:BUILD FAILED
this my AndroidMainifist.xml
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.example.mohamed.movieapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'org.glassfish.jersey.core:jersey-client:2.22.1'
compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.22.1'
}
repositories {
maven { url 'java.lang.android.support.v7.app.WindowDecoreActionBar' }
}
can any one help please
The duplication comes from jersey client. It depends on both org.glassfish.hk2.external:javax.inject and javax.inject:javax.inject.
So, you need to exclude one of them:
dependencies {
...
compile ('org.glassfish.jersey.core:jersey-client:2.22.1') {
exclude group: 'javax.inject', module: 'javax.inject'
}
...
}
I try to use org.glassfish.jersey.media:jersey-media-moxy in my project and had to apply the same exclusion for that dependency too - likely it will be the same for org.glassfish.jersey.media:jersey-media-json-jackson.
Ok, here is my current build.gradle:
apply plugin: 'com.android.application'
apply from: '../config.gradle'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId ""
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
resValue "int", "amountOfTables", amountOfTables
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
howManyTables.execute()
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.pnikosis:materialish-progress:1.4'
}
and that's the config.gradle:
def amountOfTables = 15
task howManyTables << {
println amountOfTables
}
The question is:
Why can I get access to howManyTables task from config.gradle. But can't get access to defined variable? I want to create custom config.gradle with predefined values. And then use them as variables in my Android app. (like baseURL, type of data, etc...). And them, depending of that data build my logic. Anyway, the question is clear i hope ;) Any ideas?
Because You defined the variable with def - so it's local in the script itself. Try:
config.gradle
project.ext.amountOfTables = 15
build.gradle
apply from: 'config.gradle' //correct path should be here
println project.amountOfTables
Android Studio 1.0.2 with gradle 1.0.0 on Mac
when I start a new project,gradle project sync failed with errors:
Error:(2, 0) Gradle DSL method not found: 'compile()'
Possible causes:<ul><li>The project 'My Application' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
build.gradle under project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
build.gradle under app
dependencies {
compile 'com.android.support:appcompat-v7:21.+'
}
apply plugin: 'com.android.application' android {
compileSdkVersion 21 buildToolsVersion "21.1.1" defaultConfig {
applicationId "com.macernow.djstava.myapplication" minSdkVersion 14 targetSdkVersion 21 versionCode 1 versionName "1.0"
} buildTypes {
release {
minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
} dependencies {
compile 'com.android.support:appcompat-v7:21.+' compile fileTree(dir: 'libs', include: ['*.jar'])
}
And I also try online/offline gradle settings,the error remains.Please help me,thanks.
Uninstall Android Studio cleanly by
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm ~/Library/Preferences/com.google.android.studio.plist
rm -Rf ~/Library/Application Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
And then reinstall it,everything is OK.
I have an error when I want to add Robospice library; this is my build.gradle file:
apply plugin: 'android'
android {
// Check on it to know witch Android API level is necessary:
// http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile "com.android.support:support-v4:18.0.+"
compile "com.android.support:appcompat-v7:18.0.+"
compile "com.octo.android.robospice:robospice:1.4.11"
}
But unfortunately, Gradle gives me this error:
duplicate files during packaging of APK D:\blablabla\build\apk\mtc-debug-unaligned.apk
Execution failed for task ':mtc:packageDebug'.
Duplicate files copied in APK META-INF/LICENSE.txt
File 1: C:\Users\Anthony.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-lang3\3.2.1\66f13681add50ca9e4546ffabafaaac7645db3cf\commons-lang3-3.2.1.jar
File 2: C:\Users\Anthony.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-lang3\3.2.1\66f13681add50ca9e4546ffabafaaac7645db3cf\commons-lang3-3.2.1.jar
Thanks for your help !
Anthony
uses this code to solve your problem:
android{
packagingOptions {
exclude 'META-INF/LICENSE'
}
}
but if the problem remains, you must look for the file you need ignorie during generation of apk.and add to packagingOptions like in the code above