应用无法在具有更高API的测试设备上启动

时间:2018-02-19 08:21:04

标签: android gradle android-activity crash

我有一个Android应用程序在我的测试设备(API 17)上运行得很好。但是,当我在具有较高API的设备上运行相同的应用时(在这种情况下为22),该应用无法启动。

所有这些设备都是真正的设备而不是模拟器

    02/19 11:10:07: Launching app
$ adb shell am start -n "com.example.user.eafya/com.example.user.eafya.activities.FirstActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n 
"com.example.user.eafya/com.example.user.eafya.activities.FirstActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.user.eafya/.activities.FirstActivity }
Error type 3
Error: Activity class {com.example.user.eafya/com.example.user.eafya.activities.FirstActivity} does not exist.

Error while Launching activity

第一个活动是清单文件中的启动器活动。

以下是build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.user.eafya"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        resValue "string", "google_maps_key", (project.findProperty("GOOGLE_MAPS_API_KEY") ?: "")
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.android.support:multidex:1.0.1'
    implementation 'com.android.support:support-v4:26.1.0'
    compile 'com.google.android.gms:play-services:11.2.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.mikhaellopez:circularimageview:3.0.2'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation files('libs/gson-2.8.2.jar')
    implementation files('libs/okhttp-3.0.0-RC1.jar')
}
repositories {
    mavenCentral()
}

apply plugin: 'kotlin-android-extensions'

清单

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

    <!--
         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but you must specify either coarse or fine
         location permissions for the 'MyLocation' functionality. 
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <!--
         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but you must specify either coarse or fine
         location permissions for the 'MyLocation' functionality.
    -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:name=".activities.AppController"
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".activities.MainActivity" />
        <activity android:name=".activities.FirstActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".activities.RegisterActivity"
            android:label="Register" />
        <activity
            android:name=".activities.ClinicalHistory"
            android:label="LOG IN" />
        <activity
            android:name=".activities.LoginActivity"
            android:label="LOG IN" />
        <activity android:name=".activities.AddAllergy" />
        <activity
            android:name=".activities.ClinicalHistoryDetailActivity"
            android:label="LOG IN" />
        <activity android:name=".activities.Appointments" />
        <activity
            android:name=".activities.Allergies"
            android:label="@string/title_activity_allergies"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".activities.MedicalTips"
            android:label="News" />
        <activity android:name=".activities.MedicalDetailActivity" />
        <activity android:name=".activities.Wallet" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

        <activity
            android:name=".activities.MapsActivityCurrentPlace"
            android:label="@string/title_activity_maps" />
        <activity android:name=".activities.AddChronics" />
        <activity android:name=".activities.AllergyDetail"></activity>
    </application>

</manifest>

1 个答案:

答案 0 :(得分:0)

感谢大家的贡献。这是我发现的。我将启动器活动更改为&#34; FirstActivity&#34;以外的其他活动。那也失败了,但至少它给了我一个错误:

java.lang.RuntimeException: A TaskDescription's primary color should be opaque

将原色(使用colors.xml上的颜色托盘)更改为完全不透明后,一切正常。

我调整了primary和primaryDark的透明度,这似乎是个问题。