gpt4 book ai didi

java - Android butterknife 多重分包

转载 作者:太空宇宙 更新时间:2023-11-04 11:16:26 24 4
gpt4 key购买 nike

我在我的应用程序中启用了 miltidex。 API 21+ 工作正常。Android api 16 原因:

java.lang.NoClassDefFoundError: ......AuthorizationController

如果我评论 BN 绑定(bind),一切都会正常。启用 Multidex:multiDexEnabled true,编译 'com.android.support:multidex:1.0.1' 等。有什么办法让它发挥作用吗?

编辑

梯度

    buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }
}


android {
signingConfigs {
prod_release {
...
}
}
compileSdkVersion 25
buildToolsVersion "25.0.3"
productFlavors {
dev {
// Enable pre-dexing to produce an APK that can be tested on
// Android 5.0+ without the time-consuming DEX build processes.
minSdkVersion 16
signingConfig signingConfigs.prod_release
}
prod {
// The actual minSdkVersion for the production version.
minSdkVersion 16
signingConfig signingConfigs.prod_release
}
}
defaultConfig {
applicationId "ru.wearemad.gravo"
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dexOptions {
javaMaxHeapSize "2g"
preDexLibraries = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.prod_release
}
debug {
signingConfig signingConfigs.prod_release
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.google.code.findbugs'
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
//retrofit
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
//rxjava 2
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.1.1'
//butterknife
compile 'com.jakewharton:butterknife:8.7.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
//mosby + conductor
compile 'com.bluelinelabs:conductor-support:2.1.4'
compile 'com.hannesdorfmann.mosby3:mvp-conductor:3.0.0'
compile 'com.hannesdorfmann.mosby3:viewstate:3.0.4'
compile 'com.hannesdorfmann.mosby3:viewstate-conductor:3.0.0'
compile 'com.madgag.spongycastle:core:1.54.0.0'
compile 'com.madgag.spongycastle:prov:1.54.0.0'
compile 'com.madgag.spongycastle:pkix:1.54.0.0'
compile 'com.madgag.spongycastle:pg:1.54.0.0'
// testCompile 'junit:junit:4.12'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.orhanobut:hawk:1.+'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
compile 'com.android.support:multidex:1.0.1'
}

list 部分:

<application
android:name="ru.wearemad.gravo.MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

应用程序类:

public class MyApplication extends MultiDexApplication {...}

我尝试添加 multiDexKeepProguard,但 gradle 没有看到该方法,或者方法的声明已更改。

编辑2Bitterknife.bind() 中返回的 Butterknife Unbinder 会带来麻烦。有什么解决办法吗?

最佳答案

Have you included following? If you do not override the Application class, edit your manifest file to set android:name in the tag as follows:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>

if you do override the Application class but it's not possible to change the base class, then you can instead override the attachBaseContext() method and call MultiDex.install(this) to enable multidex:

public class MyApplication extends SomeOtherApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}

Further read

关于java - Android butterknife 多重分包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45414285/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com