Android Studio 2.1 does not generate signed Apk after updating - android-studio

Recently, I've updated my android studio from 1.3 to 2.1. After that, when I trying to create a signed apk from "Generate Signed APK" in build menu. Android studio seems to works fine and prompting for successful generating release file, but always there is not such apk file in selected output folder. Also, open directory from successful pop up message does not work.
I try creating new keystore for signing and reinstalling android studio as suggested in some posts, but there is no change on issue..
This is build.gradle file I am using:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.vcc4.homeui"
minSdkVersion 15
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')
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/gson-2.6.2.jar')
compile 'com.android.support:design:23.4.0'
}

I encountered the same problem. And I found out that the generated apk was moved from the "app" folder to the "app/build/outputs/apk/" folder.
I do not know if it's a bug or a feature but it probably has something to do with "Automatically Sign Your APK", as this article https://developer.android.com/studio/publish/app-signing.html#release-mode describes the folder mentioned above.

I ran into the same issue today. I restarted Android Studio and that could have solved the issue -- in the meantime, I had issues with ProGuard etc. that started failing my build, so maybe some Gradle sync, project rebuild etc. also came in handy
But I have a sneaking suspicion this is to do with restarting maybe AS or even your machine. I ran into this same issue last time I was trying to build a signed APK and everytime this seems to take up a few of my hours....I need to figure this out too

it seems that the apk generated will be in
{project-folder}/app/release/app-release.apk

Related

Showing no OpenCV module in dependancies in Android Studio

I tried many tutorials and blogs for Setting up OpenCV Android Library on Android Studio
some of them are here
A Beginner’s Guide to Setting up OpenCV Android Library on Android Studio
Add OpenCV library into Android Studio
OpenCV in Android Studio
but i am unable to configure it according to above solutions
at start when i try to import module from /OpenCV-android-sdk/sdk/java android studio not showing module name edit box and hence i have to add "java" as a OpenCV module name
OK after importing module with the name of java we have to add dependencies but in add module dependencies not showing any module name java or anything
Guys anyone know how can i resolve this issue or any proper steps for OpenCV configuration in Android studio
I am using
Android Studio -4.0
opencv-4.3.0-android-sdk
First Screenshot: Android Studio may have removed that option in new version.
Second Screenshot: You can solve issue by editing build.gradle of Opencv as below:
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
//applicationId "org.opencv"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Change apply plugin: 'com.android.application' to apply plugin: 'com.android.library'
and comment out the following line :
applicationId "org.opencv"

android studio, how to make signed apk for release build (gradle using KTS build files)

Would like to run the release build (it is app with multiple lib modules), but it is asking for sign it.
was working by adding the code in the gradle file as:
android {
signingConfigs {
config {
keyAlias 'key0'
keyPassword 'test'
storeFile file('/root/user/androidPrjsKeyStores')
storePassword 'test'
}
}
compileSdkVersion build_versions.target_sdk
buildToolsVersion build_versions.build_tools
defaultConfig {
but after the change the gradle to KTS build files, this code does not work.
so went through the way with android studio
and got t:
but clicking on the "locate" to the release.apk and drag to emulator it got this error
and
cannt open the project for fixing:
lol, it should work but need to delete the one installed before.

How to Migrate my flutter project in Android Studio to Android X Compatibility while I have tried everything mentioned in the official document.?

I have been building a Flutter App in Android App, it was all working fine, as soon as I used GeoLocator Library, my app crashed stating it is incompatible with AndroidX. When I try to Migrate my code to AndroidX, it says "You need to have compiled SDK set to at least 28 in your module build. Gradle to migrate to AndroidX. I have already set it to 28, but it still doesn't work.
In order, to resolve this. I have tried all the steps mentioned in Flutter Documentation.
Link: https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
1. In android/gradle/wrapper/gradle-wrapper.properties change the line starting with distributionUrl like this:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
2. In android/build.gradle, replace:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
by
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
3. In android/gradle.properties, append
android.enableJetifier=true
android.useAndroidX=true
4.In android/app/build.gradle:
Under android {, make sure compileSdkVersion and targetSdkVersion are at least 28
5.Replace all deprecated libraries with the AndroidX equivalents. For instance, if you’re using the default .gradle files make the following changes:
In android/app/build.gradle
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
by
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Finally, under dependencies {, replace
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
by
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
This is some of my build.grade file where I have set the SDK version :
enter code here compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "co.appbrewery.clima"
minSdkVersion 28
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Tried all the things above, still getting an error that changes your SDK version to at least 28 whenever I try to set it Migrate to Android X using the Android Studio feature.
I would recommend using android studio feature to migrate the project to android X, instead of doing it manually.
From the source: Migrate the project to android X using android studio
With Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.
Do it with android studio.
Open the project in the studio and change the minSdk version to 23. You need to update the gradle version also and make it to more than 3.6.0. than go to refractor. There you will get the option of migrate to Android x .and do refractor. It will ask you to take the backup. And after that at the bottom you will get the popup of "Do Refractor". and that's it.

Android Studio 3.0 Canary 2: attribute 'android:versionCode' not found

I've updated Android Studio to the latest canary build and now I can't run my app.
Every time when I try to build the project I get the following error:
Error:F:\...\**app_name**\app\build\intermediates\instant-run-support\debug\slice_0\AndroidManifest.xml:2 attribute 'android:versionCode' not found
I tried to manually open the file and the attribute is clearly there:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="****"
android:versionCode="1"
android:versionName="1.0"
split="lib_slice_0_apk">
</manifest>
I've tried to clean the project, invalidate cache, restart android studio but nothing helped.
This is my build.gradle (app) file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "****"
minSdkVersion 16
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 {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.squareup.picasso:picasso:2.5.2'
}
This issue is strictly related to Instant Run. Workaround: disable it inside File -> Settings/Preferences. This will at least allow you to run your app in the Canary version of AS.
This bug is solved since Android Studio 3.0 Canary 6, just update android studio and all SDK components and restart Android Studio.
Tested on:
Build #AI-171.4163606, built on July 7, 2017
JRE: 1.8.0_152-release-884-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Simply invalidating the caches did the job for me.
File > Invalidate Caches & Restart
No need to disable Instant Run or manually delete any build folders.
What worked for me is a combination of what robin and SamboyCoding said.
Clean Project from build menu
Rebuild Project from build menu
Then I could launch the app for testing without problems.
What worked for me was going into my project folder, and deleting the "build" folder, to force gradle to recompile everything. I also deleted the "gradle" folder, but had to recreate it manually because AS didn't, but I don't think it was this that fixed it.
I had the same. I tried either rebuild the project or change build gradle a bit(e.g change a versionName) and sync, then mostly the issue is temporarily gone.
The fastest workaround that works for me in Android Studio 3.0 Canary 2 is to add the versionCode and versionName attributes, and when the error occurs, I just change it to any other value (e.g. 1.0 to 1.1 and back). Then the app starts fine.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.XXX"
android:versionCode="1"
android:versionName="1.0">
As for 6/9/2017 Android Studio 3.0 Canary 3 the bug still exists. After trying all mentioned ways to fix this, the one that works is to:
Clean Project
Build Project
Disable/Re-enable Instant Run feature
or
Reload Android Studio.
In case of the error - suggesting to send report to Google via Help > Report Instant Run Issue.., also create a bug report in Groups. Don't forget to link this StackOverlow page - may be this way Google will fix this annoying bug fast.
I got the same problem. So I tried the stable version 2.3.1 of android studio. Then there come a question if I want to use the Android studios SDK, I select this.
Try to run the app, a Gradle error come up, which request minimum Android Studio 3.0.
I start Android Studio 3.0 C2 again, the question regarding the SDK come up again, but then the app compiles and the versionCode error was gone.
Clean and rebuild the project
and restart android studio.
It will work.
After cleaning and rebulding I disabled instant run and re-enabled it and the error is gone.
Update Android studio to Canary 3. They solved the problem
Every time I get this following error:
Error:D:\StudioProjects\yoda\app\build\intermediates\instant-run-support\debug\slice_0\AndroidManifest.xml:2 attribute 'android:versionCode' not found
I'd like to delete D:\StudioProjects\yoda\app\build folder, then select Build\Rebuild Project, and everything will become all right.
For me it was enough to delete .gradle folder in the root folder of the project
open the manifest file & close it.
if still not working: rebuild, open manifest file & close it, -> RUN

Unable to access CardBuilder class

I'm using Android Studio to build a Glass app, with my SDK Manager updated to GDK Preview API 19 Revision 9, and my device is on XE 21.3. I'm trying to use the new CardBuilder class, but it isn't available. I can still use the deprecated Card class, but the new stuff just won't show up.
I even uninstalled/reinstalled the Android 4.4.2 packages, but nothing. The same occurs when I load the project in Eclipse, too. I'd like to not use the Card class, as this is for a demo tutorial.
Got any tips on how to force this?
It took me several minutes before Android Studio was able to recognise the new class. You shall delete the build folder and start a clean compilation. There is a problem with classes already compiled with previous version of the GDK which are not noticed for recompilation.
Mine finally got repaired...today's Android SDK update to 23.0.5 seemed to do the trick...that and playing with the External Libraries menu in the Project panel to make sure the new class was available and then manually adding the namespace. Whew.
Thanks for your help everybody! :)
I thought it might be that but it's the same as the Google SDK Sample Projects, but here's what I've got:
apply plugin: 'com.android.application'
repositories {
jcenter()
flatDir {
dirs 'prebuilt-libs'
}
}
android {
compileSdkVersion 'Google Inc.:Glass Development Kit Preview:19'
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 19
targetSdkVersion 20
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
This is why I've stuck with Eclipse for Glass development. Android Studio has been too flaky again and again... I do use Android Studio for standard Android development

Resources