Home > Net >  how can I compile android project to apk
how can I compile android project to apk

Time:11-30

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?

CodePudding user response:

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!

CodePudding user response:

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 -

  1. Build the Android Project by clicking on the build icon.
  2. After the build is successful, Open File Explorer of on your PC.
  3. Then going to the file location - D:\User\Android Studio 4.0.1\Applications\SampleApp\app\build\outputs\apk\debug
  4. Now drag the .apk file to upload it anywhere!
  5. 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).

Please inform me if this works... Thank you

  • Related