First, running the Java Main method in studio is theoretically feasible, after all, with the JDK in studio.
If you can't run the main method, it's definitely not the right place to do it.
I started building Javalib's moudle to create Java classes, and ran the following error:
Error:gradle:a problem occurred configuring root project ' Newtest '.
> could not resolve all files for configuration ': Classpath '.
> Could not download Kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.1.3-2) ...
> could not download Protobuf-java.jar (com.google.protobuf:protobuf-java:3.0.0)
> could don't get Resource ' Https://jcenter.bintray.com/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.jar ' ...
.
.... There's dozens of more lines of code in the back.
I did a direct check on the Internet: studio to run the main method, but not a few, and finally asked colleagues, in order to succeed.
The correct approach is:
1. Create a javalib moudle in the Android workspace.
Configure the Build.gradle for the entire project, and note that this is not a single moudle build.gradle
is to add a URL to the central warehouse of the workspace.
Jcenter () {
url ' http://jcenter.bintray.com/'
}
I have only jcenter (), not add that website, No. Just add this to it.
Complete Configuration Code:
Top-level build file where your can add configuration options common to all sub-projects/modules.
Buildscript {
repositories {
Google ()
//Focus
Jcenter () {
url "http://jcenter.bintray.com/"
}
}
dependencies {
classpath ' com.android.tools.build:gradle:3.0.1 '
//Note:do not place your application dependencies here; They belong
//In the individual module build.gradle files
}
allprojects {
repositories { C19/>google ()
jcenter ()
}
task Clean (type:delete) {
Delete rootproject.builddir
}
To create a Java class directly in an Android project running the main method is definitely not the case, above I said in the Lib project this method I was successful in the trial.
Some people may be building a Lib project directly, you can run the main method, possibly the default configuration of the workspace.
After all, everyone's configuration environment is likely to be different, if not enough to try other people's approach, someone must have encountered the same situation as you.