首页 > 解决方案 > 尝试使用 mainClassName 时出错

问题描述

我正在尝试使用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.

标签: androidapigradleandroid-gradle-plugin

解决方案


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

正如他在此处所说,您必须使用 Spark 框架创建一个 Java 项目,并且当您运行后端时,您可以创建您的 Android 项目。


推荐阅读