Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

question from:https://stackoverflow.com/questions/28957283/android-studio-create-java-project-with-no-android-dependencies

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
188 views
Welcome To Ask or Share your Answers For Others

1 Answer

Yes, it is possible. You have to manually create all necessary files.

Here are steps for Gradle based project:

  1. Remove include ':app' form settings.gradle
  2. Remove app directory
  3. Replace build.gradle with example from end of this post (IntelliJ creates similar)
  4. Create folder hierarchy for your Java code (src/main/java) enter image description here
  5. Select Edit Configuration from drop down menu where normally you start project

  6. Click Add new Configuration and select Application enter image description here

  7. 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'
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...