我遵循了https://developer.android.com/studio/build/multidex
上的说明这是我的错误代码。 任务':app:lintVitalRelease'的执行失败。
无法解析配置的所有工件
':app:debugAndroidTestRuntimeClasspath'。 找不到com.android.support:multidex-instrumentation:27.1.1。
但是我尝试获取签名的apk时遇到了同样的问题,这是我的依赖:
defaultConfig {
applicationId "com.myproject"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
multiDexEnabled true
}
dependencies {
implementation project(':react-native-date-picker')
implementation project(':react-native-wheel-picker-android')
implementation project(':lottie-react-native')
implementation project(':react-native-firebase')
implementation "com.google.firebase:firebase-auth:16.0.5"
implementation "com.google.android.gms:play-services-base:16.0.1"
implementation "com.google.firebase:firebase-core:16.0.4"
implementation 'com.android.support:multidex:1.0.3'
implementation project(':react-native-svg')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.android.support:design:25.4.0'
implementation "com.android.support:appcompat-
v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-navigation')
implementation project(':react-native-linear-gradient')
}
和我的MainApplication.java:
public class MainApplication extends NavigationApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
@Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}
protected List<ReactPackage> getPackages() {
// Add additional packages you require here
// No need to add RnnPackage and MainReactPackage
return Arrays.<ReactPackage>asList(
new LinearGradientPackage(),
new LottiePackage(),
new RNFirebasePackage(),
new RNFirebaseAuthPackage(),
new WheelPickerPackage(),
new DatePickerPackage()
);
}
@Override
public List<ReactPackage> createAdditionalReactPackages() {
return getPackages();
}
@Override
public String getJSMainModuleName() {
return "index";
}
}
感谢前进
答案 0 :(得分:1)
删除此行
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
在MainApplication.java
implementation 'com.android.support:multidex:1.0.3'
在build.gradle
将minSdkVersion升级到21解决了我的问题
答案 1 :(得分:1)
React-native + rnn v2遇到相同问题 解决方案: 如果将minSdkVersion设置为21或更高,则只需在模块级build.gradle文件中将multiDexEnabled设置为true,如下所示:
android { defaultConfig { ... minSdkVersion 21 targetSdkVersion 28 multiDexEnabled是 } ... }
但是,如果将minSdkVersion设置为20或更低,则必须使用multidex支持库,如下所示: 然后按照此处的官方说明进行操作 https://developer.android.com/studio/build/multidex