Java android RuntimeException无法实例化活动ComponentInfo

时间:2018-08-20 08:48:45

标签: java android

在s4 mini上,当我午餐应用程序时,它无法启动。我看到该应用程序已停止。在Samsung s5上,它可以正常工作。

S4 mini具有android 4.4.2 API 19

  

java.lang.RuntimeException:无法实例化活动ComponentInfo {pl。 / pl。 < strong> .smokterminal。 .LoginActivity}:java.lang.ClassNotFoundException:找不到类“ pl。 。路径上的Activity.LoginActivity”:DexPathList [[zip文件“ /data/app/pl..-18.apk"],nativeLibraryDirectories=[/data/app- lib / pl.eltegps.smokterminal-18,/ vendor / lib,/ system / lib]]

这是我的意思:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="pl.eltegps.smokterminal">

    <uses-feature
        android:name="android.hardware.camera"
        android:required="true" />
    <uses-feature android:name="android.hardware.location.gps" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/icon80"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="pl.eltegps.smokterminal.provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths" />
        </provider>


        <service android:name=".Service.UploadPhotosService" />
        <service android:name=".Service.CommunicationsService" />
        <service android:name=".Service.GPSTracker" />

        <activity
            android:name=".Activity.LoginActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar"
            android:windowSoftInputMode="stateVisible|adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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


</manifest>

build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'


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

        classpath 'io.fabric.tools:gradle:1.22.2'
    }
}

repositories {
    mavenCentral()
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }

}

android {
    signingConfigs {

        defaultConfig {
            buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L"
            buildConfigField 'String', 'BUILD_TIME', 'new java.text.SimpleDateFormat("MM.dd.yy HH:mm", java.util.Locale.GERMANY).format(new java.util.Date(' + System.currentTimeMillis() + 'L))'

        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }
    compileSdkVersion 27
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "pl.eltegps.smokterminal"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 37
        versionName "1.3.3"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        ndk {
            abiFilters "armeabi-v7a", "x86", "armeabi"
        }
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}

configurations.all {
    resolutionStrategy {
        force 'com.android.support:recyclerview-v7:23.1.1'
        force 'com.android.support:support-annotations:23.1.1'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile(group: 'org.simpleframework', name: 'simple-xml', version: '2.7.1') {
        exclude module: 'stax'
        exclude module: 'stax-api'
        exclude module: 'xpp3'
    }
    //compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'

    compile('io.socket:socket.io-client:1.0.0') {
        // excluding org.json which is provided by Android
        exclude group: 'org.json', module: 'json'
    }

    // https://mvnrepository.com/artifact/com.google.guava/guava
    compile group: 'com.google.guava', name: 'guava', version: '19.0'

    // https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
    compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.2.0'
    compile group: 'com.squareup.picasso', name: 'picasso', version: '2.5.0'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient


    compile('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.6@aar') {
        transitive = true;
    }


    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.loopj.android:android-async-http:1.4.9'
    //noinspection GradleCompatible
    compile 'com.android.support:appcompat-v7:24.2.0'
    //noinspection GradleCompatible
    compile 'com.android.support:design:24.2.0'
    compile 'com.daimajia.swipelayout:library:1.2.0@aar'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'net.zetetic:android-database-sqlcipher:3.5.4@aar'
    compile 'com.squareup.moshi:moshi:1.2.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'com.github.orhanobut:hawk:1.23'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'org.jsoup:jsoup:1.11.1'
    compile 'com.android.support:multidex:1.0.1'
    testCompile 'junit:junit:4.12'
    compile 'com.google.firebase:firebase-core:11.8.0'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
    // https://mvnrepository.com/artifact/joda-time/joda-time
    compile group: 'joda-time', name: 'joda-time', version: '2.3'
    // https://mvnrepository.com/artifact/org.apache.commons/commons-io

    //noinspection GradleCompatible
    compile 'com.google.android.gms:play-services-identity:11.8.0'
    compile 'com.google.android.gms:play-services-location:11.8.0'

// https://mvnrepository.com/artifact/commons-io/commons-io
    compile group: 'commons-io', name: 'commons-io', version: '2.6'

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

1 个答案:

答案 0 :(得分:1)

从类似的问题中,我发现最建议的解决方案是将其添加到依赖项中:

defaultConfig {
    multiDexEnabled true
}