无法从android studio运行即时应用

时间:2018-06-21 10:59:40

标签: android android-instant-apps

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

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

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

project structure app and base modules structure

功能模块为空,应用模块不包含任何活动,只有基本模块包含单个活动

app: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')
}

基本gradle

    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>

base:清单

   <?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

1 个答案:

答案 0 :(得分:-1)

  

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

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

如果应用程序代码的一部分,则要在基本模块中使用它。您应该创建另一个模块。一个库模块,用于包含您的常用部分,该模块将由应用程序和基本模块所包含。