简体   繁体   English

如何将 android 项目编译为 apk

[英]how can I compile android project to apk

at the first experience with android, I don't install android studio!第一次使用android,我没有安装android studio!

Just cloned a project and search according to see gradlew.bat file.刚刚克隆了一个项目,根据看到的 gradlew.bat 文件搜索。 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:我的设置.gradle:

include ':vlc-android-sdk-3.0.0'
include ':app'
rootProject.name = "DSM"

is SDK needed?需要 SDK 吗? what's emulator has used in this link: https://developer.android.com/studio/build/building-cmdline此链接中使用了什么模拟器: https://developer.android.com/studio/build/building-cmdline

how can I build apk finally?我最终如何构建apk?

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 . 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/工作室#下载 You can use the included SDK manager to download other SDK packages.您可以使用随附的 SDK 管理器下载其他 SDK 包。

The above-mentioned error is also thrown when an incorrect JDK version is installed in your system.当您的系统中安装了不正确的 JDK 版本时,也会引发上述错误。 [Also] make sure you also set up environment variables like ANDROID_HOME, JAVA_HOME, and platform-tools with their respective locations on your pc. [另外] 确保您还设置了环境变量,如 ANDROID_HOME、JAVA_HOME 和平台工具,以及它们在您的电脑上各自的位置。 most of this setup is taken care of by default on installing Android Studio!默认情况下,安装 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.我从不使用这种方法将我的 android 项目编译成 an.apk 我使用另一种方法,我发现它比 android 项目中的 compile.apk 更容易。

What I do is -我要做的是——

  1. Build the Android Project by clicking on the build icon.通过单击构建图标构建 Android 项目。
  2. After the build is successful, Open File Explorer of on your PC.构建成功后,在您的 PC 上打开文件资源管理器。
  3. Then going to the file location - D:\User\Android Studio 4.0.1\Applications\SampleApp\app\build\outputs\apk\debug然后转到文件位置 - D:\User\Android Studio 4.0.1\Applications\SampleApp\app\build\outputs\apk\debug
  4. Now drag the.apk file to upload it anywhere!现在拖动 .apk 文件将其上传到任何地方!
  5. For testing it in mobile without connecting USB, you can Gmail yourself by uploading the file through Google Drive.为了在不连接 USB 的情况下在移动设备上进行测试,您可以通过 Google Drive 上传文件自行 Gmail。 And then downloading the.apk through Gmail in the Mobile Device.然后通过移动设备中的Gmail下载.apk。

NOTE: the file location I have mentioned in Point 3 is different than yours, because i always keep my projects in D: drive.注意:我在第 3 点中提到的文件位置与您的不同,因为我总是将我的项目保存在 D: 驱动器中。 It would be similar after you go to your application folder (after SampleApp folder).在 go 到您的应用程序文件夹(在 SampleApp 文件夹之后)之后,它会是相似的。

Please inform me if this works... Thank you如果这可行,请通知我...谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM