生成APK构建并尝试从设备即时应用运行时出错

时间:2018-06-25 13:08:17

标签: android android-instant-apps android-instant-run

在Android Studio中运行

即时应用程序 FINE 时,该应用程序运行正常,但是在生成APK版本并尝试从设备运行该应用程序时出现错误 在小米Noughat设备中变得低于错误 通过显示此消息“解析软件包时出现问题” ,应用立即崩溃 我使用了即时应用开发版本 1.3.0 ,还通过设置>谷歌>即时应用

启用了即时应用设置
E/Icon: Unable to load resource 0x00000000 from pkg=com.android.systemui
android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:201)
    at android.content.res.MiuiResourcesImpl.getValue(MiuiResourcesImpl.java:91)
    at android.content.res.Resources.getDrawable(Resources.java:784)
    at android.graphics.drawable.Icon.loadDrawableInner(Icon.java:316)
    at android.graphics.drawable.Icon.loadDrawable(Icon.java:272)
    at android.graphics.drawable.Icon.loadDrawableAsUser(Icon.java:380)
    at com.android.systemui.statusbar.ExpandedIcon.getDrawable(ExpandedIcon.java:59)
    at com.android.systemui.statusbar.StatusBarIconView.getIcon(StatusBarIconView.java:174)
    at com.android.systemui.statusbar.StatusBarIconView.setIcon(StatusBarIconView.java:133)
    at com.android.systemui.statusbar.StatusBarIconView.updateDarkMode(StatusBarIconView.java:266)
    at com.android.systemui.statusbar.phone.SimpleStatusBar.updateDarkMode(SimpleStatusBar.java:264)
    at com.android.systemui.statusbar.phone.PhoneStatusBar$17.run(PhoneStatusBar.java:3494)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6195)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764)

并低于棒棒糖设备中的错误

package - Android: Parse error when parsing manifest. Discontinuing installation

在这里我列出了项目的清单文件和gradle文件

instantapp gradle

apply plugin: 'com.android.instantapp'
dependencies {
implementation project(':feature')
implementation project(':base')}

功能模块gradle和manifest

apply plugin: 'com.android.feature'
    android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':base')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myfirstinstantapp.feature">
<uses-permission android:name="android.permission.INTERNET" />
<application>
    <activity android:name="com.example.myfirstinstantapp.feature.MainActivity">
        <meta-data
            android:name="default-url"
            android:value="https://myfirstinstantapp.example.com/hello" />

        <intent-filter android:order="1">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />

            <data
                android:host="myfirstinstantapp.example.com"
                android:pathPattern="/.*"
                android:scheme="https" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

=========================================

基本模块gradle和清单

apply plugin: 'com.android.feature'
android {
    compileSdkVersion 28
    baseFeature true
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    api 'com.android.support:appcompat-v7:28.0.0-alpha3'
    api 'com.android.support.constraint:constraint-layout:1.1.2'
    application project(':app')
    feature project(':feature')
}


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myfirstinstantapp">
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity" />
    </application>
</manifest>

=========================================

应用gradle和清单

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.myfirstinstantapp.app"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"


    }
    buildTypes {
       release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
    }

}
dependencies {
    implementation project(':feature')
    implementation project(':base')
}

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myfirstinstantapp.app" />

=========================================

项目级别gradle

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我在这里附上了我的项目结构的屏幕截图

enter image description here

0 个答案:

没有答案