gpt4 book ai didi

android - 尝试添加 MultiDex 支持 - 找不到符号上下文和 MultiDex

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:22:35 55 4
gpt4 key购买 nike

按照以下位置提到的说明进行操作:https://developer.android.com/studio/build/multidex.html#mdex-gradle

我遇到错误找不到符号 class Context variable context and variable MultiDex

package com.mycompany.mypackage;

import android.app.Application;
import android.util.Log;

import com.facebook.react.ReactApplication;
import com.slowpath.hockeyapp.RNHockeyAppModule;
import com.slowpath.hockeyapp.RNHockeyAppPackage;
import com.microsoft.codepush.react.CodePush;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;

import com.sbugert.rnadmob.RNAdMobPackage;

import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;

import com.geektime.reactnativeonesignal.ReactNativeOneSignalPackage;
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;

import com.reactnative.ivpusic.imagepicker.PickerPackage;

import com.github.xinthink.rnmk.ReactMaterialKitPackage;

import com.learnium.RNDeviceInfo.RNDeviceInfo;

import com.burnweb.rnpermissions.RNPermissionsPackage;

import net.zubricky.AndroidKeyboardAdjust.AndroidKeyboardAdjustPackage;

// react-native-fbsdk
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.appevents.AppEventsLogger;
// react-native-fbads
import io.callstack.react.fbads.FBAdsPackage;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(context);
MultiDex.install(this);
}


// react-native-fbsdk
private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}
@Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
// If you want to use AppEventsLogger to log events.
AppEventsLogger.activateApp(this);
}

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {

@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}

@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNHockeyAppPackage(MainApplication.this),
new CodePush("mykey", MainApplication.this, BuildConfig.DEBUG),
new ReactNativeConfigPackage(),
new ReactNativeOneSignalPackage(),
new ReactNativePushNotificationPackage(),
new RNAdMobPackage(),
new PickerPackage(),
new ReactMaterialKitPackage(),
new RNDeviceInfo(),
new RNPermissionsPackage(),
new AndroidKeyboardAdjustPackage(),
new FBSDKPackage(mCallbackManager),
new FBAdsPackage()
);
}

};

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}

build.gradle

dependencies {
compile project(':react-native-device-info')
compile project(':react-native-hockeyapp')
compile project(':react-native-code-push')
compile project(':react-native-image-crop-picker')
compile project(':react-native-vector-icons')
compile project(':react-native-material-kit')
compile project(':react-native-config')
compile project(':RNAdMob')
compile project(':react-native-onesignal')
compile project(':react-native-push-notification')
compile project(':RNPermissionsModule')
compile project(':react-native-android-keyboard-adjust')
compile project(':react-native-fbsdk')
compile(project(':react-native-fbads')) {
exclude group: "com.google.android.gms"
}
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.google.firebase:firebase-ads:10.2.0'

compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile "com.facebook.fresco:animated-gif:0.12.0"
compile 'com.android.support:multidex:1.0.1'
}

我必须添加或导入什么才能让它工作吗?

最佳答案

感谢@Gabe Sechan 的帮助。我知道 React Native/JavaScript,对 Android/Java 有点无能,所以我只是按照 https://developer.android.com/studio/build/multidex.html#mdex-gradle 上的说明进行操作。 ,其中没有提到任何额外的进口。我学会了在这里查找我需要的包:https://developer.android.com/reference/android/support/multidex/MultiDexApplication.html .添加后:

import android.support.multidex.MultiDexApplication;

public class MainApplication extends MultiDexApplication implements ReactApplication {
...

应用程序似乎可以在 Android 4.4.4+ 设备上成功构建和运行。然而,在我运行 4.3 的三星 Galaxy S3 模拟器上,我在应用程序启动时崩溃:What does WIN DEATH: android.osDeadObjectException mean? ,这似乎完全是另一个问题。

关于android - 尝试添加 MultiDex 支持 - 找不到符号上下文和 MultiDex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42614142/

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