Android Studio和QUOT;建设 - 使项目"不创建罐子 [英] Android Studio "Build - make project" does not create jar

查看:214
本文介绍了Android Studio和QUOT;建设 - 使项目"不创建罐子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Android Studio中首次应用程序,而我想要的应用程序连接到我还将开发一个服务器。此服务器将在Java运行时环境,而不是Android上运行,但我preFER如果我可以开发它旁边的应用程序,在同一个项目,IDE。

I am developing an app in Android Studio for the first time, and I want the app to connect to a server that I will also develop. This server will run on the Java Runtime Environment instead of Android, but I'd prefer if I can develop it alongside the app, in the same project and IDE.

我迄今所做的:


  • 在根目录增加了一个服务器文件夹(同一水平 /应用程序文件夹)

  • 增加了服务器/ src目录/ JAVA /主/ Hello.java 文件上手

  • 增加了服务器/的build.gradle 这个文件的内容:

  • added a server folder in the root (same level as the /app folder)
  • added a server/src/java/main/Hello.java file to get started
  • added a server/build.gradle file with this content:

apply plugin: 'java'
jar {
    manifest {
        attributes 'Main-Class': 'Hello'
    }
}


  • 更​​新 settings.gradle 来包括服务器模块是这样的:

  • updated settings.gradle to include the server module like this:

    include ':app', ':server'
    


  • 以上足以得到这个工作:

    The above suffices to get this working:


    • 执行构建的gradle 在命令行上,现在创建一个可执行的server.jar。

    • 服务器code Android Studio中显示出来。它也内置如果我点击构建 - 使项目

    • Executing gradle build on the command line now creates an executable server.jar.
    • The server code shows up in Android Studio. It is also built if I click Build - Make Project.

    然而,构建 - 让项目由于某些原因只编译 Hello.java 文件转换成一个.class文件。它不是创建的server.jar 文件。为什么不能做同样的事情作为一个构建的gradle ?我该如何解决这个问题?

    However, Build - Make project is for some reason only compiling Hello.java files into a .class file. It is not creating the server.jar file. Why is it not doing the same thing as a gradle build? How do I fix this?

    推荐答案

    所有可用gradle这个任务可以从Android Studio中的右侧的摇篮工程工具窗口探索,虽然你可能需要点击刷新按钮之前首先它显示了他们。 jar任务应该出现在那里,并双击将建立的server.jar文件。

    All available gradle tasks can be explored from the "Gradle projects" tool window on the right hand side of Android Studio, though you may have to click the "refresh" button first before it shows them. The jar task should show up there, and double clicking will build the server.jar file.

    创建一个jar文件是没有必要迅速启动从Android Studio中的服务器虽然。更改服务器/的build.gradle 如下:

    Creating a jar file is not necessary to quickly launch the server from Android Studio though. Change server/build.gradle as follows:

    apply plugin: 'java'
    apply plugin: 'application'
    
    mainClassName = "Hello"
    

    在在摇篮工程工具窗口再次更新,这应该做一个跑任务提供。右键单击它,然后单击运行...菜单项,把这个任务分解成一个运行配置。现在应用程序可以容易地与运行按钮来启动在IDE的顶部

    After another refresh in the "Gradle Projects" tool window, this should make a "run" task available. Right-click it and click the "run ..." menu item to turn this task into a run configuration. Now the application can easily be started with the run button at the top of the IDE.

    这篇关于Android Studio和QUOT;建设 - 使项目"不创建罐子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆