cordova 5.0 generate signed apk - android

I use Cordova 5.0.0 to develop android app and I would like to run the app on real machine.
I tried two ways to generate signed apk but failed,
One is used command line to sign an apk that generated by cordova. by this way, it will cause "parsing error" when install the apk;
The second way I tried is using android studio to generate signed apk. My step is "import non-android studio project" then generate signed apk. By this way, I install successfully but the app can't be open and popup error info "unfortunately, xx has stopped".
There is no problem with the code.
Anyone can give me some suggestion? Thanks.

Cordova 5 uses gradle to compile now, so the old ant.properties no longer works. You can work the same trick by creating a release-signing.properties file in platforms/android and adding the following:
storeFile=<path to="" .keystore="" file="">
storeType=jks
keyAlias=<your key="" alias="">
// optional :
keyPassword=<your-key-password>
storePassword=<your-store-password>

If you used Android Studio, you can try with Intellij IDEA (Android Studio is performed by Intellij Platfrom ) here.
After importing your projet, simple go to :
Build > Generate Signed APK..
You'll need to create a key and then Intellij will create your APK.
If you still have your error "unfortunaly..." connect your device and check Intellij logs.

Related

React Native AppCenter build problem - "JAVA_HOME_11_X64"

I updated most app packages, updated gradle (distributionUrl=https://services.gradle.org/distributions/gradle-7.5-bin.zip) and gradle tools ('com.android.tools.build:gradle:7.3.0').
I can make apk file through android studio. I can work with the emulator.
I tried to build via AppCenter and got an error that I need to use JAVA 11.
In the builder configuration, I inserted the parameter - JAVA_HOME => $(JAVA_HOME_11_X64).
The build was assembled successfully.
But if I try to install apk on my phone I get an error (see screenshot)
Also, the size of the apk file has increased by 2 times, which is very strange.
I can't install the apk file created through the AppCenter.
Perhaps someone faced such a problem? I will be grateful for advice.
image

Google Play error: cannot upload a test-only APK

When trying to upload the first apk to a recently created project in GooglePlay console, I receive this error:
You cannot upload a test-only APK
Searching Google gives me 0 results for that exact string as per today.
I also have submitted a ticket for Play Console. Will update here if have any answer.
UPDATE Nov 29th 2017
As #paul-lammertsma suggested, there's a workaround. Still would be good to know why we need to go gradle way and we cannot do it via IDE.
Building your app through Android Studio 3.0 and later will add android:testOnly="true" to your application manifest, marking the APK as FLAG_TEST_ONLY for the PackageManager. More information on CommonsBlog here.
Attempting to install such an APK outside of Android Studio will fail with:
Failed to install app-debug.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
Attempting to upload it to Google Play will also fail, with :
You cannot upload a test-only APK
There are four solutions to this:
Build from Android Studio
Simply select "Build APK(s)" from the "Build" menu in Android Studio.
Sign from Android Studio manually
Simply select "Generate Signed APK..." from the "Build" menu in Android Studio. Provide the keystore and enter the signing details in the dialog that displays.
Build through Gradle
You can of course simply execute Gradle from the terminal for some automation, for instance if your deployment cycle runs through CI (which I highly recommend!):
./gradlew assembleRelease
(Alternatively, you may prefer running this Gradle task from the Gradle pane from within Android Studio.)
Disable this feature in Android Studio
If you don't like this behavior, you may elect to add this flag to your gradle.properties. Beware that the test flag is for your own protection, so you don't accidentally publish a test-only APK!
# Disble testOnly mode for Android Studio
android.injected.testOnly=false
Looks like I found something very related:
ADB Install Fails With INSTALL_FAILED_TEST_ONLY
I'm using 2.4.0-alpha6 of gradle plugin and that's seems to be far from ready to be used for production.
So the solution is to use the latest stable gradle plugin:
classpath 'com.android.tools.build:gradle:2.3.1'
Click on Build and then press BuildAPK(s) and then upload it will work. Instant run APK on android studio 3.0 runs only on the device attached to adb.
I found this blog that addresses the cause of the "test-only" bug
https://commonsware.com/blog/2017/10/31/android-studio-3p0-flag-test-only.html
basically, there are two things to note about it:
You cannot install an app with android:testOnly="true" by conventional means, such as from an Android file manager or from a download off of a Web site
Android Studio 3.0 sets android:testOnly="true" on APKs that are run from the IDE
android studio 3.0 now sets this "testOnly" flag when you compile a release version using the green Run button (make project CTRL+F9).
The solution I found is to not call "make project", but to call either
build > build APK
or
build > Generate Signed APK...
I am using Android Studio 3.1 Canary 5
What I had tried (but not worked):
I tried all the answers as above,but Unfortunately I didn't get solution.
I removed kotlin dependency and signed but doesn't worked.
I tried use command line like ./gradlew assembleRelease
I tried to build apk using "Build APK" and "Generate Signed APK"
After all the possibilities I got solution by following way:
- Compile SDK Version changed from Android P to Android Oreo 27
- Changed AppCompat Version to 27.0.1
and Its successfully working now.
Thank you.
It worked for me. Try to run this and build again.
./gradlew assembleRelease
Maybe You are uploading the wrong apk file which is generated previously not the signed apk. So select the apk file by locating the exact path of the generated signed apk file.

Android change development environment

Currently I am using Eclipse IDE with ADT plugin for my Android application development, but when I change the same source code to another machine with same IDE and ADT Plugin, the generated APK cannot be installed as upgrade, android show a error message (I don't remember the error message)
Since that error, I use the original IDE to compile an APK and finally upgrade on the installed devices.
What I need to add/change in other machines to avoid install errors?
Thank you.
You need to use the same keystore to build your app when you test.
Android: keytool error on the command line when locating debug.keystore
or on a Mac:
How to find ~/.android/debug.keystore in Mac OS X for Android?
Copy the debug keystore from one machine to the other. You may want to make a back up if you have multiple projects that you are debugging, but you should probably just migrate to a common key.
The apk generated will have a different key therefore it cannot be installed as an update.

Creating apk file with netbeans

I know how to create .apk application with eclipse, but right now I have written it with netbeans and I don't know how to do it.
https://blogs.oracle.com/geertjan/entry/procedure_for_android_development_on
here is said to click right mouse button on my project and choose "Export Signed Android Package" but I don't have such option.
Try phonegap cloud build service, it is very good option, you have to remember to generate your app's config.xml before building online. You can build apk,ipa,oct, etc as you wish.I think you have to install some plugins for build using netbeans.Check for plugin as shown:
Tools-->plugins-->Available plugins
Nativly this is not possible with netbeans. However you can build your project simply my command-line:
phonegap run android
However this depends on your platform and your phonegap version, read on: http://docs.phonegap.com/en/3.2.0/guide_cli_index.md.html#The%20Command-Line%20Interface

eclipse is not generating apk file for any app developed in it?

I've been developing some applications in android using eclipse IDE.
All of those apps run fine on emulator but eclipse is not generating their .apk file and i am not able to install apps in any device.
Also its not giving any error or warning while running apps on emulator.
Please help me there.Thanks in advance for any help.
If it is not generated itself, you have to right click on the project you want the apk for, then Android Tools will lead to the Exporting the apk file. You have to create a key one time and you can use it further in your apk generation.
When you run the project on the emulator, the .apk is generated on the bin directory. Keep in mind that just building the project (and not running it) will not output the apk file into the bin directory.
Have you checked the bin directory?
Right Click on Your Project-> Build Project
Check in your Bin folder, it will have your application apk file.
If you do not find it,try restarting your eclipse and building project.
To run application on your device, make sure your device is discovered and in Device Settings "Allow Mock Locations" is checked
try to upgrade your ADT and SDK, I had a same problem this morning.
Google just introduced a new build system.
http://developer.android.com/tools/sdk/eclipse-adt.html
in eclipse from package explorer right click on your application -> Export ->Android -> export android application -> after this follow the steps from wizard and get your signed apk
Try to switch off Antivir or firewall

Categories

Resources