Android Studio: create Java project with no Android dependencies

前端 未结 10 1666
遇见更好的自我
遇见更好的自我 2020-12-12 16:20

It\'s possible to add pure Java module to existing Android project.

But is it possible to create pure Java project with no Android dependencies?

相关标签:
10条回答
  • 2020-12-12 17:04

    Not via the 'New project' wizard.

    One alternative is to create a Java maven/gradle project outside Android Studio, then 'import' it into AS via File->Open.

    Gradle has the init plugin to set up a java project scaffold:

    gradle init --type java-library

    https://docs.gradle.org/current/userguide/build_init_plugin.html

    0 讨论(0)
  • 2020-12-12 17:04

    Another way from my perspective:

    1. Create a new android project
    2. Add java module to your project
    3. Close android studio project and go to project's directory, just take the java module folder and paste it to new directory
    4. In Android Studio open exthis this module, ide will generate gradle file for you.
    0 讨论(0)
  • 2020-12-12 17:09

    The easiest way to run a pure java program with input

    Follow these simple steps:

    1. Create a new project or open an existing project
    2. Right-click your package name under java directory > New > Scratch File
    3. Choose java from the dialog

    A class with name Scratch.java will open now you can write your code here...

    1. To run your program just right-click to Scratch.java and choose option -> Run 'Scratch.main()'

    Now you can see you program output. :)

    0 讨论(0)
  • 2020-12-12 17:12

    Easiest Way From Scratch

    1. Create a empty folder where you want to put the project
    2. At the 'Welcome to Android Studio' screen, choose "Open existing..."
    3. Navigate to your folder and hit OK
    4. Your project is created, now add your java files
    5. Choose the SDK and you're done! Happy coding
    0 讨论(0)
提交回复
热议问题