我刚刚创建了一个新项目,并添加了一个简单的空协程,以检查一切是否正常。
@Echo Off
setlocal EnableDelayedExpansion
set _my_Current_Folder=C:\VEHADARTA\Routine_Tasks\T001_Daily_Changes
Set _FTPServerName=84.95.247.239
Set _UserName=XXXX
Set _Password=YYYY
Set _RemoteFolder=public_html/vehadarta/Batch_Jobs/
Set _Filename=Daily_Changes.sql
Set _ScriptFile=ftp1
call :Put_the_Daily_Changes_sql_file_in_FTP_Server
pause
exit
:Put_the_Daily_Changes_sql_file_in_FTP_Server
>"%_ScriptFile%" Echo verbose
>>"%_ScriptFile%" Echo open %_FTPServerName%
>>"%_ScriptFile%" Echo %_UserName%
>>"%_ScriptFile%" Echo %_Password%
>>"%_ScriptFile%" Echo cd %_RemoteFolder%
>>"%_ScriptFile%" Echo lcd %_Current_Folder%
>>"%_ScriptFile%" Echo prompt
>>"%_ScriptFile%" Echo binary
>>"%_ScriptFile%" Echo put %_Filename%
>>"%_ScriptFile%" Echo quit
:: Run script
ftp -s:"%_ScriptFile%"
Del "%_ScriptFile%"
exit /b
我崩溃了
class MainActivity : AppCompatActivity(),CoroutineScope {
lateinit var job: Job
override val coroutineContext: CoroutineContext
get() = Dispatchers.Main + job
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
job=Job()
launch { }
}
}
我的build.gradle
Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2019-01-31 21:06:54.720 11930-11930/com.seed.kotlintest I/zygote64: at void android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, android.support.v4.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)
2019-01-31 21:06:54.720 11930-11930/com.seed.kotlintest I/zygote64: at android.view.ViewGroup android.support.v7.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
2019-01-31 21:06:54.720 11930-11930/com.seed.kotlintest I/zygote64: at void android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-01-31 21:06:54.720 11930-11930/com.seed.kotlintest I/zygote64: at void android.support.v7.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-01-31 21:06:54.720 11930-11930/com.seed.kotlintest I/zygote64: at void android.support.v7.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-01-31 21:06:54.720 11930-11930/com.seed.kotlintest I/zygote64: at void com.seed.kotlintest.MainActivity.onCreate(android.os.Bundle) (MainActivity.kt:16)
2019-01-31 21:06:54.720 11930-11930/com.seed.kotlintest I/zygote64: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7183)
2019-01-31 21:06:54.720 11930-11930/com.seed.kotlintest I/zygote64: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1220)
2019-01-31 21:06:54.720 11930-11930/com.seed.kotlintest I/zygote64: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2910)
2019-01-31 21:06:54.720 11930-11930/com.seed.kotlintest I/zygote64: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$Ac
你们可以尝试相同的方法。只需创建一个新的空项目并添加空协程
答案 0 :(得分:0)
要使用Dispatchers.Main
,我们需要向{strong> build.gradle 文件中添加kotlinx-coroutines-android
:
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.0'