尝试使用mainClassName时出现错误

时间:2019-05-21 13:02:24

标签: android api gradle android-gradle

我正在尝试使用this SMS服务,但是在设置SMSBackend类时,由于我无法获取博客中给出的链接,我无法设置mainClassName,被困在这里,我尝试了jar方法,只有类名,完整的类名是我的gradle文件

buildscript {
repositories { jcenter() }
dependencies {
    classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
}

apply plugin: 'com.android.application'

apply plugin: 'com.github.johnrengelman.shadow'


android {
compileSdkVersion 28
defaultConfig {
    applicationId "net.iquesoft.smsapp"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
mainClassName = 'net.iquesoft.smsapp.SMSBackend'

compileOptions {
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
implementation 'com.sparkjava:spark-core:2.6.0'
implementation group: 'com.twilio.sdk', name: 'twilio', version: '7.9.0'
implementation 'org.slf4j:slf4j-simple:1.6.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

我遇到这样的错误 Could not set unknown property 'mainClassName' for object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

1 个答案:

答案 0 :(得分:0)

您正在创建一个Android项目以生成后端。

您必须按照他所说的here使用Spark框架创建Java项目,然后在运行后端时可以创建Android项目。