I have a strange problem that just started with an existing Android Studio 2.3.3 project.
The build process is not automatically generating an APK, in this case app-debug.apk Log shows build is successful, but no APK anywhere in the project directory tree. Manually selecting Build / Build APK works fine, however.
This is a problem when I change the source and click run. The build process is successful, but then get "Error Installing APK" into the emulator (because the APK does not exist).
This problem only happens on the one project, and I was playing around with Espresso earlier. My guess is I changed a setting somewhere, I just cannot figure out which one. What do I need to change to have the APK generated automatically again? build.gradle included.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 16
targetSdkVersion 25
versionCode 2
versionName "0.0.2"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
storeFile file("/home/user/keystore/keystore.jks")
storePassword "xxxxxxxxxxxxxxxxxx"
keyAlias "xxxxxxxxxxxxxxxxx"
keyPassword "xxxxxxxxxxxxxxxxxxx"
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-ads:10.2.4'
compile 'com.google.android.gms:play-services-location:10.2.4'
testCompile 'junit:junit:4.12'
}
Try below solution -
At right side of Android studio you have a gradle option click on that and then click the refresh icon and then check build.
More details follow below link -
apk not generating
My Android Studio does it all the time so I came up with a workaround. Instead of going to Build > Build APK. I simply run the app.
After running the app if you go to build > output > apk in your project directory, you will find your APK over there. Android Studio rarely throws an error when you run the app.
EDIT
This APK does NOT work on physical devices I dont know what the reason is. It runs on emulators though.
Something is not right with the key, maybe it is not on the path... A studio does not report anything then (simply does not build bundle). Click on the folder icon in the key alias field it will be an error if the key is not on the path (fastest check).
Due to many dependencies in Build.gradle android studio takes too much time and then said Request time out. So have a look into Build.gradle.
Do these steps.
First Method: try to minimize the dependencies
Second Method: Add MultiDEX implementation 'androidx.multidex:multidex:2.0.1' this is for androidX.
Third Method: Make class public class ApplicationDelegate extends MultiDexApplication { } then add in Android Manifest File like this in Application tag
<application
android:name=".ApplicationDelegate"
android:allowBackup="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
Related
I used to generate a signed apk from Android Studio and everything was working well until I updated Android Studio to 3.3. It generates an apk but after I try to install it, it says: App Not Installed!
My Trial was by:
Click on build
Generate Signed Apk
Choose APK and click Next
Insert the Key Store Path, Key Store Password, Key Alias, Key Password
Click Next
Choose Release Variant
Click Finish
The Apk is generated but it's not signed! What is the problem ?
Here is my app build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 27
defaultConfig {
applicationId "com.twobreathe.soft2breathe"
minSdkVersion 23
targetSdkVersion 27
versionCode 9
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
vectorDrawables {
useSupportLibrary true
}
resConfigs "en", "ja"
}
signingConfigs {
release {
keyAlias "[my key alias]"
keyPassword "[my key password]"
storeFile file("[path to the keystore file]")
storePassword "[my store password]"
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources true
pseudoLocalesEnabled false
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable true
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/fluidsynth/android/CMakeLists.txt"
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
dataBinding {
enabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '28.0.3'
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.github.parse-community.Parse-SDK-Android:parse:1.18.4'
implementation 'com.jjoe64:graphview:4.2.2'
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.orhanobut:hawk:2.0.1'
implementation 'xyz.sahildave:arclayout:1.0.0'
implementation 'com.mikhaellopez:circularprogressbar:2.0.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
implementation 'com.github.GrenderG:Toasty:1.3.0'
implementation 'com.kyleduo.switchbutton:library:2.0.0'
implementation 'com.github.franmontiel:LocaleChanger:0.9.2'
implementation 'cn.aigestudio.wheelpicker:WheelPicker:1.1.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.8'
}
After updating to 3.3, many problems are occuring related to signing an APK. Sometime it doesn't sign the apk and sometime it says the key is not private.
Well i also faced this problem after upgrading to android studio 3.3 and i resolved in 3 steps. But firstly make sure you backup your whole project.
In Android Studio goto File > Project Structure and untick from "use embedded JDK" then click OK
Goto Computer Settings (system settings) (win + pause key) then go to Advanced system settings>Environment variables. if JAVA_HOME not present then add it and set path to your installed JDK.
As i couldn't find a direct approach to modify jdk path in my project that is upgraded in some way to android studio 3.3 settings, i did following(for the last step) BUT MAKE SURE YOU MAKE BACKUP BEFORE THIS.
To make sure where i am guiding come to project view, I deleted ".grade", ".idea", "capture", "gradle" folders from the root and "build", "release", "lib" folder from "app" leaving "src" as it is. Deleted root.iml and did not delete app.iml file Then rebuild the project and then created the Signed package.
It went successful after 2 try. To be very honest i did the last step twice by restoring files from backup. As deleting these folders i messed up 1 time.
Not strictly related, but I ended up in this questions when searching for a fix to my problem.
In my case I forgot to remove 'debuggable true' for one of my non-debug built-types. When I was generating the bundle the google play store wouldn't complain about it just said that it wasn't signed. But when I tried uploading an apk it showed the true error.
From your Gradle its visible that you have not configured your Signing Config with it.
Please check image below:
Step 1:
Go to your project settings > select your module (Let's say "app") > go to signing > enter proper information and keystore.jks file
Step 2:
Go to Build Types > select Release type > assign signing config as you created on step 1. > after that your gradle will have config as there in image.
Step 3:
Try generating signed APK.
It will be success!!!
Happy Coding..
Double check both of the values on the final dialog, labelled by "Signature Versions".
For more information please check the following link:
https://developer.android.com/about/versions/nougat/android-7.0#apk_signature_v2
Anyway this question seems duplicate as the following:
android studio: release apk is not signed
friend
when you go for build the signed apk
now in android studio 3.3 , you will 2 option for build the signed apk.
1. Android App Bundle
2.APK
i will suggest to use option 2
select option 2 and Click on Next button now studio ask for your password details
now fill all details and
select Remember password checkbox for feature and now next .
now again studio ask for debug and release build confirmation
now here select release and select 2 checkbox at bottom and then continue
hope your signed apk will be generate .
When generating an APK, make sure both the signature types are checked, otherwise Fabric (and other places) may not recognise it as signed.
Additionally you probably want to remove debuggable true from your release config, as debuggable builds can't be uploaded to Google Play. There's a chance this is also causing an issue.
Try to sign it using command-line tools. I may help you to identify the problem.
(https://developer.android.com/studio/build/building-cmdline).
In my case, it was JAVA_HOME problem (as in #Vanshaj Daga answer).
I Have started my new android project with Basic Default Activity.IT run fine in emulator .I Have tried to install iy in real device both pre lolipop and abovr lolipop device but getting error
App cannot be installed error in prelolipop device and above lolipop device app will install but when i try to open app it will close
Can any one help how to fix this issue ?
Build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.myapp.myapplication"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
Your code is fine, my guess is that your APK is not completely built
Build your APK:
On Android Studio click on Build
Then click on Build APK(s)
After that search for your debug APK and install it on your device
If this fails you can try ADB, take a look at the following guides for install and usage:
How to install it on windows
How to Install apk using ADB
Hope it helps
Two things could be the problem.
Navigate to settings > security and make sure Unknown sources is checked.
Make sure you downloaded the whole apk in the email
Hope this helps!
So, the title pretty much sums up my problem. Anyone know how to fix it? Last time I build apk, it work fine on AS 2.X, but, I'm now developing with Kotlin so, I have to use AS 3.0.
I use AS 3.0 Canary 7 (This project is a fresh project)
This is my dummy class in my library (Stored in "domain".library.mylibrary)
class Test {
fun hello(): String {
return "hello"
}
}
And this is my (mylibrary) gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
testImplementation 'junit:junit:4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" //Declared in project level gradle: ext.kotlin_version = '1.1.3-2'
}
My gradlew.bat clean build --info log: https://pastebin.com/bfTZ5s4e
Android Studio does not generate a jar by default, but rather an AAR file. If you want to get a jar output, you need to implement apply plugin: 'maven-publish' on top of your mylibrary/gradle.build file and read the following document: Chapter 36. Maven Publishing (new)
Another note, is that I would suggest you not to use ProGuard directly on your release artifact, but rather provide a consumer ProGuard file and let the users of your library to handle that task, otherwise they will have a hard time referencing obfuscated code. Read my answer on this here
While the build task may generate an output, it is known that the assemble task (or assembleRelease) is the one that will generate your aar output.
Try running the following command:
./gradlew clean assembleRelease
and check the output in /mylibrary/build/outputs/apk/release/ if I am not mistaken.
Whether I create the "release" APK by:
Using Generate Signed APK in Android Studio
Select the Release build variant and use Tools -> Build APK
Run the assembleRelease task
... the APK produced always has debuggable=true which I've confirmed by trying to upload them to Google Play, which says:
"Upload failed. You uploaded a debuggable APK. For security reasons you need to disable debugging before it can be published in Google Play."
The (only) manifest has no debuggable attribute specified. Gradle specifies debuggable=false for release, and true for debug, see below.
What am I missing? Where is the debuggable state coming from, and why is the debuggable=false in the release build type declaration being ignored? I do not want to add debuggable=false to the manifest and to have to keep manually enabling/disabling it.
app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
applicationId "com.myapp.android"
minSdkVersion 14
targetSdkVersion 26
versionCode 5
versionName 5
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
storeFile rootProject.file("keystore.jks")
if (storeFile.exists()) {
def config = new Properties()
config.load(new FileInputStream(rootProject.file("keystore.passwords")))
storePassword config.KeystorePassword
keyAlias config.KeyAlias
keyPassword config.KeyPassword
}
}
}
buildTypes {
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
debuggable true
applicationIdSuffix ".debug"
}
}
dataBinding {
enabled = true
}
lintOptions {
disable 'RtlHardcoded'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// Copy release APK to project root
task copyReleaseApk(type: Copy) {
from 'build/outputs/apk'
into '..'
include '**/*release.apk'
}
afterEvaluate {
if (tasks.findByPath("packageRelease") == null) {tasks.create("packageRelease")}
tasks.findByPath("packageRelease").finalizedBy(copyReleaseApk)
}
}
ext {
// Single place to specify the support library version
supportLibraryVersion = '26.0.0-beta2'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs'
exclude module: 'espresso-idling-resource'
exclude group: "javax.inject"
})
implementation 'com.android.support.test.espresso:espresso-contrib:2.2.2'
// Dagger dependency injection
implementation 'com.google.dagger:dagger:2.10'
annotationProcessor 'com.google.dagger:dagger-compiler:2.10'
implementation 'com.google.dagger:dagger-android:2.10'
implementation 'com.google.dagger:dagger-android-support:2.10'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.10'
implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
implementation "com.android.support:design:$supportLibraryVersion"
implementation "com.android.support.constraint:constraint-layout:1.0.2"
implementation "com.jakewharton.timber:timber:4.5.1"
implementation "com.squareup.phrase:phrase:1.1.0"
implementation "com.squareup.retrofit2:retrofit:2.2.0"
implementation "com.squareup.retrofit2:converter-gson:2.2.0"
implementation "com.squareup.okhttp3:logging-interceptor:3.7.0"
implementation 'net.danlew:android.joda:2.9.9'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-crash:11.0.0'
androidTestImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Update 1: I tried adding debuggable=false to the manifest and it makes no difference, the APK produced still cannot be uploaded to Google Play.
Update 2: I loaded the APKs back into Android Studio using the APK Analyzer that makes it easy to see the manifest, and they all include.... debuggable=true. Where is it coming from?
Update 3: assembleRelease produces a debuggable APK on both my local machine AND on the CI server (BuddyBuild).
Update 4: A clean rebuild (including deleting the build folders) and restarting Android Studio with its caches cleared makes no difference.
Update 5: It seems reasonable to assume that the debuggable=true state could be coming from one of the dependencies, but if that is the case which, and how can that be overridden?
As the project is targeting API 26 and using 3.0.0-alpha4 of the android gradle plugin, 26.0.0-beta2 build tools, and gradle 4.0-rc1 I thought I should check that the issue does not relate to an issue with these pre-release tools. So I reverted to API 25 and the stable releases of gradle 3.3, gradle plugin 2.3.3 and build tools 25.0.3. This was a little tedious as I had to downgrade all the Java 8 syntax from the source to Java 7. But having done that, the build process now works as expected and produces release APK artifacts that do not contain the debuggable="true" flag and can be uploaded to Google Play. 👍
I'm not clear specifically where the cause is but I've logged this in the Android tools bug tracker as it seems possible it is a bug:
https://issuetracker.google.com/issues/62899843
UPDATE: The response from the tools team is that this is expected behaviour because the app targets API 26 and that is in preview. I thought as the 26 APIs were final that APKs could be built against it and released to Google Play but clearly not.
This is because you probably have incremental builds, by default all incremental builds are assumed debuggable.
Under the General Notes of the SDK Tools Revision 8, it states:
Support for a true debug build. Developers no longer need to add the
android:debuggable attribute to the tag in the manifest
— the build tools add the attribute automatically. In Eclipse/ADT, all
incremental builds are assumed to be debug builds, so the tools insert
android:debuggable="true". When exporting a signed release build, the
tools do not add the attribute. In Ant, a ant debug command
automatically inserts the android:debuggable="true" attribute, while
ant release does not. If android:debuggable="true" is manually set,
then ant release will actually do a debug build, rather than a release
build.
I am facing a horrified error. After installing android studio 2.2.3, i couldn't build my very first project due to gradle error. I even tried using maven link but i use my PC offline. The following is my gradle script:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.samim.myapplication"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
androidTestCompile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile 'com.android.support:appcompat-v7:25.1.1'
testCompile 'junit:junit:4.12'
}
I am also posting an image regarding the errors.
After doing clean build and rebuild
project gradle
I tried using maven link but i use my PC offline
That's your problem.
Gradle uses the exact same sources as Maven would.
Once you get online, your dependencies should resolve from any "New Project" in Android Studio. You then should let the dependencies download, and then you are welcome to work offline.
Note: You also need to download the Android SDK
The best solution is to add untrusted server certificates automatically to android studio when using the internet from workplace. Go to Settings -> Tools -> Server Certificates, now check "Accept non-trusted certificates automatically". After this coding can be done offline.
Also using a third party VPN solves certificate issues.