Failed resolution of:Ljava/util/stream/IntStream

java8中最重要的两个特性,

一个是可以使用lambda表达式,另一个就是对集合对象操作的api、Stream的使用。

将这俩个特性使用android上也会大大的提高编程效率,下面看该如何使用它们。

编译环境:

java1.8

android studio 2.2

虚拟机:android 6


配置文件:

项目build:


config.gradle

ext {
    dependencies = ["appcompat-v7"        : "com.android.support:appcompat-v7:24.2.0",
                    "design"              : "com.android.support:design:23.3.0",
                    "recyclerview-v7"     : "com.android.support:recyclerview-v7:23.3.0",
                    "retrofit"            : "com.squareup.retrofit:retrofit:1.9.0",
                    "rxandroid"           : "io.reactivex:rxandroid:1.1.0",
                    "rxjava"              : "io.reactivex:rxjava:1.1.0",
                    "okhttp-urlconnection": "com.squareup.okhttp:okhttp-urlconnection:2.0.0",
                    "okhttp"              : "com.squareup.okhttp:okhttp:2.0.0",
                    "glide"               : "com.github.bumptech.glide:glide:3.6.1"]
}

app/build.gradle

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'android-apt'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.example.xq.rxandroiddemo"
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
//        jackOptions {
//            enabled true
//        }

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile rootProject.ext.dependencies["design"]
    compile rootProject.ext.dependencies["appcompat-v7"]
    compile rootProject.ext.dependencies["retrofit"]
    compile rootProject.ext.dependencies["rxandroid"]
    compile rootProject.ext.dependencies["rxjava"]
    compile rootProject.ext.dependencies["okhttp-urlconnection"]
    compile rootProject.ext.dependencies["okhttp"]
    compile rootProject.ext.dependencies["glide"]
}

错误:


代码:



可以看到 rxandroid,lambda表达式都是可以使用的,编译时也是可以通过的 但是一运行就报错

原因:

streamAPI只有在android7中才支持,那么如果想在android7以下使用该怎么做呢?

引入:

在app/build.gradle中使用

compile 'com.annimon:stream:1.1.1'


结果:


android 使用poi读取高版本excel, 解决以下这两个错误 java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLEventFactory; at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.(PackagePropertiesMarshaller.java:41) at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161) at org.apache.poi.openxml4j.opc.OPCPackage.(OPCPackage.java:141) at org.apache.poi.openxml4j.opc.ZipPackage.(ZipPackage.java:97) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:324) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:184) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:149) javax.xml.stream.FactoryConfigurationError: Provider com.sun.xml.internal.stream.events.XMLEventFactoryImpl not found at javax.xml.stream.FactoryFinder.newInstance(Unknown Source) at javax.xml.stream.FactoryFinder.newInstance(Unknown Source) at javax.xml.stream.FactoryFinder.find(Unknown Source) at javax.xml.stream.FactoryFinder.find(Unknown Source) at javax.xml.stream.XMLEventFactory.newInstance(Unknown Source) at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.(PackagePropertiesMarshaller.java:41) at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161) at org.apache.poi.openxml4j.opc.OPCPackage.(OPCPackage.java:141) at org.apache.poi.openxml4j.opc.ZipPackage.(ZipPackage.java:97) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:324) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:184) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:149)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值