【问题标题】:Create Instant app for existing application为现有应用程序创建即时应用程序
【发布时间】:2019-06-10 10:37:25
【问题描述】:

我有一个应用程序,我想为它创建一个instantApp。 我成功地将更改应用到我的项目并成功构建。

但是有两个问题: -我无法运行应用程序,错误是:

Default Activity not found

另一个问题是,当我运行instantApp 时,我看到一条错误消息,上面写着Google Play Store has stoped

我有一个app 和两个Instant App Feature Module,它们是basefeature

这些是我的功能清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
          package="instantapp.samples.yaramobile.com.base.feature">

    <application tools:ignore="GoogleAppIndexingWarning">

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

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

            <intent-filter
                    android:autoVerify="true"
                    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="test.com"/>
                <data android:pathPattern="/"/>
                <data android:scheme="https"/>
                <data android:scheme="http"/>
            </intent-filter>
        </activity>

        <activity android:name=".presenter.display.DisplayActivity"/>
        <activity android:name=".presenter.display.PermissionActivity"/>
    </application>
</manifest>

【问题讨论】:

标签: android android-studio android-activity android-instant-apps


【解决方案1】:

我终于找到了问题和解决办法:

问题在于 AppCompact 依赖关系:

implementation 'androidx.appcompat:appcompat:1.0.2'

发生冲突,我不得不使用api 而不是implementation

api 'androidx.appcompat:appcompat:1.0.2'

还有一个与房间依赖的冲突:

 implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
 kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0'
 implementation 'androidx.room:room-runtime:2.1.0-alpha02'
 kapt 'androidx.room:room-compiler:2.1.0-alpha02'

我也不得不换成api

 api 'androidx.lifecycle:lifecycle-extensions:2.0.0'
 kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0'
 api 'androidx.room:room-runtime:2.1.0-alpha02'
 kapt 'androidx.room:room-compiler:2.1.0-alpha02'

另一个问题是关于databinding 我刚刚在我的基本模块中添加了databinding,但在安装的模块中也需要它:

  dataBinding{
        enabled = true
    }

又是关于room: 我不得不在基本模块的manifest 中添加一个提供程序,因为installed 模块中的合并清单出现错误,因为room 依赖项中使用了这些提供程序:

<provider
        tools:replace="android:authorities"
        android:name="androidx.lifecycle.ProcessLifecycleOwnerInitializer"
        android:authorities="codenevisha.ir.mvvmwithdagger.base.lifecycle-process"
        android:exported="false"
        android:multiprocess="true"/>

不要忘记添加 tools:replace="android:authorities" 替换此提供程序

希望这些指南对你也有用。

【讨论】:

    【解决方案2】:

    根据thread,如果您在升级 IntelliJ IDEA 或 Android Studio 版本后,或在生成新 APK 后发现该错误,您可能需要刷新 IDE 的缓存。

    File -&gt; Invalidate Caches / Restart...

    这也意味着您没有在 AndroidManifest.xml 中声明一个活动,该活动被标记为应用程序启动时要启动的主要活动。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-28
      • 1970-01-01
      • 2019-06-14
      • 2011-11-30
      • 1970-01-01
      • 2018-12-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多