Recently change to Android Studio from Eclipse and I have also changed the JDK from java-open-jdk to jdk1.7.0_45.
Now I'm trying to run my first app and I get this message:
Installation failed since the APK was either not signed, or signed incorrectly.
If this is a Gradle-based project, then make sure the signing configuration
is specified in the Gradle build script
Edit:
When I'm running from Android Studio I get the error displayed above. When I'm running it from the command line I don't get an error (well the app is running and I get an error but nothing to do with gradle).
I got the code from here
You can check build.gradle here at google repo
UPDATE 2:
I added this code
signingConfigs {
release {
storeFile file("john.keystore")
storePassword "john"
keyAlias "johnkeystore"
keyPassword "john"
}
}
just above the buildTypes code block in the build.gradle file.
File john.keystore is on the root of my Project. I'm running gradlew assembleRelease and I'm getting a xxx-release-unsigned.apk.
If you indeed runing build with gradle you need to configure signingConfigs. Android can configure your debug signingConfig automatically. You can make release signingConfig in a next manner:
android {
signingConfigs {
release {
storeFile file('android.keystore')
storePassword "pwd"
keyAlias "alias"
keyPassword "pwd"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
Check manual on this topic here: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Signing-Configurations
If you still have issues, please update question with your build.gradle. Most likely issue is laying here. I'm using JDK 1.7 and gradle builds are working fine.
I had the same problem, i went to Build->Clean Project and re-execute the project and it worked.
I have been struggling for a while with Android Studio esp. gradle and build variants.
I have change this from the build types as defined:
debug
release
As I ran into the same problem (while developing and running tests), I went to Build -> Rebuild Project and then re-launched the emulator. That worked for me.
None of the answers worked for me, even after uninstalling app from phone, I could not deploy it. What worked was installing the app o a different device, and then when I tried to deploy it on the previous device, it miracleously worked.
If your goal is not to create a custom build for your application you might want to clean all the data about it from your test device, in case you are using emulator just wipe all the data from device. Go to -> Tools -> Android -> AVD Manager -> [Device you wanna wipe] (In actions tab) -> Wipe Data.
In case of actual device just uninstall the app and all related data.
Reason is that unsigned APK has a signature, so device sees you're trying to install something with the same package name that was generated not here.
Hope this saves you some time.
In case your device has multiple users, before installing signed APK, check if the same app is not installed for other users. If it is there remove it.
For me this was the root cause of rejecting installation of signed APK.
Just to Build -> Rebuild Project and then re-launched the emulator. That worked for me.
Related
[EDIT: I have found that if I have "minifyEnabled true" set for release build, then I see the following issue. If removed, issue is resolved. Is this a bug?]
Original post:
I have my library that I am using in my app, as Library project. In that Library I am using raw files that are in "myLibrary\src\main\res" folder. I use resources?.openRawResource(R.raw.file) function to access the file.
This is working fine when I am developing project and run the app on my device. But when I download my published app from playstore, openRawResource() fails and returns nullpointerException.
I opened signed apk in win rar, the raw files are not in there.
Also, when I use the following config to build and install the app on my device using Android Studio, then it works fine.
signingConfigs {
config {
keyAlias 'abc'
keyPassword 'pass'
storeFile file
storePassword 'abcPass'
}
}
Can you tell me what possibly could be wrong?
I just converted my Eclipse project to an Android Studio project.
One of the very important step in the building/running process is to sign the apk.
So I used the "generate signed apk" from the build menu and it worked fine.
Now, I just want that when I run the app on the USB device, the signing is done automatically. The Android Studio page state that it's possible using the "signing" tabs in the module settings but this tabs doesn't exist!! See the picture below:
I have the latest version of Android Studio, so I guess this feature moved somewhere else but I can't find it!
Thanks!
The menu is under File > Project Structure. Then select your module from the list on the left, switch to the signing tab, and add your signing information.
This will make two changes to your build.gradle:
First, it will add a signingConfigs {} section that looks something like this-
signingConfigs {
release {
storeFile file("your.keystore")
storePassword 'mySecreKystorePassword'
keyAlias 'myKeyAlias'
keyPassword 'mySecretKeyPassword'
}
}
Second, it will configure your buildTypes to use this signing config like so-
buildTypes {
release {
signingConfig signingConfigs.release
}
Usually there're good reasons to have separate debug and production builds (e.g. separate API endpoint, separate API KEYS on tracking, faster building times), so I'll leave a question here for you: Why do you want to debug using a signed (a.k.a. production) build?
on the other hand, to answer your question, there's an easy way to switch which build variant that will be used when you hit the play button on AndroidStudio.
On the several panels around the border there's one named BuildVariants with a little Android icon. Over there's a drop-down menu where you can change to use debug or release build variant.
I have a project with three different build types: debug, beta, and release. My test package is always created for debug builds, but QA uses the beta build and we want QA to run these tests on their vast array of devices.
I'm trying to create a testing apk for QA that is signed by the same key as the beta build. Looking through the Android-Gradle documentation, I don't see anything telling me that I can't do this, but I don't see anyway to configure this. Is there anyway I can configure which keystore is used when assembling a test apk? Or is there a way to create an unsigned test apk?
You can now point this to a different target, I don't know when this happened, but from the docs:
Currently only one Build Type is tested. By default it is the debug
Build Type, but this can be reconfigured with:
android {
...
testBuildType "staging"
}
This is an incomplete answer to your question in that it documents what you can't do, but the connectedAndroidTest task, which is what runs the androidTest tests in your project, is hardcoded to run against the debug build type, and I don't see a way to point it at a different build type.
Taking the advice from Is there a way to list task dependencies in Gradle? and examining the task dependency tree, if you run:
./gradlew tasks --all
you get this in your output:
Verification tasks
------------------
app:check - Runs all checks. [app:lint]
app:connectedAndroidTest - Installs and runs the tests for Build 'debug' on connected devices. [app:assembleDebug, app:assembleDebugTest]
app:connectedCheck - Runs all device checks on currently connected devices. [app:connectedAndroidTest]
app:deviceCheck - Runs all device checks using Device Providers and Test Servers.
The documentation for the connectedAndroidTest task claims it runs tests against debug, and the task dependencies (which you see with the -all flag) confirm that the task depends on assembleDebug.
Adding additional build types and flavors doesn't seem to affect the dependency on the built-in debug type.
It's possible that with greater Gradle-fu than mine, you could rewire the tasks to make the tests depend on a different build type, but doing this is likely to be fragile since it's bound to depend on things that aren't supported API in the Android Gradle plugin.
To answer your question most directly, though, if all you want is to run tests against a build with a different certificate, you could change the signing config on your debug build to use the beta certificate:
android {
signingConfigs {
beta {
keyAlias 'key'
keyPassword 'password'
storeFile file('/path/to/beta_keystore.jks')
storePassword 'password'
}
}
buildTypes {
debug {
signingConfig signingConfigs.beta
}
beta {
signingConfig signingConfigs.beta
}
}
}
I tested it and I am able to run androidTest targets against debug builds that use a custom keystore in this way. However, I doubt this solves your problem, because I suspect you want to run your tests against the beta build, not a debug build with the beta certificate.
To add a testing source set for your build variant, follow these steps:
In the Project window on the left, click the drop-down menu and
select the Project view.
Within the appropriate module folder,
right-click the src folder and click New > Directory.
For the directory name, enter "androidTestVariantName." For example,
if you have a build variant called "MyFlavor" then the directory name
shoulbe "androidTestMyFlavor." Then click OK.
Right-click on the new directory and click New > Directory. Enter
"java" as the directory name, and then click OK.
Now you can add tests to this new source set by following the steps above to add a new test. When you reach the Choose Destination Directory dialog, select the new variant test source set.
The instrumented tests in src/androidTest/ source set are shared by all build variants. When building a test APK for the "MyFlavor" variant of your app, Gradle combines both the src/androidTest/ and src/androidTestMyFlavor/ source sets.
Another way is to put following line your in default config.
Currently only one Build Type is tested. By default it is the debug Build Type, but this can be reconfigured with:
android {
...
testBuildType "staging"
}
I'm getting below error while trying to upload new APK file.
Upload failed
You uploaded a debuggable APK. For security reasons you need to
disable debugging before it can be published in Google Play.
If you're using Android Studio, the simplest way is to open the "Build Variant" toolbar on the left bottom and change it from "Debug" to "Release" then "Build" -> "Generated Signed APK".
In my case I had to add android:debuggable="false" into manifest.. Worked even without few days ago.
If you using maven and android-maven-plugin, add this to plugin configuration
<configuration>
<release>true</release>
</configuration>
Please note, even if you have a release entry in your gradle build with debuggable false, if debuggable is set to true in the AndroidManifest.xml, it will still fail to upload. Found a random subproject in mine that had it set to true even though the gradle build file was false for all sub projects.
In case someone still looking the answer. I had similar problem. In my case Google Api error was: Google Api Error: apkNotificationMessageKeyDebuggable: APK is marked as debuggable. - APK is marked as debuggable. During investigation I've found that inside BuildConfig.java file DEBUG constant equals true even though BUILD_TYPE == release. After several hours I've found this thread. So in my case the problem was in jacoco. After removing testCoverageEnabled = true for release build, DEBUG became false again.
Loads of tutorials for Android Studio need me to use the "Project Structure" window (File > Project Structure), but whenever I try to open it, I get an error "We will provide a UI to configure project setting later. Until then, please manually edit your build.gradle file(s.)".
Does anyone know if it's like this for everyone (in which case, what do those tutorials mean by File > Project Structure?), or just me? I've had the same error on Windows and Linux.
One of the tutorials: How do I add a library project to Android Studio?
Before Android Studio, IntelliJ Android plugin users used to use the Project Structure dialog to add/remove modules from their projects.
Android Studio aims to have a single model for building your application from both the command line and from the IDE. So if you have to modify the project structure, the correct way to do it is to modify your build.gradle (and/or settings.gradle) build scripts and reimport the project.
Eventually (within a few months), Android Studio will hook up the project structure dialog to automatically edit the gradle build scripts for you, or will provide a different UI, just like the error message says.
You'll find the gradle plugin user guide at http://tools.android.com/tech-docs/new-build-system/user-guide to be helpful in figuring out how to add libraries to your gradle build scripts.
There are currently some bugs with the UI in android studio project structure settings related to updating the Gradle. Right now whatever I enter into the project structure fields do not save or update the gradle files. What did work for me was writing the settings directly into the build.gradle
The gradle files are basically xml files that are generated (dynamic) instead of static.
I tried forever in the project structure UI to set up application signing for debug, eventually to get it to work I added,
android {
signingConfigs {
debug {
storeFile file("debug.keystore")
}
myConfig {
storeFile file("other.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
foo {
signingConfig signingConfigs.myConfig
}
}
}
The android developers guide for configuring gradle will help you get up to speed.
http://developer.android.com/tools/building/configuring-gradle.html
refer to the Gradle documentation for the parameters you are looking for
http://tools.android.com/tech-docs/new-build-system/user-guide
There are currently some bugs with the UI in android studio project structure settings related to updating the Gradle. Right now whatever I enter into the project structure fields do not save or update the gradle files. What did work for me was writing the settings directly into the build.gradle
The gradle files are basically xml files that are generated (dynamic) instead of static.
I tried forever in the project structure UI to set up application signing for debug, eventually to get it to work I added,
android {
signingConfigs {
debug {
storeFile file("debug.keystore")
}
myConfig {
storeFile file("other.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
foo {
signingConfig signingConfigs.myConfig
}
}
}
The android developers guide for configuring gradle will help you get up to speed.
http://developer.android.com/tools/building/configuring-gradle.html
refer to the Gradle documentation for the parameters you are looking for
http://tools.android.com/tech-docs/new-build-system/user-guide