weixin_39125267
2018-03-12 03:44
采纳率: 14.3%
浏览 1.3k

android studio 关于jar包问题 不知道怎么解决

apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
useLibrary 'org.apache.http.legacy'

defaultConfig {
    applicationId "com.mynj"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }

}

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'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.1.2'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'

compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'

compile 'com.squareup.picasso:picasso:2.5.1'
compile 'com.github.bumptech.glide:glide:3.5.2'

}

运行之后报错

Gradle build finished with 186 error(s) in 1m 39s 514ms

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.mysql.jdbc.ConnectionImpl$1) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is not an inner class.
Error:(com.mysql.jdbc.ConnectionImpl$10) that doesn't come with an
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:indicate that it is not an inner class.
Error:(com.mysql.jdbc.ConnectionImpl$2) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is not an inner class.
Error:(com.mysql.jdbc.ConnectionImpl$3) that doesn't come with an
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is not an inner class.

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • feihaokui 2018-03-12 03:56
    已采纳

    我试过的方法:
    #保留Annotation不混淆
    -keepattributes Annotation,InnerClasses,EnclosingMethod
    或者这样
    首先修改Gradle配置文件,启用MultiDex并包含MultiDex支持:

    defaultConfig {
    multiDexEnabled true
    }

    dependencies { compile 'com.android.support:multidex:1.0.1' }

    然后让应用支持多DEX文件。在MultiDexApplication JavaDoc中描述了三种可选方法:

    1、在AndroidManifest.xml的application中声明android.support.multidex.MultiDexApplication;
    2、如果你已经有自己的Application类,让其继承MultiDexApplication;
    3、如果你的Application类已经继承自其它类,你不想修改它,那么可以重写attachBaseContext()方法:

     @Override   
    protected void attachBaseContext(Context base) {  
        super.attachBaseContext(base); MultiDex.install(this);  
    }  
    
    打赏 评论
  • feihaokui 2018-03-12 07:00

    你这是重复依赖导致jar包冲突了, 你先(双击shift)搜索定位一下这个类com/google/gson/annotations/Expose.class,看看是哪些依赖重复依赖了gson这个类库。

    打赏 评论

相关推荐 更多相似问题