【问题标题】:Unable to run instant app from android studio无法从 android studio 运行即时应用程序
【发布时间】:2018-06-21 10:59:39
【问题描述】:

我无法在即时应用程序模式下运行我的应用程序,而如果我运行应用程序模块,它工作正常。但是当我选择即时应用程序模块时,它会运行但出现白屏。

使用android studio的内置即时应用支持创建项目

关注此视频:https://www.youtube.com/watch?v=9Jg1D07NgeI&t=569s 以及 youtube 上的一些博客、代码实验室说明和其他教程

功能模块是空的应用模块不包含任何活动只有基础模块包含单个活动

应用程序:gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27

    defaultConfig {
        applicationId "com.anilsharma92.myintantapp.app"
        minSdkVersion 23
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    }

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

}

dependencies {
    implementation project(':base')
}

基础等级

    apply plugin: 'com.android.feature'

android {
    compileSdkVersion 27
    baseFeature true
    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

instant app gradle :

    apply plugin: 'com.android.instantapp'

android {
    compileSdkVersion 27

}

dependencies {
    implementation project(':base')
}


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


</manifest>

基础:清单

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

    <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">
        <meta-data
            android:name="aia-compat-api-min-version"
            android:value="1" />

        <activity android:name=".SplashActivity">
            <intent-filter
                android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

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

                <data
                    android:host="anilsharma92.000webhostapp.com"
                    android:scheme="https"
                    android:pathPattern="/splash" />
            </intent-filter>

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

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

</manifest>

asset json file

【问题讨论】:

  • 啊,您使用的是什么版本的 AS 和什么模拟器设置?某些模拟器设置存在问题,其中要渲染的最后一个对象将显示为空白/白色。 (在活动中举杯祝酒,你会明白我的意思)所以..只需使用不同的模拟器设置。

标签: android android-instant-apps


【解决方案1】:

为什么要将你的应用模块包含在基本模块中?

application project(':app') - 不应该!

如果应用程序有部分代码,您希望在基本模块中使用它。您应该创建另一个模块。一个包含你公共部分的库模块,这个模块将被应用程序和基础模块包含。

【讨论】:

    猜你喜欢
    • 2016-12-24
    • 2016-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-07
    相关资源
    最近更新 更多