这就是我的结果所以错误运行代码..
Exception in thread "main" java.lang.ClassNotFoundException: pya.marlon.com.pruebas.ExampleRXJava
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:123)
Process finished with exit code 1
使用一些示例RXJava可能会遇到gradle代码问题..
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "pya.marlon.com.pruebas"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions{
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/main/java-gen', '../greendao/classes']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':greendao')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'de.greenrobot:greendao:1.3.7'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
compile 'com.android.support:design:25.3.1'
compile 'io.reactivex:rxjava:1.3.0'
}
我的Android Studio有什么问题所以版本是2.3.2 我在项目中使用了两个模块
答案 0 :(得分:0)
请正确阅读异常消息,它清楚地显示找不到pya.marlon.com.pruebas.ExampleRXJava
课程,可能您没有包含上述课程。
答案 1 :(得分:0)
要在Android中使用RxJava,请将以下依赖项添加到build.gradle文件中。
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.8
并查看此教程RXJava Android Article