Fixed multidex configuration for android 4.4

This commit is contained in:
Julien Eluard 2017-08-07 14:21:07 +02:00 committed by Roman Volosovskyi
parent d999927352
commit c378098d3b
4 changed files with 30 additions and 16 deletions

View File

@ -160,6 +160,7 @@ android {
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile project(':react-native-http-bridge')
compile project(':nfc-react-native')
compile project(':instabug-reactnative')

View File

@ -1,15 +1,21 @@
package im.status.ethereum;
import android.content.Context;
import android.app.AlertDialog;
import android.app.ActivityManager;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.support.multidex.MultiDexApplication;
import android.os.Looper;
import android.util.Log;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Looper;
import android.util.Log;
import com.facebook.react.ReactActivity;
import com.cboy.rn.splashscreen.SplashScreen;
import com.testfairy.TestFairy;
@ -18,8 +24,7 @@ import java.util.Properties;
public class MainActivity extends ReactActivity {
private void registerUncaughtExceptionHandler() {
// Make sure we get an Alert for every uncaught exceptions
private static void registerUncaughtExceptionHandler(final Context context) {
final Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
@ -29,7 +34,7 @@ public class MainActivity extends ReactActivity {
public void run() {
Looper.prepare();
new AlertDialog.Builder(MainActivity.this)
new AlertDialog.Builder(context)
.setTitle("Error")
.setMessage(t.toString())
.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
@ -46,14 +51,16 @@ public class MainActivity extends ReactActivity {
});
}
private ActivityManager.MemoryInfo getAvailableMemory() {
ActivityManager activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
private ActivityManager getActivityManager() {
return (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
}
private ActivityManager.MemoryInfo getAvailableMemory(final ActivityManager activityManager) {
final ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
return memoryInfo;
}
protected void configureStatus() {
// Required because of crazy APN settings redirecting localhost (found in GB)
Properties properties = System.getProperties();
@ -63,8 +70,13 @@ public class MainActivity extends ReactActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
registerUncaughtExceptionHandler();
Log.v("RNBootstrap", "Available memory "+getAvailableMemory().availMem);
// Make sure we get an Alert for every uncaught exceptions
registerUncaughtExceptionHandler(MainActivity.this);
// Report memory details for this application
final ActivityManager activityManager = getActivityManager();
Log.v("RNBootstrap", "Available system memory "+getAvailableMemory(activityManager).availMem + ", maximum usable application memory " + activityManager.getLargeMemoryClass()+"M");
SplashScreen.show(this);
super.onCreate(savedInstanceState);

View File

@ -1,6 +1,6 @@
package im.status.ethereum;
import android.app.Application;
import android.support.multidex.MultiDexApplication;
import com.BV.LinearGradient.LinearGradientPackage;
import com.aakashns.reactnativedialogs.ReactNativeDialogsPackage;
import com.bitgo.randombytes.RandomBytesPackage;
@ -30,7 +30,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
public class MainApplication extends MultiDexApplication implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
@ -75,4 +75,5 @@ public class MainApplication extends Application implements ReactApplication {
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}

View File

@ -1,12 +1,12 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
compileSdkVersion 24
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}