Android Studio: create Java project with no Android dependencies
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
Yes, it is possible. You have to manually create all necessary files.
Here are steps for Gradle based project:
- Remove include ':app' form settings.gradle
- Remove app directory
- Replace build.gradle with example from end of this post (IntelliJ creates similar)
- Create folder hierarchy for your Java code (src/main/java)
Select Edit Configuration from drop down menu where normally you start project
Click Add new Configuration and select Application
- In Main class point your Main class.
Android studio is more or less like IntelliJ Community Edition.
apply plugin: 'java'
sourceCompatibility = 1.8
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}