[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?
Related
I am developing for a closed platform and need to sign my apk with platform keys to be able to read from certain protected libraries. since this app additionally is not available on the Google Play store, does this mean that I don't need to sign with any other public private key pair for a release build? currently my workflow is such that we first create the build with gradlew assembleRelease which I assume uses the local.properties to sign my apk given the current build.gradle setup:
release {
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile file('./debug.keystore')
storePassword 'android'
}
if I am subsequently using apksigner to sign with the platform credentials, does that render the aforementioned release build.gradle config pointless?
So it looks like the gradle configuration is used for a particular build type, or the alternative is to use zipalign and apksigner on the apk generated from the gradle task. So if i wanted to continue using apksigner i should remove the build.gradle configuration. I guess theoretically it was signing again the app twice, but since the last one was the non-debug keys, it didn't really matter.
For reference:
https://developer.android.com/studio/build/building-cmdline#gradle_signing
I am beginner in Android. We are facing issues with Google Places API. We generated a SHA key for keystore file and added it to Google console. And use same file for building release apk, and released app. The app is working fine.
With few minor changes we update another version of app, then we got issues with places. Places API is not working.
We need to generate release build from same system, where we generated a SHA key from keystore file? I feel no need because from any system the SHA key is same for release keystore file.
And not added any configurations in Gradle file.
signingConfigs {
release {
storeFile file("my-release-key.jks")
storePassword "password"
keyAlias "my-alias"
keyPassword "password"
}
}
Because we used Sign an APK procedure from this documentation https://developer.android.com/studio/publish/app-signing.html
I am nor getting what exactly we are missing.
I think you are working as a group on project, might be due to code merging. Project got deleted and it will cause problem for you. Just try to configure the place API again. It's the only hope for solving problem.
I want to store my key store in my Android studio Project so that I can use a relative path in the Generate Signed APK Wizard. But I cant see to figure out where the Signed APK Wizard is looking.
How can I use a relative path to my android studio project to my keystore for use with the Generate Signed APK Wizard?
I just tried in Android Studio 1.4 and it seems that the wizard uses paths relative to the project directory.
Example:
project directory /home/dev/project
module name app
keystore file /home/dev/project/app/keystores/debug.keystore
In the wizard following works for me app/keystores/debug.keystore (notice that path is relative - without leading slash).
Adding following to the build.gradle in module will use relative path to the debug.keystore as well (notice that the module name is not listed there as we are already inside the app module)
android {
signingConfigs {
debug {
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile file('keystore/debug.keystore')
storePassword 'android'
}
}
...
}
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.
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