Делаем частичный сбор кеша кода, код = 24КБ, данные = 30КБ android studio 3.3.2 - PullRequest
0 голосов
/ 20 апреля 2019

Мое приложение зависает и падает после добавления определенных зависимостей в Gradle.

Проблема

2019-04-15 10:17:34.573 10220-10225/com.example.app I/art: Do partial code cache collection, code=24KB, data=30KB
2019-04-15 10:17:34.573 10220-10225/com.example.app I/art: After code cache collection, code=24KB, data=30KB
2019-04-15 10:17:34.573 10220-10225/com.example.app I/art: Increasing code cache capacity to 128KB
2019-04-15 10:17:34.661 10220-10220/com.example.app D/AndroidRuntime: Shutting down VM
2019-04-15 10:17:34.683 10220-10231/? I/art: Starting a blocking GC HeapTrim
2019-04-15 10:17:34.692 10220-10227/? I/art: Debugger is no longer active
2019-04-15 10:17:34.692 10220-10227/? I/art: Starting a blocking GC Instrumentation

Я сослался на следующие ответы

"AndroidRuntime: выключение виртуальной машины", ничего больше

Logcat, показывающий «Выключение ВМ»

Получение этого исключения, которое приводит к сбою приложения Android при запуске

но никто из них не помог. Проблема остается прежней.

Manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.app"
    android:hardwareAccelerated="false"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-permission android:name="android.permission.READ_SYNC_STATS" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.GET_TOP_ACTIVITY_INFO" />
    <uses-permission
        android:name="android.permission.CAMERA"
        android:required="true" />
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-feature
        android:name="android.hardware.telephony"
        android:required="false" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <uses-feature android:name="android.hardware.camera2" />

    <application
        android:name=".sync.LogCreate"
        android:allowBackup="true"
        android:hardwareAccelerated="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".activities.ForgotPasswordActivity"></activity>
        <activity
            android:name=".activities.Splashscreen"
            android:label="@string/app_name"
            android:screenOrientation="portrait">
            <intent-filter>
              <action android:name="android.intent.action.MAIN" />

              <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".activities.LoginActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".activities.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustPan" />

        <service android:name=".sync.FirebaseMessageService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <service android:name=".sync.FirebaseInstanceIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>

</manifest>

build.gradle (приложение)

dependencies {

    implementation files('libs/httpmime-4.3.6.jar')
    implementation files('libs/picasso-2.4.0.jar')
    implementation files('libs/pixlui-1-0-5.jar')
    implementation files('libs/AndroidNBioBSPJNI.jar')
    //noinspection GradleCompatible

    //Android Support Libraries
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'com.otaliastudios:cameraview:1.5.1'

    //Firebase Services
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-messaging:17.6.0'
    implementation 'com.google.firebase:firebase-ml-vision:19.0.3'
    implementation 'com.google.firebase:firebase-ml-vision-face-model:17.0.2'
    //implementation 'com.google.android.gms:play-services:12.0.1'

    implementation 'com.mikhaellopez:circularimageview:3.0.2'
    implementation 'com.squareup:android-times-square:1.6.5@aar'
    implementation 'com.journeyapps:zxing-android-embedded:3.4.0'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.3@aar') {
        transitive = true;
    }

    implementation 'com.squareup.okhttp3:okhttp:3.2.0'
    implementation 'com.akexorcist:localizationactivity:1.2.2'
    implementation 'gun0912.ted:tedpermission-rx2:2.1.1'

    // JSON response handling library
    implementation 'com.google.code.gson:gson:2.8.5'

}
apply plugin: 'com.google.gms.google-services'

Получение проблемы с памятью при добавлении.

implementation 'com.google.firebase:firebase-ml-vision-face-model:17.0.2'

Я даже пытался внедрить те же библиотеки на новом и не получил никаких проблем там.

Application.class

public class LogCreate extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread t, Throwable e) {
                try {
                    String root = Environment.getExternalStorageDirectory().toString() + "/example";
                   FileWriter fw = new FileWriter(root + "/exception.txt", true);
                    PrintWriter pw = new PrintWriter(fw);
                    e.printStackTrace(pw);
                    Log.e("uncaughtException: ", "=" + e.getMessage());
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        });

        if (isExternalStorageWritable()) {

            String root = Environment.getExternalStorageDirectory().toString() + "/example";
            File logDirectory = new File(root + "/log");
            File logFile = new File(logDirectory, "logcat" + System.currentTimeMillis() + ".txt");

            // create log folder
            if (!logDirectory.exists()) {
                logDirectory.mkdir();
            }

            // clear the previous logcat and then write the new one to the file
            try {
                Process process = Runtime.getRuntime().exec("logcat -c");
                process = Runtime.getRuntime().exec("logcat -f " + logFile);
            } catch (IOException e) {
                e.printStackTrace();
            }

        } else if (isExternalStorageReadable()) {
            // only readable
        } else {
            // not accessible
        }
    }

    /*Checks if external storage is available for read and write */
    public boolean isExternalStorageWritable() {
        String state = Environment.getExternalStorageState();
        if (Environment.MEDIA_MOUNTED.equals(state)) {
            return true;
        }
        return false;
    }

    /*Checks if external storage is available to at least read */
    public boolean isExternalStorageReadable() {
        String state = Environment.getExternalStorageState();
        if (Environment.MEDIA_MOUNTED.equals(state) ||
                Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
            return true;
        }
        return false;
    }
}

Любая помощь будет отличной.

Заранее спасибо

...