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
Related
at the first experience with android, I don't install android studio!
Just cloned a project and search according to see gradlew.bat file. but when I run it:
PS D:\projects\android> .\gradlew.bat assembleDebug g
FAILURE: Build failed with an exception.
* Where:
Settings file 'D:\projects\android\settings.gradle'
* What went wrong:
Could not compile settings file 'D:\projects\android\settings.gradle'.
> startup failed:
General error during semantic analysis: Unsupported class file major version 61
java.lang.IllegalArgumentException: Unsupported class file major version 61
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:196)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:177)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:163)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:284)
at org.codehaus.groovy.ast.decompiled.AsmDecompiler.parseClass(AsmDecompiler.java:81)
...
my settings.gradle:
include ':vlc-android-sdk-3.0.0'
include ':app'
rootProject.name = "DSM"
is SDK needed? what's emulator has used in this link: https://developer.android.com/studio/build/building-cmdline
how can I build apk finally?
Yes, you need the Android SDK to build, run and debug apps! if you don't want to install Android Studio, you can download the basic Android command-line tools from this link: https://developer.android.com/studio#downloads. You can use the included SDK manager to download other SDK packages.
The above-mentioned error is also thrown when an incorrect JDK version is installed in your system. [Also] make sure you also set up environment variables like ANDROID_HOME, JAVA_HOME, and platform-tools with their respective locations on your pc. most of this setup is taken care of by default on installing Android Studio!
I never use this method to compile my android project into an .apk
I use an alternative method which I find easier than compiling .apk in the android project.
What I do is -
Build the Android Project by clicking on the build icon.
After the build is successful, Open File Explorer of on your PC.
Then going to the file location - D:\User\Android Studio 4.0.1\Applications\SampleApp\app\build\outputs\apk\debug
Now drag the .apk file to upload it anywhere!
For testing it in mobile without connecting USB, you can Gmail yourself by uploading the file through Google Drive. And then downloading the .apk through Gmail in the Mobile Device.
NOTE : the file location I have mentioned in Point 3 is different than yours, because I always keep my projects in D: drive. It would be similar after you go to your application folder (after SampleApp folder).
I'm using Android Studio 2.4 preview 7 version. But, when I build debug apk and install via adb command or put apk file in sdcard of device it always gives me same error "App not installed" in any of android phone. I have got INSTALL_FAILED_TEST_ONLY error in Android Logcat every time at the time of installation in any android device.
If you analyze your apk file you'll see the problem easily - namely that when building the project with the mentioned Android Studio version, the Gradle plugin is automatically injecting an android:testOnly=true to the final AndroidManifest.xml file of the output apk.
You can read more about this property and what it's used for HERE.
To workaround this problem - you can still install the app using this command:
adb install -t debug.apk
If you want to build a signed release version of your app (e.g. for publishing the Play Store), you can always do so via Build -> Generate Signed APK. The result is an apk without the mentioned property and can be installed on any device.
If you want a bit of context why this property is injected, perhaps check THIS and THIS issues on the AOSP bug tracker.
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.
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.
While using Android Studio I encountered the following error:
The date of the APK is 2 days older than the current one (Gradle is used to append the build date to APK name). I've checked folder \build\outputs\apk, and an APK with the correct date has indeed been generated:
The follows have been tried:
Build -> Clean Project
Build -> Rebuild Project
File -> Invalidate Caches / Restart...
How do I fix this so the correct APK can be uploaded to device to run?
Edit:
Changed the title to better reflect the circumstances where this issue would occur. It appears that Android Studio would remember the APK names provided by Gradle when it's been synced with Android Studio, but does not update the APK names when Gradle is ran to create the actual files.
In my situation it's caused by the fact that the current date is appended to the APK name, so if I synced Gradle to Android Studio on 12/3 Android Studio would remember the APK filename to be app_2014-12-03.apk). Then using Gradle build and run the app on 12/4 would cause the disconnection between Android Studio and Gralde, where Gralde generated app_2014-12-04.apk and yet Android Studio still remembered the APK filename to be app_2014-12-03.apk.
It is a problem with sync between Gradle and Android Studio. Press Gradle Sync icon (it is icon between Project Structure and AVD Manager) and it will solve the issue.
(In comments you asked for explanation - I found this answer few weeks ago, when I had also issue with this[but now I cannot find this page]. If I remember correctly was information, that during Sync Gradle is informing AS about different information including info about apk path. In your case [and mine in past] path is changing every day, as we have date in name of apk and due to this we have to make Sync)
If you want a workaround for this you can check out my answer on this post.
Basically, you wold only rename the APK when doing a command line build, such as from a CI Server. While doing normal development Android Studio works as usual.