代码之家  ›  专栏  ›  技术社区  ›  Ehsan

为现有应用程序创建即时应用程序

  •  1
  • Ehsan  · 技术社区  · 7 年前

    我有一个要创建的应用程序 instantApp 为了它。 我成功地将更改应用于我的项目,并且它成功地生成。

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

    Default Activity not found
    

    enter image description here

    另一个问题是当我运行 即时应用程序 我看到一条错误消息 Google Play Store has stoped

    enter image description here

    我有一个 app 两个 Instant App Feature Module 那是 base 和 feature .

    这是我的特征清单:

    <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>
    
    2 回复  |  直到 7 年前
        1
  •  1
  •   Ehsan    7 年前

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

    问题是关于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 '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{
            enabled = true
        }
    

    又是关于 room : 我必须在 manifest 因为在我的 installed 模块,因为这些提供程序用于 房间 依赖关系:

    <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
  •  0
  •   abielita    7 年前

    基于此 thread ,如果在升级Intellij IDEA或Android Studio版本后,或在生成新的APK后,看到该错误,则可能需要刷新IDE的缓存。

    File -> Invalidate Caches / Restart...

    它还意味着您没有在androidmanifest.xml中声明的活动,该活动被标记为应用程序启动时要启动的主要活动。